Fix fog rendering bug on d3d11/d3d10

This commit is contained in:
Wojtek Figat
2025-09-30 15:44:34 +02:00
parent 0848f1fa83
commit f09d6aa0eb
2 changed files with 10 additions and 1 deletions

View File

@@ -152,7 +152,13 @@ void PS_Forward(
#if USE_FOG && MATERIAL_SHADING_MODEL != SHADING_MODEL_UNLIT
// Calculate exponential height fog
float4 fog = GetExponentialHeightFog(ExponentialHeightFog, materialInput.WorldPosition, ViewPos, 0, gBuffer.ViewPos.z);
#if DIRECTX && FEATURE_LEVEL < FEATURE_LEVEL_SM6
// TODO: fix D3D11/D3D10 bug with incorrect distance
float fogSceneDistance = distance(materialInput.WorldPosition, ViewPos);
#else
float fogSceneDistance = gBuffer.ViewPos.z;
#endif
float4 fog = GetExponentialHeightFog(ExponentialHeightFog, materialInput.WorldPosition, ViewPos, 0, fogSceneDistance);
if (ExponentialHeightFog.VolumetricFogMaxDistance > 0)
{

View File

@@ -43,6 +43,9 @@ void ForwardShadingFeature::Bind(MaterialShader::BindParameters& params, Span<by
else
{
data.ExponentialHeightFog.FogMinOpacity = 1.0f;
data.ExponentialHeightFog.FogDensity = 0.0f;
data.ExponentialHeightFog.FogCutoffDistance = 0.1f;
data.ExponentialHeightFog.StartDistance = 0.0f;
data.ExponentialHeightFog.ApplyDirectionalInscattering = 0.0f;
}
params.GPUContext->BindSR(volumetricFogTextureRegisterIndex, volumetricFogTexture);