Skip to content

Commit

Permalink
Make Terrain000 use the water channel in the map info texture (#6648)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackYps authored Feb 8, 2025
1 parent 410dc04 commit 58f8715
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog/snippets/graphics.6621.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 4 additions & 7 deletions effects/terrain.fx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 58f8715

Please sign in to comment.