From 58f87151b083a5a85b83190ef803aace19aa90ac Mon Sep 17 00:00:00 2001 From: BlackYps <52536103+BlackYps@users.noreply.github.com> Date: Sat, 8 Feb 2025 15:16:19 +0100 Subject: [PATCH] Make Terrain000 use the water channel in the map info texture (#6648) --- changelog/snippets/graphics.6621.md | 1 + effects/terrain.fx | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) create mode 100644 changelog/snippets/graphics.6621.md diff --git a/changelog/snippets/graphics.6621.md b/changelog/snippets/graphics.6621.md new file mode 100644 index 0000000000..6797ae5c44 --- /dev/null +++ b/changelog/snippets/graphics.6621.md @@ -0,0 +1 @@ +- (#6621, #6648) Add new terrain shaders that allow better texturing of mesa-like terrain. Slight tweaks to other recently added terrain shaders. These changes have no immediate effects on existing maps, because virtually no maps use these shaders yet. \ No newline at end of file diff --git a/effects/terrain.fx b/effects/terrain.fx index 4924afa33d..1010b1d1d0 100644 --- a/effects/terrain.fx +++ b/effects/terrain.fx @@ -2097,7 +2097,7 @@ float4 TerrainPBRAlbedoPS ( VS_OUTPUT inV) : COLOR // | S6 | R G B specularity | X Y Z unused | // | S7 | R G B specularity | X Y Z unused | // ---- --- --- --- --- --- --- --- --- -// | U | normal.x normal.z unused shadow | +// | U | normal.x normal.z waterDepth shadow | // These shaders are similar to the usual TTerrainXP shader. They // are designed as a drop-in replacement that solely introduce the map-wide @@ -2182,6 +2182,7 @@ float4 Terrain000AlbedoPS ( VS_OUTPUT inV, uniform bool halfRange ) : COLOR // w = shadows float4 terrainInfo = tex2D(UpperAlbedoSampler, coordinates.xy); float terrainShadow = terrainInfo.w; + float waterDepth = terrainInfo.b; // disable shadows when game settings tell us to if (0 == ShadowsEnabled) { @@ -2221,17 +2222,13 @@ float4 Terrain000AlbedoPS ( VS_OUTPUT inV, uniform bool halfRange ) : COLOR float3 r = reflect(normalize(inV.mViewDirection), normal); float3 specular = pow(saturate(dot(r, SunDirection)),80) * albedo.aaa * SpecularColor.a * SpecularColor.rgb; - // compute lighting - float dotSunNormal = max(0, dot(SunDirection, normal)); + float dotSunNormal = dot(SunDirection, normal); - // combine everything float3 light = SunColor * saturate(dotSunNormal) * shadow + SunAmbience; light = LightingMultiplier * light + ShadowFillColor * (1 - light); albedo.rgb = light * (albedo.rgb + specular.rgb); - // compute water ramp intensity - float waterDepth = tex2Dproj(UtilitySamplerC, coordinates).g; - albedo.rgb = ApplyWaterColor(-1 * inV.mViewDirection, inV.mTexWT.z, waterDepth, albedo.rgb); + albedo.rgb = ApplyWaterColor(-inV.mViewDirection, inV.mTexWT.z, waterDepth, albedo.rgb); return float4(albedo.rgb, 0.01f); }