@@ -504,12 +504,12 @@ float GeometrySmith(float3 n, float nDotV, float3 l, float roughness)
504504 return gs1 * gs2;
505505}
506506
507- float3 PBR (VS_OUTPUT inV, float4 position, float3 albedo, float3 n, float roughness, float waterDepth) {
507+ float3 PBR (VS_OUTPUT inV, float3 albedo, float3 n, float roughness, float waterDepth) {
508508 // See https://blog.selfshadow.com/publications/s2013-shading-course/
509509
510510 float shadow = 1 ;
511511 if (ShadowsEnabled == 1 ) {
512- float terrainShadow = tex2D (UpperAlbedoSampler, position.xy ).w; // 1 where sun is, 0 where shadow is
512+ float terrainShadow = tex2D (UpperAlbedoSampler, TerrainScale * inV.mTexWT ).w; // 1 where sun is, 0 where shadow is
513513 shadow = tex2D (ShadowSampler, inV.mShadow.xy).g; // 1 where sun is, 0 where shadow is
514514 shadow *= terrainShadow;
515515 }
@@ -1352,7 +1352,7 @@ float4 DecalsPS( VS_OUTPUT inV, uniform bool inShadows) : COLOR
13521352 float3 color;
13531353 // We want the decals to behave consistently with the rest of the ground
13541354 if (ShaderUsesPbrRendering ()) {
1355- color = PBR (inV, TerrainScale * inV.mTexWT, decalAlbedo.rgb, normal, 1 -decalSpec.r, waterDepth);
1355+ color = PBR (inV, decalAlbedo.rgb, normal, 1 -decalSpec.r, waterDepth);
13561356 } else {
13571357 color = CalculateLighting (normal, inV.mTexWT.xyz, decalAlbedo.xyz, decalSpec.r, waterDepth, inV.mShadow, inShadows).xyz;
13581358 }
@@ -2037,7 +2037,7 @@ float4 TerrainPBRAlbedoPS ( VS_OUTPUT inV) : COLOR
20372037 float roughness = saturate (albedo.a * mask1.w * 2 + 0.01 );
20382038
20392039 float waterDepth = tex2D (UpperAlbedoSampler, position.xy).b;
2040- float3 color = PBR (inV, position, albedo, normal, roughness, waterDepth);
2040+ float3 color = PBR (inV, albedo, normal, roughness, waterDepth);
20412041 color = ApplyWaterColor (-1 * inV.mViewDirection, inV.mTexWT.z, waterDepth, color);
20422042
20432043 return float4 (color, 0.01f );
@@ -2631,7 +2631,7 @@ float4 Terrain101AlbedoPS ( VS_OUTPUT inV, uniform bool halfRange ) : COLOR
26312631 float roughness = saturate (albedo.a * mask1.w * 2 + 0.01 );
26322632
26332633 float waterDepth = tex2D (UpperAlbedoSampler, position.xy).b;
2634- float3 color = PBR (inV, position, albedo, normal, roughness, waterDepth);
2634+ float3 color = PBR (inV, albedo, normal, roughness, waterDepth);
26352635 color = ApplyWaterColor (-1 * inV.mViewDirection, inV.mTexWT.z, waterDepth, color);
26362636
26372637 return float4 (color, 0.01f );
@@ -2816,7 +2816,7 @@ float4 Terrain301AlbedoPS ( VS_OUTPUT inV, uniform bool halfRange ) : COLOR
28162816 float roughness = saturate (albedo.a * mask1.w * 2 + 0.01 );
28172817
28182818 float waterDepth = tex2D (UpperAlbedoSampler, position.xy).b;
2819- float3 color = PBR (inV, position, albedo, normal, roughness, waterDepth);
2819+ float3 color = PBR (inV, albedo, normal, roughness, waterDepth);
28202820 color = ApplyWaterColor (-1 * inV.mViewDirection, inV.mTexWT.z, waterDepth, color);
28212821
28222822 return float4 (color, 0.01f );
0 commit comments