shaderBoldColorLines.geom 811 Bytes
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1 2
// ShaderBoldColorLines::geometryShaderText

Sylvain Thery's avatar
Sylvain Thery committed
3
uniform vec2 lineWidth;
Sylvain Thery's avatar
Sylvain Thery committed
4 5 6 7 8 9 10 11 12

VARYING_IN vec3 vcolor[];
VARYING_OUT vec3 fragColor;

VARYING_IN vec3 posClip[];
VARYING_OUT vec3 fragClip;

void main()
{
Sylvain Thery's avatar
Sylvain Thery committed
13 14 15

	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
16 17 18 19

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

Sylvain Thery's avatar
Sylvain Thery committed
20
	vec3 LW = vec3(lineWidth,1.0);
Sylvain Thery's avatar
Sylvain Thery committed
21 22
	fragClip = posClip[0];
	fragColor = vcolor[0];
Sylvain Thery's avatar
Sylvain Thery committed
23
	gl_Position = vec4(A-U*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
24
	EmitVertex();
Sylvain Thery's avatar
Sylvain Thery committed
25
	gl_Position = vec4(A+V*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
26
	EmitVertex();
Sylvain Thery's avatar
Sylvain Thery committed
27
	gl_Position = vec4(A-V*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
28 29 30
	EmitVertex();
	fragColor = vcolor[1];
	fragClip = posClip[1];
Sylvain Thery's avatar
Sylvain Thery committed
31
	gl_Position = vec4(B+V*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
32
	EmitVertex();
Sylvain Thery's avatar
Sylvain Thery committed
33
	gl_Position = vec4(B-V*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
34
	EmitVertex();
Sylvain Thery's avatar
Sylvain Thery committed
35
	gl_Position = vec4(B+U*LW, 1.0);
Sylvain Thery's avatar
Sylvain Thery committed
36 37 38 39
	EmitVertex();

	EndPrimitive();
}