2021-04-10 09:14:16 +00:00
|
|
|
#version 330 core
|
|
|
|
|
|
|
|
layout(location = 0) in vec4 pos;
|
2023-04-07 06:17:37 +00:00
|
|
|
layout(location = 3) in vec4 multitexcoord0;
|
2021-04-10 09:14:16 +00:00
|
|
|
|
2023-04-07 06:17:37 +00:00
|
|
|
out vec3 cubemap_coord;
|
2021-04-10 09:14:16 +00:00
|
|
|
|
|
|
|
uniform mat4 osg_ModelViewProjectionMatrix;
|
|
|
|
uniform int fg_CubemapFace;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
2023-04-07 06:17:37 +00:00
|
|
|
vec2 texcoord = multitexcoord0.xy * 2.0 - 1.0;
|
|
|
|
|
2021-04-10 09:14:16 +00:00
|
|
|
// Map the quad texture coordinates to a direction vector to sample
|
|
|
|
// the cubemap. This assumes that we are using the weird left-handed
|
|
|
|
// orientations given by the OpenGL spec.
|
|
|
|
// See https://www.khronos.org/opengl/wiki/Cubemap_Texture#Upload_and_orientation
|
|
|
|
switch(fg_CubemapFace) {
|
|
|
|
case 0: // +X
|
2023-04-07 06:17:37 +00:00
|
|
|
cubemap_coord = vec3(1.0, -texcoord.y, -texcoord.x);
|
2021-04-10 09:14:16 +00:00
|
|
|
break;
|
|
|
|
case 1: // -X
|
2023-04-07 06:17:37 +00:00
|
|
|
cubemap_coord = vec3(-1.0, -texcoord.y, texcoord.x);
|
2021-04-10 09:14:16 +00:00
|
|
|
break;
|
|
|
|
case 2: // +Y
|
2023-04-07 06:17:37 +00:00
|
|
|
cubemap_coord = vec3(texcoord.x, 1.0, texcoord.y);
|
2021-04-10 09:14:16 +00:00
|
|
|
break;
|
|
|
|
case 3: // -Y
|
2023-04-07 06:17:37 +00:00
|
|
|
cubemap_coord = vec3(texcoord.x, -1.0, -texcoord.y);
|
2021-04-10 09:14:16 +00:00
|
|
|
break;
|
|
|
|
case 4: // +Z
|
2023-04-07 06:17:37 +00:00
|
|
|
cubemap_coord = vec3(texcoord.x, -texcoord.y, 1.0);
|
2021-04-10 09:14:16 +00:00
|
|
|
break;
|
|
|
|
case 5: // -Z
|
2023-04-07 06:17:37 +00:00
|
|
|
cubemap_coord = vec3(-texcoord.x, -texcoord.y, -1.0);
|
2021-04-10 09:14:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|