1
0
Fork 0
fgdata/Shaders/HDR/skydome.vert
Fernando García Liñán a00f7ddfaf HDR: Fix Earth appearing to be "rounder" than normal
We have to compensate for the fact that the sky-view LUT contains the view from the camera, but the skydome remains fixed on the ground.
2021-07-29 11:55:01 +02:00

20 lines
595 B
GLSL

#version 330 core
layout(location = 0) in vec4 pos;
out vec3 vRayDir;
out vec3 vRayDirView;
uniform mat4 osg_ModelViewMatrix;
uniform mat4 osg_ModelViewProjectionMatrix;
void main()
{
gl_Position = osg_ModelViewProjectionMatrix * pos;
// Get the camera height (0 being the ground)
vec4 groundPoint = osg_ModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);
float altitude = length(groundPoint);
// Compensate for the skydome being fixed on the ground
vRayDir = normalize(pos.xyz - vec3(0.0, 0.0, altitude));
vRayDirView = (osg_ModelViewMatrix * vec4(vRayDir, 0.0)).xyz;
}