Files
armorpaint/base/shaders/pass_viewray.vert.glsl
T

29 lines
472 B
GLSL
Raw Normal View History

2023-02-08 14:40:15 +01:00
#version 450
uniform mat4 invVP;
uniform vec3 eye;
in vec2 pos;
2024-08-15 20:29:14 +02:00
out vec2 tex_coord;
out vec3 view_ray;
2023-02-08 14:40:15 +01:00
void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
2024-08-15 20:29:14 +02:00
tex_coord = pos.xy * madd + madd;
2024-10-15 23:24:15 +02:00
#ifdef GLSL
#else
2024-08-15 20:29:14 +02:00
tex_coord.y = 1.0 - tex_coord.y;
2024-10-15 23:24:15 +02:00
#endif
2023-02-08 14:40:15 +01:00
gl_Position = vec4(pos.xy, 0.0, 1.0);
// NDC (at the back of cube)
vec4 v = vec4(pos.x, pos.y, 1.0, 1.0);
2024-10-02 23:17:50 +02:00
v = vec4(mul(v, invVP));
2023-02-08 14:40:15 +01:00
v.xyz /= v.w;
2024-08-15 20:29:14 +02:00
view_ray = v.xyz - eye;
2023-02-08 14:40:15 +01:00
}