#version 330 uniform vec2 uViewportRes; uniform mat4 model; uniform mat4 view; uniform mat4 projection; layout (location = 0) in vec3 position; layout (location = 1) in vec3 tangent; layout (location = 2) in vec4 iColor; layout (location = 3) in float iLineWidth; out vec4 color; out float lineWidth; out float lineStrength; void main(void) { int index = gl_VertexID % 6; float orientation = 1.0f + ( (index % 2) * -2 ); vec4 positionScreen = projection * view * model * vec4(position, 1.0f); vec4 directionScreen = projection * view * model * vec4(position + tangent, 0.0f); vec4 normal = positionScreen - directionScreen; positionScreen.xyz /= positionScreen.w; positionScreen.xy *= (uViewportRes * 0.5f); float aspectRatio = projection[1][1] / projection[0][0]; normal.xyz /= normal.w; positionScreen += vec4(normalize(normal.yx * vec2(-1.0f, 1.0f) * orientation), 0.0f, 0.0f) * 0.5f * iLineWidth; positionScreen.xy /= (uViewportRes * 0.5f); positionScreen.xyz *= positionScreen.w; gl_Position = positionScreen; lineWidth = iLineWidth; lineStrength = orientation; color = iColor; } void mainBackup(void) { float aspectRatio = 0.0f; int index = gl_VertexID % 6; float orientation = 1 + ( (index % 2) * -2 ); vec4 positionCamera = view * model * vec4(position, 1.0f); float distance = -position.z; vec4 tv = projection * view * model * vec4(position + tangent, 0.0f); vec4 v = vec4(normalize(tv.yx) * orientation * vec2(-1.0f, 1.0f), 0.0f, 0.0f) * distance; vec4 direction = positionCamera - tv; direction.xy = direction.yx * vec2(-1.0f, 1.0f) * orientation; gl_Position = (projection * positionCamera) + vec4(direction.xy, 0.0f, 0.0f); lineWidth = iLineWidth; lineStrength = orientation; color = vec4(iColor.xyz, 1.0f); }