Skip to content

Commit

Permalink
refactor: fix shader warnings
Browse files Browse the repository at this point in the history
Should have handled all X3206 implicit truncation warnings

part of #534
  • Loading branch information
alandtse committed Oct 16, 2024
1 parent f036f2b commit 6a47d21
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ float3 GetSamplingVector(uint3 ThreadID, in RWTexture2DArray<float4> OutputTextu
}

#if defined(REFLECTIONS)
color.rgb = lerp(color.rgb, Color::GammaToLinear(ReflectionsTexture.SampleLevel(LinearSampler, uv, 0)), saturate(mipLevel / 8.0));
color.rgb = lerp(color.rgb, Color::GammaToLinear(ReflectionsTexture.SampleLevel(LinearSampler, uv, 0).rgb), saturate(mipLevel / 8.0));
#else
color.rgb = lerp(color.rgb, color.rgb * Color::GammaToLinear(DefaultCubemap.SampleLevel(LinearSampler, uv, 0).x) * 2, saturate(mipLevel / 8.0));
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ float smoothbumpstep(float edge0, float edge1, float x)

position += positionCS.xyz;

color += ColorTexture.SampleLevel(LinearSampler, uv, 0);
color += ColorTexture.SampleLevel(LinearSampler, uv, 0).rgb;
weight++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace ExtendedMaterials
wsum += weights[i];
}
float invwsum = rcp(wsum);
[unroll] for (int i = 0; i < 6; i++)
[unroll] for (i = 0; i < 6; i++)
{
weights[i] *= invwsum;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ namespace ExtendedMaterials
total += pixelOffset[i];
}
float invtotal = rcp(total);
[unroll] for (int i = 0; i < 6; i++)
[unroll] for (i = 0; i < 6; i++)
{
pixelOffset[i] *= invtotal;
}
Expand Down Expand Up @@ -354,13 +354,13 @@ namespace ExtendedMaterials
float scale = max(params[0].HeightScale * input.LandBlendWeights1.x, max(params[1].HeightScale * input.LandBlendWeights1.y, max(params[2].HeightScale * input.LandBlendWeights1.z,
max(params[3].HeightScale * input.LandBlendWeights1.w, max(params[4].HeightScale * input.LandBlendWeights2.x, params[5].HeightScale * input.LandBlendWeights2.y)))));
rayDir *= scale;
sh = GetTerrainHeight(input, coords + rayDir * multipliers.x, mipLevel, params, quality, input.LandBlendWeights1, input.LandBlendWeights2, heights);
sh = GetTerrainHeight(input, coords + rayDir * multipliers.x, mipLevel, params, quality, input.LandBlendWeights1, input.LandBlendWeights2.xy, heights);
if (quality > 0.25)
sh.y = GetTerrainHeight(input, coords + rayDir * multipliers.y, mipLevel, params, quality, input.LandBlendWeights1, input.LandBlendWeights2, heights);
sh.y = GetTerrainHeight(input, coords + rayDir * multipliers.y, mipLevel, params, quality, input.LandBlendWeights1, input.LandBlendWeights2.xy, heights);
if (quality > 0.5)
sh.z = GetTerrainHeight(input, coords + rayDir * multipliers.z, mipLevel, params, quality, input.LandBlendWeights1, input.LandBlendWeights2, heights);
sh.z = GetTerrainHeight(input, coords + rayDir * multipliers.z, mipLevel, params, quality, input.LandBlendWeights1, input.LandBlendWeights2.xy, heights);
if (quality > 0.75)
sh.w = GetTerrainHeight(input, coords + rayDir * multipliers.w, mipLevel, params, quality, input.LandBlendWeights1, input.LandBlendWeights2, heights);
sh.w = GetTerrainHeight(input, coords + rayDir * multipliers.w, mipLevel, params, quality, input.LandBlendWeights1, input.LandBlendWeights2.xy, heights);
return 1.0 - saturate(dot(max(0, sh - sh0), 1.0) * shadowIntensity) * lerp(quality, 1.0, extendedMaterialSettings.ExtendShadows);
# else
sh = GetTerrainHeight(input, coords + rayDir * multipliers.x, mipLevel, params, quality, heights);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ namespace GrassCollision
float3 displacement = 0.0;

