From a206b3cb51021c3769150a0ff2e98d1a9f4bff77 Mon Sep 17 00:00:00 2001 From: "Nikolai V. Chr" Date: Tue, 10 Oct 2017 17:58:32 +0200 Subject: [PATCH] Change to the up vector used in sky irradiance light in ALS shader. Models that are xml offset with pitch, heading or yaw should now be correct lighted. --- Shaders/model-ALS-ultra.frag | 3 ++- Shaders/road-ALS-ultra.frag | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Shaders/model-ALS-ultra.frag b/Shaders/model-ALS-ultra.frag index 8173466e3..286e7acb2 100644 --- a/Shaders/model-ALS-ultra.frag +++ b/Shaders/model-ALS-ultra.frag @@ -79,6 +79,7 @@ uniform float snowlevel; uniform float snow_thickness_factor; uniform float osg_SimulationTime; +uniform mat4 osg_ViewMatrix; uniform float landing_light1_offset; uniform float landing_light2_offset; @@ -155,7 +156,7 @@ void main (void) /// BEGIN geometry for light - vec3 up = (gl_ModelViewMatrix * vec4(0.0,0.0,1.0,0.0)).xyz; + vec3 up = (osg_ViewMatrix * vec4(0.0,0.0,1.0,0.0)).xyz; //vec4 worldPos3D = (osg_ViewMatrixInverse * vec4 (0.0,0.0,0.0, 1.0)); //worldPos3D.a = 0.0; //vec3 up = (osg_ViewMatrix * worldPos3D).xyz; diff --git a/Shaders/road-ALS-ultra.frag b/Shaders/road-ALS-ultra.frag index ebd61bb2f..9255196fd 100644 --- a/Shaders/road-ALS-ultra.frag +++ b/Shaders/road-ALS-ultra.frag @@ -76,6 +76,7 @@ uniform float snowlevel; uniform float snow_thickness_factor; uniform float osg_SimulationTime; +uniform mat4 osg_ViewMatrix; uniform float landing_light1_offset; uniform float landing_light2_offset; @@ -221,7 +222,7 @@ void main (void) /// BEGIN geometry for light - vec3 up = (gl_ModelViewMatrix * vec4(0.0,0.0,1.0,0.0)).xyz; + vec3 up = (osg_ViewMatrix * vec4(0.0,0.0,1.0,0.0)).xyz; vec3 nVertVec = normalize(vertVec);