Skip to content

Commit

Permalink
Tweak high terrain shader shadow calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Sep 13, 2023
1 parent c2ed493 commit 7c01d27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions data/base/shaders/terrain_combined_high.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions data/base/shaders/vk/terrain_combined_high.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7c01d27

Please sign in to comment.