mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Debranch fog calculations
This commit is contained in:
parent
15aee1c5b0
commit
d96bf4ba8c
1 changed files with 16 additions and 17 deletions
|
@ -309,14 +309,13 @@ float DoFogBulbForSky(float3 pos, ShaderFogBulb bulb)
|
|||
}
|
||||
|
||||
float DoDistanceFogForVertex(float3 pos)
|
||||
{
|
||||
float fog = 0.0f;
|
||||
|
||||
if (FogMaxDistance > 0.0f)
|
||||
{
|
||||
float d = length(CamPositionWS.xyz - pos);
|
||||
fog = clamp((d - FogMinDistance * 1024) / (FogMaxDistance * 1024 - FogMinDistance * 1024), 0, 1);
|
||||
}
|
||||
float fogRange = FogMaxDistance * 1024 - FogMinDistance * 1024;
|
||||
|
||||
float fogEnabled = step(0.0f, FogMaxDistance);
|
||||
float fogFactor = (d - FogMinDistance * 1024) / fogRange;
|
||||
float fog = saturate(fogFactor) * fogEnabled;
|
||||
|
||||
return fog;
|
||||
}
|
||||
|
@ -328,12 +327,12 @@ float4 DoFogBulbsForVertex(float3 pos)
|
|||
for (int i = 0; i < NumFogBulbs; i++)
|
||||
{
|
||||
float fogFactor = DoFogBulb(pos, FogBulbs[i]);
|
||||
fog.xyz += FogBulbs[i].Color.xyz * fogFactor;
|
||||
float3 fogColor = FogBulbs[i].Color.xyz * fogFactor;
|
||||
|
||||
fog.xyz += fogColor;
|
||||
fog.w += fogFactor;
|
||||
if (fog.w >= 1.0f)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
fog.w = saturate(fog.w);
|
||||
}
|
||||
|
||||
return fog;
|
||||
|
@ -346,12 +345,12 @@ float4 DoFogBulbsForSky(float3 pos)
|
|||
for (int i = 0; i < NumFogBulbs; i++)
|
||||
{
|
||||
float fogFactor = DoFogBulbForSky(pos, FogBulbs[i]);
|
||||
fog.xyz += FogBulbs[i].Color.xyz * fogFactor;
|
||||
float3 fogColor = FogBulbs[i].Color.xyz * fogFactor;
|
||||
|
||||
fog.xyz += fogColor;
|
||||
fog.w += fogFactor;
|
||||
if (fog.w >= 1.0f)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
fog.w = saturate(fog.w);
|
||||
}
|
||||
|
||||
return fog;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue