mirror of
https://github.com/overte-org/overte.git
synced 2025-06-17 16:20:32 +02:00
60 lines
No EOL
1.7 KiB
Text
60 lines
No EOL
1.7 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// Created by Bradley Austin Davis on 2016/07/05
|
|
// Copyright 2013-2016 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
<@include gpu/Transform.slh@>
|
|
<$declareStandardTransform()$>
|
|
|
|
layout(std140) uniform lineData {
|
|
vec4 p1;
|
|
vec4 p2;
|
|
vec4 color;
|
|
float width;
|
|
};
|
|
|
|
out vec4 _color;
|
|
// the distance from the center in 'quad space'
|
|
out float distanceFromCenter;
|
|
|
|
void main(void) {
|
|
_color = color;
|
|
|
|
TransformCamera cam = getTransformCamera();
|
|
TransformObject obj = getTransformObject();
|
|
|
|
vec4 p1eye, p2eye;
|
|
<$transformModelToEyePos(cam, obj, p1, p1eye)$>
|
|
<$transformModelToEyePos(cam, obj, p2, p2eye)$>
|
|
p1eye /= p1eye.w;
|
|
p2eye /= p2eye.w;
|
|
|
|
// Find the line direction
|
|
vec3 v1 = normalize(p1eye.xyz - p2eye.xyz);
|
|
// Find the vector from the eye to one of the points
|
|
vec3 v2 = normalize(p1eye.xyz);
|
|
// The orthogonal vector is the cross product of these two
|
|
vec3 orthogonal = cross(v1, v2) * width;
|
|
|
|
// Deteremine which end to emit based on the vertex id (even / odd)
|
|
vec4 eye = (0 == gl_VertexID % 2) ? p1eye : p2eye;
|
|
|
|
// Add or subtract the orthogonal vector based on a different vertex ID
|
|
// calculation
|
|
if (gl_VertexID < 2) {
|
|
distanceFromCenter = -1.0;
|
|
eye.xyz -= orthogonal;
|
|
} else {
|
|
distanceFromCenter = 1.0;
|
|
eye.xyz += orthogonal;
|
|
}
|
|
|
|
// Finally, put the eyespace vertex into clip space
|
|
<$transformEyeToClipPos(cam, eye, gl_Position)$>
|
|
} |