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
|
|
|
out vec3 ray_dir;
|
|
|
|
out vec3 ray_dir_view;
|
2021-04-10 09:14:16 +00:00
|
|
|
|
2021-07-28 07:40:04 +00:00
|
|
|
uniform mat4 osg_ModelViewMatrix;
|
2021-04-10 09:14:16 +00:00
|
|
|
uniform mat4 osg_ModelViewProjectionMatrix;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
2021-07-29 09:55:01 +00:00
|
|
|
// Get the camera height (0 being the ground)
|
2023-04-07 06:17:37 +00:00
|
|
|
vec4 ground_point = osg_ModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);
|
|
|
|
float altitude = length(ground_point);
|
2021-07-29 09:55:01 +00:00
|
|
|
// Compensate for the skydome being fixed on the ground
|
2023-04-07 06:17:37 +00:00
|
|
|
ray_dir = normalize(pos.xyz - vec3(0.0, 0.0, altitude));
|
|
|
|
ray_dir_view = (osg_ModelViewMatrix * vec4(ray_dir, 0.0)).xyz;
|
2021-04-10 09:14:16 +00:00
|
|
|
}
|