2016-05-05 19:50:03 +02:00
|
|
|
#version 450
|
|
|
|
|
|
|
|
#ifdef GL_ES
|
|
|
|
precision highp float;
|
|
|
|
#endif
|
|
|
|
|
2016-07-17 20:29:53 +02:00
|
|
|
uniform mat4 transpV;
|
|
|
|
uniform mat4 invP;
|
2016-05-05 19:50:03 +02:00
|
|
|
uniform mat4 invVP;
|
|
|
|
uniform vec3 eye;
|
|
|
|
|
|
|
|
in vec2 pos;
|
|
|
|
|
|
|
|
out vec2 texCoord;
|
|
|
|
out vec3 viewRay;
|
2016-07-17 20:29:53 +02:00
|
|
|
out vec3 vecnormal;
|
2016-05-05 19:50:03 +02:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
// Scale vertex attribute to [0-1] range
|
2016-10-17 17:39:40 +02:00
|
|
|
const vec2 madd = vec2(0.5, 0.5);
|
2016-05-05 19:50:03 +02:00
|
|
|
texCoord = pos.xy * madd + madd;
|
2017-06-23 15:47:51 +02:00
|
|
|
#ifdef _InvY
|
|
|
|
texCoord.y = 1.0 - texCoord.y;
|
|
|
|
#endif
|
2016-05-05 19:50:03 +02:00
|
|
|
|
|
|
|
gl_Position = vec4(pos.xy, 0.0, 1.0);
|
2016-07-17 20:29:53 +02:00
|
|
|
|
|
|
|
vec4 p = vec4(pos.xy, 0.0, 1.0);
|
|
|
|
vec3 unprojected = (invP * p).xyz;
|
|
|
|
vecnormal = mat3(transpV) * unprojected;
|
2016-10-17 17:39:40 +02:00
|
|
|
|
2016-05-05 19:50:03 +02:00
|
|
|
// NDC (at the back of cube)
|
|
|
|
vec4 v = vec4(pos.x, pos.y, 1.0, 1.0);
|
|
|
|
v = vec4(invVP * v);
|
|
|
|
v.xyz /= v.w;
|
|
|
|
viewRay = v.xyz - eye;
|
|
|
|
}
|