From 1d8824574e446b1d91ed3b1fd7e229e7bebfe951 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:49:12 -0400 Subject: [PATCH 1/2] Tweak high terrain shader blending and light calculations --- data/base/shaders/terrain_combined_high.frag | 7 +++---- data/base/shaders/vk/terrain_combined_high.frag | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/data/base/shaders/terrain_combined_high.frag b/data/base/shaders/terrain_combined_high.frag index 203cd548694..ba5549f73f7 100644 --- a/data/base/shaders/terrain_combined_high.frag +++ b/data/base/shaders/terrain_combined_high.frag @@ -115,7 +115,7 @@ void getGroundBM(int i, inout BumpData res) { } vec3 blendAddEffectLighting(vec3 a, vec3 b) { - return min(a + b, vec3(1.0)); + return a + b; } vec4 doBumpMapping(BumpData b, vec3 lightDir, vec3 halfVec) { @@ -134,11 +134,10 @@ vec4 doBumpMapping(BumpData b, vec3 lightDir, vec3 halfVec) { vec4 light = (ambientLight + visibility*diffuseLight*lambertTerm) * adjustedTileBrightness; light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects) - light.a = 1.f; vec4 light_spec = (visibility*specularLight*blinnTerm*lambertTerm) * adjustedTileBrightness; - light_spec.rgb = blendAddEffectLighting(light_spec.rgb, (lightmap_vec4.rgb / 2.f)); // additive color (from environmental point lights / effects) - light_spec *= b.gloss; + light_spec.rgb = blendAddEffectLighting(light_spec.rgb, (lightmap_vec4.rgb / 2.5f)); // additive color (from environmental point lights / effects) + light_spec *= (b.gloss * b.gloss); vec4 res = (b.color*light) + light_spec; diff --git a/data/base/shaders/vk/terrain_combined_high.frag b/data/base/shaders/vk/terrain_combined_high.frag index f133b4a197b..2a8c295d6cf 100644 --- a/data/base/shaders/vk/terrain_combined_high.frag +++ b/data/base/shaders/vk/terrain_combined_high.frag @@ -57,7 +57,7 @@ void getGroundBM(int i, inout BumpData res) { } vec3 blendAddEffectLighting(vec3 a, vec3 b) { - return min(a + b, vec3(1.0)); + return a + b; } vec4 doBumpMapping(BumpData b, vec3 lightDir, vec3 halfVec) { @@ -76,11 +76,10 @@ vec4 doBumpMapping(BumpData b, vec3 lightDir, vec3 halfVec) { vec4 light = (ambientLight + visibility*diffuseLight*lambertTerm) * adjustedTileBrightness; light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects) - light.a = 1.f; vec4 light_spec = (visibility*specularLight*blinnTerm*lambertTerm) * adjustedTileBrightness; - light_spec.rgb = blendAddEffectLighting(light_spec.rgb, (lightmap_vec4.rgb / 2.f)); // additive color (from environmental point lights / effects) - light_spec *= b.gloss; + light_spec.rgb = blendAddEffectLighting(light_spec.rgb, (lightmap_vec4.rgb / 2.5f)); // additive color (from environmental point lights / effects) + light_spec *= (b.gloss * b.gloss); vec4 res = (b.color*light) + light_spec; From 600809dcf4398228dd1d6dbfba86748375429efc Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Wed, 13 Sep 2023 13:23:48 -0400 Subject: [PATCH 2/2] Tweak high terrain shader shadow calculations --- data/base/shaders/terrain_combined_high.frag | 3 +-- data/base/shaders/vk/terrain_combined_high.frag | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/data/base/shaders/terrain_combined_high.frag b/data/base/shaders/terrain_combined_high.frag index ba5549f73f7..1bab7ef480e 100644 --- a/data/base/shaders/terrain_combined_high.frag +++ b/data/base/shaders/terrain_combined_high.frag @@ -127,12 +127,11 @@ vec4 doBumpMapping(BumpData b, vec3 lightDir, vec3 halfVec) { blinnTerm = lambertTerm != 0.0 ? blinnTerm : 0.0; blinnTerm = pow(blinnTerm, 16.f); float visibility = getShadowVisibility(); - visibility = visibility*visibility*visibility; vec4 lightmap_vec4 = texture(lightmap_tex, uvLightmap, 0.f); float adjustedTileBrightness = pow(lightmap_vec4.a, 2.f-lightmap_vec4.a); // ... * tile brightness / ambient occlusion (stored in lightmap.a) - vec4 light = (ambientLight + visibility*diffuseLight*lambertTerm) * adjustedTileBrightness; + vec4 light = (ambientLight*0.25f + visibility*ambientLight*0.75f + visibility*diffuseLight*lambertTerm) * adjustedTileBrightness; light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects) vec4 light_spec = (visibility*specularLight*blinnTerm*lambertTerm) * adjustedTileBrightness; diff --git a/data/base/shaders/vk/terrain_combined_high.frag b/data/base/shaders/vk/terrain_combined_high.frag index 2a8c295d6cf..950e031af3e 100644 --- a/data/base/shaders/vk/terrain_combined_high.frag +++ b/data/base/shaders/vk/terrain_combined_high.frag @@ -69,12 +69,11 @@ vec4 doBumpMapping(BumpData b, vec3 lightDir, vec3 halfVec) { blinnTerm = lambertTerm != 0.0 ? blinnTerm : 0.0; blinnTerm = pow(blinnTerm, 16.f); float visibility = getShadowVisibility(); - visibility = visibility*visibility*visibility; vec4 lightmap_vec4 = texture(lightmap_tex, frag.uvLightmap, 0.f); float adjustedTileBrightness = pow(lightmap_vec4.a, 2.f-lightmap_vec4.a); // ... * tile brightness / ambient occlusion (stored in lightmap.a) - vec4 light = (ambientLight + visibility*diffuseLight*lambertTerm) * adjustedTileBrightness; + vec4 light = (ambientLight*0.25f + visibility*ambientLight*0.75f + visibility*diffuseLight*lambertTerm) * adjustedTileBrightness; light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects) vec4 light_spec = (visibility*specularLight*blinnTerm*lambertTerm) * adjustedTileBrightness;