From a00f7ddfafb8e696a8c4ceee1fc6efcca20aa285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Li=C3=B1=C3=A1n?= Date: Thu, 29 Jul 2021 11:55:01 +0200 Subject: [PATCH] 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. --- Shaders/HDR/skydome.vert | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Shaders/HDR/skydome.vert b/Shaders/HDR/skydome.vert index a141fd672..179547975 100644 --- a/Shaders/HDR/skydome.vert +++ b/Shaders/HDR/skydome.vert @@ -11,6 +11,10 @@ uniform mat4 osg_ModelViewProjectionMatrix; void main() { gl_Position = osg_ModelViewProjectionMatrix * pos; - vRayDir = normalize(pos.xyz); + // 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; }