for (uint i = 0; i < numCollisions; i++) {
float dist = distance(collisionData[i].centre[eyeIndex], worldPosition);
float dist = distance(collisionData[i].centre[eyeIndex].xyz, worldPosition);
float power = 1.0 - saturate(dist / collisionData[i].centre[0].w);
float3 direction = worldPosition - collisionData[i].centre[eyeIndex];
float3 direction = worldPosition - collisionData[i].centre[eyeIndex].xyz;
float3 shift = power * direction;
displacement += shift;
displacement.z -= length(shift.xy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ float2x3 getKernelBasis(float3 D, float3 N, float roughness = 1.0, float anisoFa
uvSample = (floor(uvSample * OUT_FRAME_DIM) + 0.5) * RCP_OUT_FRAME_DIM; // Snap to the pixel centre

float depthSample = srcDepth.SampleLevel(samplerLinearClamp, uvSample * frameScale, 0);
float3 posSample = ScreenToViewPosition(screenPosSample, depthSample, eyeIndex);
float3 posSample = ScreenToViewPosition(screenPosSample.xy, depthSample, eyeIndex);

float4 normalRoughnessSample = srcNormalRoughness.SampleLevel(samplerLinearClamp, uvSample * frameScale, 0);
float3 normalSample = GBuffer::DecodeNormal(normalRoughnessSample.xy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void readHistory(
const float prev_depth = prev_geo.x;
// const float3 prev_normal = GBuffer::DecodeNormal(prev_geo.yz); // prev normal is already world
float3 prev_pos = ScreenToViewPosition(screen_pos, prev_depth, eyeIndex);
prev_pos = ViewToWorldPosition(prev_pos, PrevInvViewMat[eyeIndex]) + CameraPreviousPosAdjust[eyeIndex];
prev_pos = ViewToWorldPosition(prev_pos, PrevInvViewMat[eyeIndex]) + CameraPreviousPosAdjust[eyeIndex].xyz;

float3 delta_pos = curr_pos - prev_pos;
// float normal_prod = dot(curr_normal, prev_normal);
Expand Down Expand Up @@ -94,7 +94,7 @@ void readHistory(
// float3 curr_normal = GBuffer::DecodeNormal(srcCurrNormal[pixCoord]);
// curr_normal = ViewToWorldVector(curr_normal, CameraViewInverse[eyeIndex]);
float3 curr_pos = ScreenToViewPosition(screen_pos, curr_depth, eyeIndex);
curr_pos = ViewToWorldPosition(curr_pos, CameraViewInverse[eyeIndex]) + CameraPosAdjust[eyeIndex];
curr_pos = ViewToWorldPosition(curr_pos, CameraViewInverse[eyeIndex]) + CameraPosAdjust[eyeIndex].xyz;

float2 prev_px_coord = prev_uv * OUT_FRAME_DIM;
int2 prev_px_lu = floor(prev_px_coord - 0.5);
Expand Down
2 changes: 1 addition & 1 deletion features/Skylighting/Shaders/Skylighting/Skylighting.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace Skylighting
int3 offset = int3(i, j, k);
int3 cellID = cell000 + offset;

if (any(cellID < 0) || any(cellID >= ARRAY_DIM))
if (any(cellID < 0) || any((uint3)cellID >= ARRAY_DIM))
continue;

float3 cellCentreMS = cellID + 0.5 - ARRAY_DIM / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ float GetInterpolatedHeight(float2 pxCoord, bool isVertical)
uint2 dims;
TexHeight.GetDimensions(dims.x, dims.y);

int2 lerpPxCoordA = int2(pxCoord - .5 * float2(isVertical, !isVertical));
int2 lerpPxCoordB = int2(pxCoord + .5 * float2(isVertical, !isVertical));
int2 lerpPxCoordA = min(0, int2(pxCoord - .5 * float2(isVertical, !isVertical)));
int2 lerpPxCoordB = min(0, int2(pxCoord + .5 * float2(isVertical, !isVertical)));
float heightA = TexHeight[lerpPxCoordA];
float heightB = TexHeight[lerpPxCoordB];

Expand All @@ -31,7 +31,7 @@ float GetInterpolatedHeight(float2 pxCoord, bool isVertical)
bool inBoundA = all(lerpPxCoordA > 0);
bool inBoundB = all(lerpPxCoordB < dims);
if (inBoundA && inBoundB)
return lerp(heightA, heightB, frac(pxCoord - .5));
return lerp(heightA, heightB, frac(pxCoord.x - .5));
else if (!inBoundA)
return heightB;
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace WaterLighting
float causticsFade = 1.0 - saturate(causticsDistToWater / 1024.0);
causticsFade *= causticsFade;

float2 causticsUV = (worldPosition.xyz + CameraPosAdjust[0].xyz) * 0.005;
float2 causticsUV = (worldPosition.xy + CameraPosAdjust[0].xy) * 0.005;

float2 causticsUV1 = PanCausticsUV(causticsUV, 0.5 * 0.2, 1.0);
float2 causticsUV2 = PanCausticsUV(causticsUV, 1.0 * 0.2, -0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace WetnessEffects
float3 specularIrradiance = 1.0;
# else
float level = roughness * 7.0;
float3 specularIrradiance = Color::GammaToLinear(specularTexture.SampleLevel(SampColorSampler, R, level));
float3 specularIrradiance = Color::GammaToLinear(specularTexture.SampleLevel(SampColorSampler, R, level).rgb);
# endif
#else
float3 specularIrradiance = 1.0;
Expand Down
6 changes: 3 additions & 3 deletions package/Shaders/Common/PBR.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,22 @@ namespace PBR
// R
Mp = HairGaussian(B[0], ThetaH - Alpha[0]);
Np = 0.25 * cosHalfPhi;
Fp = GetFresnelFactorSchlick(specularColor, sqrt(saturate(0.5 + 0.5 * VdotL)));
Fp = GetFresnelFactorSchlick(specularColor, sqrt(saturate(0.5 + 0.5 * VdotL))).x;
S += (Mp * Np) * (Fp * lerp(1, backlit, saturate(-VdotL)));

// TT
Mp = HairGaussian(B[1], ThetaH - Alpha[1]);
a = (1.55f / hairIOR) * rcp(n_prime);
h = cosHalfPhi * (1 + a * (0.6 - 0.8 * cosPhi));
f = GetFresnelFactorSchlick(specularColor, cosThetaD * sqrt(saturate(1 - h * h)));
f = GetFresnelFactorSchlick(specularColor, cosThetaD * sqrt(saturate(1 - h * h))).x;
Fp = (1 - f) * (1 - f);
Tp = pow(surfaceProperties.BaseColor, 0.5 * sqrt(1 - (h * a) * (h * a)) / cosThetaD);
Np = exp(-3.65 * cosPhi - 3.98);
S += (Mp * Np) * (Fp * Tp) * backlit;

// TRT
Mp = HairGaussian(B[2], ThetaH - Alpha[2]);
f = GetFresnelFactorSchlick(specularColor, cosThetaD * 0.5f);
f = GetFresnelFactorSchlick(specularColor, cosThetaD * 0.5f).x;
Fp = (1 - f) * (1 - f) * f;
Tp = pow(surfaceProperties.BaseColor, 0.8 / cosThetaD);
Np = exp(17 * cosPhi - 16.78);
Expand Down
14 changes: 7 additions & 7 deletions package/Shaders/DistantTree.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -215,26 +215,26 @@ PS_OUTPUT main(PS_INPUT input)
float dirShadow = 1;

# if defined(SCREEN_SPACE_SHADOWS)
dirShadow = ScreenSpaceShadows::GetScreenSpaceShadow(input.Position, screenUV, screenNoise, viewPosition, eyeIndex);
dirShadow = ScreenSpaceShadows::GetScreenSpaceShadow(input.Position.xyz, screenUV, screenNoise, viewPosition, eyeIndex);
# endif

# if defined(TERRAIN_SHADOWS)
if (dirShadow > 0.0) {
float terrainShadow = TerrainShadows::GetTerrainShadow(input.WorldPosition.xyz + CameraPosAdjust[eyeIndex], length(input.WorldPosition.xyz), SampDiffuse);
float terrainShadow = TerrainShadows::GetTerrainShadow(input.WorldPosition.xyz + CameraPosAdjust[eyeIndex].xyz, length(input.WorldPosition.xyz), SampDiffuse);
dirShadow = min(dirShadow, terrainShadow);
}
# endif

# if defined(CLOUD_SHADOWS)
if (dirShadow > 0.0) {
dirShadow *= CloudShadows::GetCloudShadowMult(input.WorldPosition, SampDiffuse);
dirShadow *= CloudShadows::GetCloudShadowMult(input.WorldPosition.xyz, SampDiffuse);
}
# endif

float3 diffuseColor = DirLightColorShared.xyz * dirShadow;

float3 ddx = ddx_coarse(input.WorldPosition);
float3 ddy = ddy_coarse(input.WorldPosition);
float3 ddx = ddx_coarse(input.WorldPosition.xyz);
float3 ddy = ddy_coarse(input.WorldPosition.xyz);
float3 normal = normalize(cross(ddx, ddy));

# if !defined(SSGI)
Expand All @@ -253,8 +253,8 @@ PS_OUTPUT main(PS_INPUT input)
psout.Albedo = float4(baseColor.xyz, 1);
psout.Masks = float4(0, 0, 1, 0);
# else
float3 ddx = ddx_coarse(input.WorldPosition);
float3 ddy = ddy_coarse(input.WorldPosition);
float3 ddx = ddx_coarse(input.WorldPosition.xyz);
float3 ddy = ddy_coarse(input.WorldPosition.xyz);
float3 normal = normalize(cross(ddx, ddy));

float3 color = baseColor.xyz * (DiffuseColor.xyz + AmbientColor.xyz);
Expand Down
6 changes: 3 additions & 3 deletions package/Shaders/Effect.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct VS_OUTPUT
cbuffer VS_PerFrame : register(b12)
{
# if !defined(VR)
row_major float4x3 ScreenProj[1] : packoffset(c0);
row_major float4x4 ScreenProj[1] : packoffset(c0);
row_major float4x4 ViewProj[1] : packoffset(c8);
# if defined(SKINNED)
float3 BonesPivot[1] : packoffset(c40);
Expand All @@ -102,7 +102,7 @@ cbuffer VS_PerFrame : register(b12)
# endif // MOTIONVECTORS_NORMALS
# endif // SKINNED
# else
row_major float4x3 ScreenProj[2] : packoffset(c0);
row_major float4x4 ScreenProj[2] : packoffset(c0);
row_major float4x4 ViewProj[2] : packoffset(c16);
# if defined(SKINNED)
float3 BonesPivot[2] : packoffset(c80);
Expand Down Expand Up @@ -608,7 +608,7 @@ PS_OUTPUT main(PS_INPUT input)
float3 propertyColor = PropertyColor.xyz;

# if defined(LIGHTING)
propertyColor = GetLightingColor(input.MSPosition, input.WorldPosition, input.Position, eyeIndex);
propertyColor = GetLightingColor(input.MSPosition.xyz, input.WorldPosition.xyz, input.Position.xyzw, eyeIndex);

# if defined(LIGHT_LIMIT_FIX)
uint lightCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion package/Shaders/ISHDR.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ PS_OUTPUT main(PS_INPUT input)

float blendedLuminance = Color::RGBToLuminance(blendedColor);

float3 linearColor = Cinematic.w * lerp(lerp(blendedLuminance, float4(blendedColor, 1), Cinematic.x), blendedLuminance * Tint, Tint.w);
float3 linearColor = Cinematic.w * lerp(lerp(blendedLuminance, float4(blendedColor, 1), Cinematic.x), blendedLuminance * Tint, Tint.w).xyz;

// Contrast modified to fix crushed shadows
linearColor = pow(abs(linearColor) / avgValue.x, Cinematic.z) * avgValue.x * sign(linearColor);
Expand Down
2 changes: 1 addition & 1 deletion package/Shaders/ISSAOCameraZ.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PS_OUTPUT main(PS_INPUT input)
PS_OUTPUT psout;

float2 screenPosition = FrameBuffer::GetDynamicResolutionAdjustedScreenPosition(input.TexCoord);
float4 depth = DepthTex.Sample(DepthSampler, screenPosition).x;
float depth = DepthTex.Sample(DepthSampler, screenPosition).x;

psout.ClippedDepth = clamp(g_ClipInfos.x / (g_ClipInfos.y * depth + g_ClipInfos.z), 0, g_ClipInfos.w);

Expand Down
2 changes: 1 addition & 1 deletion package/Shaders/ISWaterDisplacement.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ PS_OUTPUT main(PS_INPUT input)
# elif defined(HEIGHTMAP_RAIN)
psout.Color = GetHeight(input, RainVars);
# elif defined(HEIGHTMAP_WADING)
psout.Color = GetHeight(input, WadingVars);
psout.Color = GetHeight(input, WadingVars.xyz);
# endif

return psout;
Expand Down
8 changes: 4 additions & 4 deletions package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ cbuffer VS_PerFrame : register(b12)
float3 PreviousBonesPivot[1] : packoffset(c41);
# endif // SKINNED
# else
row_major float4x4 ScreenProj[2] : packoffset(c0);
row_major float3x3 ScreenProj[2] : packoffset(c0);
row_major float4x4 ViewProj[2] : packoffset(c16);
# if defined(SKINNED)
float3 BonesPivot[2] : packoffset(c80);
Expand Down Expand Up @@ -1228,7 +1228,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
}
if (extendedMaterialSettings.EnableShadows && (parallaxShadowQuality > 0.0f || extendedMaterialSettings.ExtendShadows)) {
# if defined(TRUE_PBR)
sh0 = ExtendedMaterials::GetTerrainHeight(input, uv, mipLevels, displacementParams, parallaxShadowQuality, input.LandBlendWeights1, input.LandBlendWeights2, weights);
sh0 = ExtendedMaterials::GetTerrainHeight(input, uv, mipLevels, displacementParams, parallaxShadowQuality, input.LandBlendWeights1, input.LandBlendWeights2.xy, weights);
# else
sh0 = ExtendedMaterials::GetTerrainHeight(input, uv, mipLevels, displacementParams, parallaxShadowQuality, weights);
# endif
Expand Down Expand Up @@ -2231,7 +2231,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
CharacterLightParams.y * saturate(dot(float2(0.164398998, -0.986393988), modelNormal.yz));
float charLightColor = min(CharacterLightParams.w, max(0, CharacterLightParams.z * TexCharacterLightProjNoiseSampler.Sample(SampCharacterLightProjNoiseSampler, baseShadowUV).x));
# if defined(TRUE_PBR)
charLightColor = Color::GammaToLinear(charLightColor) / Color::LightPreMult;
charLightColor = Color::GammaToLinear(charLightColor).x / Color::LightPreMult;
# endif
diffuseColor += (charLightMul * charLightColor).xxx;
}
Expand Down Expand Up @@ -2506,7 +2506,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
{
pbrWeight = 1 - lodLandBlendFactor;

float3 litLodLandColor = vertexColor * lodLandColor * lodLandFadeFactor * lodLandDiffuseColor;
float3 litLodLandColor = vertexColor * lodLandColor.xyz * lodLandFadeFactor * lodLandDiffuseColor;
color.xyz = lerp(color.xyz, litLodLandColor, lodLandBlendFactor);

# if defined(DEFERRED)
Expand Down
6 changes: 3 additions & 3 deletions package/Shaders/RunGrass.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
# else
float4 specColor = TexNormalSampler.Sample(SampNormalSampler, input.TexCoord.xy);
# endif
float dirShadowColor = !InInterior ? TexShadowMaskSampler.Load(int3(input.HPosition.xy, 0)) : 1.0;
float dirShadowColor = !InInterior ? TexShadowMaskSampler.Load(int3(input.HPosition.xy, 0)).r : 1.0;

uint eyeIndex = Stereo::GetEyeIndexPS(input.HPosition, VPOSOffset);
psout.MotionVectors = GetSSMotionVector(input.WorldPosition, input.PreviousWorldPosition, eyeIndex);
Expand Down Expand Up @@ -513,7 +513,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
if (dirShadowColor > 0.0) {
if (dirLightAngle > 0.0) {
# if defined(SCREEN_SPACE_SHADOWS)
dirDetailShadow = ScreenSpaceShadows::GetScreenSpaceShadow(input.HPosition, screenUV, screenNoise, viewPosition, eyeIndex);
dirDetailShadow = ScreenSpaceShadows::GetScreenSpaceShadow(input.HPosition.xyz, screenUV, screenNoise, viewPosition, eyeIndex);
# endif // SCREEN_SPACE_SHADOWS
}

Expand Down Expand Up @@ -667,7 +667,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace
psout.Diffuse = float4(diffuseColor, 1);
}
# else
psout.Diffuse.xyz = float4(diffuseColor, 1);
psout.Diffuse.xyz = diffuseColor;
# endif

float3 normalVS = normalize(FrameBuffer::WorldToView(normal, false, eyeIndex));
Expand Down
6 changes: 3 additions & 3 deletions package/Shaders/Utility.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ float GetPoissonDiskFilteredShadowVisibility(float noise, float2x2 rotationMatri
sampleOffset *= 1.5;

# if defined(RENDER_SHADOWMASKDPB)
float2 sampleUV = sampleOffset + baseUV;
float2 sampleUV = sampleOffset + baseUV.xy;

baseUV.z += noise;

Expand Down Expand Up @@ -516,7 +516,7 @@ PS_OUTPUT main(PS_INPUT input)
TexStencilSampler.GetDimensions(0, stencilDimensions.x, stencilDimensions.y, stencilDimensions.z);
stencilValue = TexStencilSampler.Load(float3(stencilDimensions.xy * depthUv, 0)).x;
# endif
depthUv = Stereo::ConvertFromStereoUV(depthUv * DynamicResolutionParams2, eyeIndex);
depthUv = Stereo::ConvertFromStereoUV(depthUv * DynamicResolutionParams2.xy, eyeIndex);
float4 positionCS = float4(2 * float2(depthUv.x, -depthUv.y + 1) - 1, depth, 1);
float4 positionMS = mul(CameraViewProjInverse[eyeIndex], positionCS);
positionMS.xyz = positionMS.xyz / positionMS.w;
Expand Down Expand Up @@ -670,7 +670,7 @@ PS_OUTPUT main(PS_INPUT input)

shadowColor.xyzw = fadeFactor * shadowVisibility;
# elif defined(RENDER_SHADOWMASKDPB)
float3 positionLS = mul(transpose(ShadowMapProj[eyeIndex][0]), float4(positionMS.xyz, 1));
float3 positionLS = mul(transpose(ShadowMapProj[eyeIndex][0]), float4(positionMS.xyz, 1)).xyz;

bool lowerHalf = positionLS.z * 0.5 + 0.5 < 0;
float3 normalizedPositionLS = normalize(positionLS);
Expand Down
6 changes: 3 additions & 3 deletions package/Shaders/Water.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ float3 GetWaterSpecularColor(PS_INPUT input, float3 normal, float3 viewDirection
sh2 specularLobe = Skylighting::fauxSpecularLobeSH(normal, -viewDirection, 0.0);

float skylightingSpecular = shFuncProductIntegral(skylighting, specularLobe);
skylightingSpecular = lerp(1.0, skylightingSpecular, Skylighting::getFadeOutFactor(input.WPosition));
skylightingSpecular = lerp(1.0, skylightingSpecular, Skylighting::getFadeOutFactor(input.WPosition.xyz));
skylightingSpecular = Skylighting::mixSpecular(skylightingSettings, skylightingSpecular);

float3 specularIrradiance = 1;
Expand Down Expand Up @@ -605,7 +605,7 @@ float3 GetWaterSpecularColor(PS_INPUT input, float3 normal, float3 viewDirection
float4 ssrReflectionColorRaw = RawSSRReflectionTex.Sample(RawSSRReflectionSampler, ssrReflectionUvDR);

// calculate fog on reflection
float depth = DepthTex.Load(int3(ssrReflectionUvDR * BufferDim.xy, 0));
float depth = DepthTex.Load(int3(ssrReflectionUvDR * BufferDim.xy, 0)).r;
float fogDensity = depth == 0 ? 0.f : pow(saturate((-depth * FogParam.z + FogParam.z) / FogParam.w), FogNearColor.w);
float3 fogColor = lerp(FogNearColor.xyz, FogFarColor.xyz, fogDensity);

Expand Down Expand Up @@ -728,7 +728,7 @@ float3 GetWaterDiffuseColor(PS_INPUT input, float3 normal, float3 viewDirection,

sh2 skylightingSH = Skylighting::sample(skylightingSettings, SkylightingProbeArray, positionMSSkylight, float3(0, 0, 1));
float skylighting = shUnproject(skylightingSH, float3(0, 0, 1));
skylighting = lerp(1.0, skylighting, Skylighting::getFadeOutFactor(input.WPosition));
skylighting = lerp(1.0, skylighting, Skylighting::getFadeOutFactor(input.WPosition.xyz));

float3 refractionDiffuseColorSkylight = Skylighting::mixDiffuse(skylightingSettings, skylighting);
refractionDiffuseColorSkylight = Color::LinearToGamma(Color::GammaToLinear(refractionDiffuseColor) * refractionDiffuseColorSkylight);
Expand Down

0 comments on commit 6a47d21

Please sign in to comment.