Skip to content

Commit

Permalink
Fixes for water + lightmap
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Jul 1, 2023
1 parent 98b0458 commit f843722
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
10 changes: 8 additions & 2 deletions data/base/shaders/terrain_water_classic.frag
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ out vec4 FragColor;
#define FragColor gl_FragColor
#endif

vec3 blendAddEffectLighting(vec3 a, vec3 b) {
return min(a + b, vec3(1.0));
}

vec4 main_legacy()
{
vec4 decal = texture(tex2, uv2, WZ_MIP_LOAD_BIAS);
vec4 light = texture(lightmap_tex, uvLightmap, 0.f);
return light * decal;
vec4 lightmap_vec4 = texture(lightmap_tex, uvLightmap, 0.f);
vec4 color = decal * vec4(vec3(lightmap_vec4.a), 1.f); // ... * tile brightness / ambient occlusion (stored in lightmap.a);
color.rgb = blendAddEffectLighting(color.rgb, (lightmap_vec4.rgb / 2.f)); // additive color (from environmental point lights / effects)
return color;
}

void main()
Expand Down
10 changes: 8 additions & 2 deletions data/base/shaders/vk/terrain_water_classic.frag
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ layout(location = 5) in float depth;

layout(location = 0) out vec4 FragColor;

vec3 blendAddEffectLighting(vec3 a, vec3 b) {
return min(a + b, vec3(1.0));
}

vec4 main_classic()
{
vec4 decal = texture(tex2, uv2, WZ_MIP_LOAD_BIAS);
vec4 light = texture(lightmap_tex, uvLightmap, 0.f);
return light * decal;
vec4 lightmap_vec4 = texture(lightmap_tex, uvLightmap, 0.f);
vec4 color = decal * vec4(vec3(lightmap_vec4.a), 1.f); // ... * tile brightness / ambient occlusion (stored in lightmap.a);
color.rgb = blendAddEffectLighting(color.rgb, (lightmap_vec4.rgb / 2.f)); // additive color (from environmental point lights / effects)
return color;
}

void main()
Expand Down
10 changes: 8 additions & 2 deletions data/base/shaders/vk/water.frag
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ vec4 main_medium()
return fragColor;
}

vec3 blendAddEffectLighting(vec3 a, vec3 b) {
return min(a + b, vec3(1.0));
}

vec4 main_bumpMapping()
{
vec2 uv1 = uv1_uv2.xy;
Expand All @@ -75,8 +79,10 @@ vec4 main_bumpMapping()

vec4 fragColor = (texture(tex1, uv1, WZ_MIP_LOAD_BIAS)+texture(tex2, uv2, WZ_MIP_LOAD_BIAS)) * (gloss+vec4(0.08,0.13,0.15,1.0));
fragColor = fragColor*(ambientLight+diffuseLight*lambertTerm) + specularLight*(1.0-gloss)*gaussianTerm*vec4(1.0,0.843,0.686,1.0);
vec4 light = texture(lightmap_tex, uvLightmap, 0.f);
return light * fragColor;
vec4 lightmap_vec4 = texture(lightmap_tex, uvLightmap, 0.f);
vec4 color = fragColor * vec4(vec3(lightmap_vec4.a), 1.f); // ... * tile brightness / ambient occlusion (stored in lightmap.a);
color.rgb = blendAddEffectLighting(color.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects)
return color;
}

void main()
Expand Down
10 changes: 8 additions & 2 deletions data/base/shaders/water.frag
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ vec4 main_medium()
return fragColor;
}

vec3 blendAddEffectLighting(vec3 a, vec3 b) {
return min(a + b, vec3(1.0));
}

vec4 main_bumpMapping()
{
vec2 uv1 = uv1_uv2.xy;
Expand Down Expand Up @@ -86,8 +90,10 @@ vec4 main_bumpMapping()

vec4 fragColor = (texture(tex1, uv1, WZ_MIP_LOAD_BIAS)+texture(tex2, uv2, WZ_MIP_LOAD_BIAS)) * (gloss+vec4(0.08,0.13,0.15,1.0));
fragColor = fragColor*(ambientLight+diffuseLight*lambertTerm) + specularLight*(1.0-gloss)*gaussianTerm*vec4(1.0,0.843,0.686,1.0);
vec4 light = texture(lightmap_tex, uvLightmap, 0.f);
return light * fragColor;
vec4 lightmap_vec4 = texture(lightmap_tex, uvLightmap, 0.f);
vec4 color = fragColor * vec4(vec3(lightmap_vec4.a), 1.f); // ... * tile brightness / ambient occlusion (stored in lightmap.a);
color.rgb = blendAddEffectLighting(color.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects)
return color;
}

void main()
Expand Down

0 comments on commit f843722

Please sign in to comment.