22
33#if defined VERTEX_SHADER
44
5- in vec3 in_Position ;
5+ in vec3 in_position ;
66
7- uniform mat4 ProjM;
8- uniform mat4 ModelViewM;
9- uniform mat3 NormalM;
10-
11- out vec3 normal;
12- out vec2 uv0;
7+ uniform mat4 m_proj;
8+ uniform mat4 m_mv;
9+ uniform mat3 m_normal;
1310
1411void main() {
15- gl_Position = vec4 (in_Position , 1.0 );
12+ gl_Position = vec4 (in_position , 1.0 );
1613}
1714
1815#elif defined FRAGMENT_SHADER
@@ -22,7 +19,7 @@ uniform sampler2D texture0;
2219uniform float time;
2320
2421in vec3 normal;
25- in vec2 uv0 ;
22+ in vec2 uv ;
2623in vec3 lightdir;
2724in vec3 eyepos;
2825
@@ -34,7 +31,7 @@ void main()
3431 vec4 specular = vec4 (1.0 , 1.0 , 1.0 , 1.0 );
3532 float shininess = 0.5 ;
3633
37- vec4 c = texture(texture0, uv0 );
34+ vec4 c = texture(texture0, uv );
3835 vec4 spec = vec4 (0.0 );
3936
4037 vec3 n = normalize (normal);
@@ -58,13 +55,13 @@ void main()
5855layout (points) in ;
5956layout (triangle_strip, max_vertices = 24 ) out ; // 4 vertices per side of the cube
6057
61- uniform mat4 ProjM ;
62- uniform mat4 ModelViewM ;
63- uniform mat3 NormalM ;
58+ uniform mat4 m_proj ;
59+ uniform mat4 m_mv ;
60+ uniform mat3 m_normal ;
6461uniform vec3 lightpos;
6562uniform float time;
6663
67- out vec2 uv0 ;
64+ out vec2 uv ;
6865out vec3 normal;
6966out vec3 lightdir;
7067out vec3 eyepos;
@@ -82,11 +79,11 @@ vec3 cube_corners[8] = vec3[] (
8279);
8380
8481#define EMIT_V(POS, UV, NORMAL) \
85- uv0 = UV; \
86- normal = normalize (NormalM * NORMAL); \
82+ uv = UV; \
83+ normal = normalize (m_normal * NORMAL); \
8784 lightdir = lightpos - POS.xyz; \
8885 eyepos = - POS.xyz; \
89- gl_Position = ProjM * vec4 (POS, 1.0 ); \
86+ gl_Position = m_proj * vec4 (POS, 1.0 ); \
9087 EmitVertex()
9188
9289#define EMIT_QUAD(P1, P2, P3, P4, NORMAL) \
@@ -109,7 +106,7 @@ void main()
109106 pos.x += cos (time + gl_in[0 ].gl_Position .x);
110107 pos.z += cos (time + gl_in[0 ].gl_Position .z);
111108
112- corners[i] = (ModelViewM * vec4 (pos, 1.0 )).xyz;
109+ corners[i] = (m_mv * vec4 (pos, 1.0 )).xyz;
113110 }
114111 EMIT_QUAD(3 , 2 , 0 , 1 , vec3 ( 0.0 , 0.0 , - 1.0 )); // back
115112 EMIT_QUAD(6 , 7 , 5 , 4 , vec3 ( 0.0 , 0.0 , 1.0 )); // front
0 commit comments