Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

pointSprite.geom 1.52 KB
Newer Older
1
2
3
4
5
// PointSprite::geometryShaderText

uniform float size;
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
6
7
#ifdef WITH_PLANE
	uniform vec3 eyePos;
Sylvain Thery's avatar
Sylvain Thery committed
8
	VARYING_OUT vec3 shiftedEye;
9
#endif
10

Sylvain Thery's avatar
Sylvain Thery committed
11
VARYING_OUT vec2 spriteCoord;
12
VARYING_OUT vec3 sphereCenter;
Sylvain Thery's avatar
Sylvain Thery committed
13

14
15
16
17
18
#ifdef WITH_COLOR_PER_VERTEX 
	VARYING_IN vec3 color[1];
	VARYING_OUT vec3 colorsprite;
#endif

Sylvain's avatar
Sylvain committed
19
#ifdef WITH_PLANE
20
21
	void corner( vec4 center, vec3 planeX, vec3 planeY, float x, float y)
	{
Sylvain Thery's avatar
Sylvain Thery committed
22
23
		spriteCoord = vec2(x,y);
		vec4 pos = center + size*( x*vec4(planeX,0.0) + y*vec4(planeY,0.0)+ vec4(0.0,0.0,0.5,0.0)); 
24
25
26
27
28
29
		gl_Position = ProjectionMatrix *  pos;
		EmitVertex();
	}
#else
	void corner( vec4 center, float x, float y)
	{
Sylvain Thery's avatar
Sylvain Thery committed
30
31
		spriteCoord = vec2(x,y);
		vec4 pos = center + vec4(size*x, size*y, 0.0, 0.0);
32
33
34
		gl_Position = ProjectionMatrix *  pos;
		EmitVertex();
	}
Sylvain's avatar
Sylvain committed
35
36
#endif

37
38
void main()
{
Sylvain's avatar
Sylvain committed
39
40
41
42
43
44

#ifdef WITH_COLOR_PER_VERTEX 
	colorsprite = color[0];
#endif

	vec4 posCenter = ModelViewMatrix * POSITION_IN(0);
45
	sphereCenter = posCenter.xyz;
Sylvain Thery's avatar
Sylvain Thery committed
46
	
47
#ifdef WITH_PLANE
Sylvain Thery's avatar
Sylvain Thery committed
48
49
50
	shiftedEye = eyePos - sphereCenter;
	vec3 V = -shiftedEye;
	normalize(V);
Sylvain's avatar
Sylvain committed
51

Sylvain Thery's avatar
Sylvain Thery committed
52
53
54
55
56
57
58
59
	vec3 planeX = vec3(-V[2],0.0,V[0]); //cross(V, vec3(0.0,1.0,0.0));
	normalize(planeX);
	vec3 planeY = cross(planeX,V);

	corner(posCenter, planeX, planeY, -1.4, 1.4);
	corner(posCenter, planeX, planeY, -1.4,-1.4);
	corner(posCenter, planeX, planeY,  1.4, 1.4);
	corner(posCenter, planeX, planeY,  1.4,-1.4);
60
#else
Sylvain Thery's avatar
Sylvain Thery committed
61
62
63
64
	corner(posCenter, -1.4, 1.4);
	corner(posCenter, -1.4,-1.4);
	corner(posCenter,  1.4, 1.4);
	corner(posCenter,  1.4,-1.4);
65
#endif	
66
67
	EndPrimitive();
}
Sylvain Thery's avatar
Sylvain Thery committed
68