#version 130 #extension GL_ARB_explicit_attrib_location: require uniform mat4 mvp; uniform mat3 mv_normal; layout(location = 0) in vec2 uv; out vec4 color; out vec2 frag_uv; // Direction of the normal in camera-space. out vec3 normal_cs; void main(void) { /* Center the region at the origin. Assume that it's 7 units by 7 * units. */ vec2 bias_uv = uv - 0.5; vec4 position = vec4(bias_uv.x * 7., 0.0, bias_uv.y * 7., 1.0); gl_Position = mvp * position; /* Transform the normal by the inverse-transpose of the model-view * matrix. */ normal_cs = mv_normal * vec3(0., 1., 0.); frag_uv = uv; }