Skip to content

Commit

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

Expand Down
7 changes: 3 additions & 4 deletions data/base/shaders/vk/terrain_combined_high.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;

Expand Down

0 comments on commit 1d88245

Please sign in to comment.