From 87248b46f3d38d9f4a3c5283b837105f478f14eb Mon Sep 17 00:00:00 2001 From: vlj Date: Sun, 20 Apr 2014 02:01:29 +0200 Subject: [PATCH] Tweak shadows CSM split. --- data/shaders/sunlightshadow.frag | 16 +++++++++++----- src/graphics/render.cpp | 6 +++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/data/shaders/sunlightshadow.frag b/data/shaders/sunlightshadow.frag index d970def0b..ff65e3f0c 100644 --- a/data/shaders/sunlightshadow.frag +++ b/data/shaders/sunlightshadow.frag @@ -100,20 +100,26 @@ void main() { } else if (xpos.z < 20.) factor = getShadowFactor(xpos.xyz, bias, 1); - else if (xpos.z < 30.) + else if (xpos.z < 21.) { float a = getShadowFactor(xpos.xyz, bias, 1), b = getShadowFactor(xpos.xyz, bias, 2); - factor = mix(a, b, (xpos.z - 20.) / 10.); + factor = mix(a, b, (xpos.z - 20.)); } else if (xpos.z < 50.) factor = getShadowFactor(xpos.xyz, bias, 2); - else if (xpos.z < 70.) + else if (xpos.z < 55.) { float a = getShadowFactor(xpos.xyz, bias, 2), b = getShadowFactor(xpos.xyz, bias, 3); - factor = mix(a, b, (xpos.z - 50.) / 20.); + factor = mix(a, b, (xpos.z - 50.) / 5.); + } + else if (xpos.z < 145.) + factor = getShadowFactor(xpos.xyz, bias, 3); + else if (xpos.z < 150.) + { + factor = mix(getShadowFactor(xpos.xyz, bias, 3), 1., (xpos.z - 145.) / 5.); } else - factor = getShadowFactor(xpos.xyz, bias, 3); + factor = 1.; Diff = vec4(factor * NdotL * col, 1.); Spec = vec4(factor * Specular, 1.); return; diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index e383c4562..34938f82d 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -559,9 +559,9 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, float FarValues[] = { 6., - 30., - 70., - oldfar, + 21., + 55., + 150., }; float NearValues[] = {