Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for water + lightmap #3296

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading