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

27 lines
447 B
GLSL
Raw Normal View History

2023-02-08 14:40:15 +01:00
#version 450
uniform mat4 invP;
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, invP));
2024-08-15 20:29:14 +02:00
view_ray = vec3(v.xy / v.z, 1.0);
2023-02-08 14:40:15 +01:00
}