shaderBoldLines.geom 700 Bytes
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1 2
// ShaderBoldLines::geometryShaderText

Sylvain Thery's avatar
Sylvain Thery committed
3
uniform vec2 lineWidth;
Sylvain Thery's avatar
Sylvain Thery committed
4 5 6 7 8
VARYING_IN vec3 posClip[];
VARYING_OUT vec3 fragClip;

void main()
{
Sylvain Thery's avatar
Sylvain Thery committed
9 10
	vec3 A = POSITION_IN(0).xyz / abs(POSITION_IN(0).w);
	vec3 B = POSITION_IN(1).xyz / abs(POSITION_IN(1).w);
Sylvain Thery's avatar
Sylvain Thery committed
11 12 13 14

	vec3 U = normalize(B-A);
	vec3 V = cross(U,vec3(0.0,0.0,1.0));

Sylvain Thery's avatar
Sylvain Thery committed
15
	vec3 LW = vec3(lineWidth,1.0);
Sylvain Thery's avatar
Sylvain Thery committed
16
	fragClip = posClip[0];
Sylvain Thery's avatar
Sylvain Thery committed
17
	gl_Position = vec4(A-U*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
18
	EmitVertex();
Sylvain Thery's avatar
Sylvain Thery committed
19
	gl_Position = vec4(A+V*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
20
	EmitVertex();
Sylvain Thery's avatar
Sylvain Thery committed
21
	gl_Position = vec4(A-V*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
22 23
	EmitVertex();
	fragClip = posClip[1];
Sylvain Thery's avatar
Sylvain Thery committed
24
	gl_Position = vec4(B+V*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
25
	EmitVertex();
Sylvain Thery's avatar
Sylvain Thery committed
26
	gl_Position = vec4(B-V*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
27
	EmitVertex();
Sylvain Thery's avatar
Sylvain Thery committed
28
	gl_Position = vec4(B+U*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
29 30 31
	EmitVertex();
	EndPrimitive();
}