您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
16 行
512 B
16 行
512 B
half ComputeGlobalFogFactor(float3 wPos)
|
|
{
|
|
half cHeightFalloff = 0.02;
|
|
half cVolFogHeightDensityAtViewer = exp( -cHeightFalloff * cViewPos.z );
|
|
half3 cameraToWorldPos = GetCameraPositionWS() - wPos;
|
|
half fogInt = length( cameraToWorldPos ) * cVolFogHeightDensityAtViewer;
|
|
|
|
const float cSlopeThreshold = 0.01;
|
|
if( abs( cameraToWorldPos.z ) > cSlopeThreshold )
|
|
{
|
|
float t = cHeightFalloff * cameraToWorldPos.z;
|
|
fogInt *= ( 1.0 - exp( -t ) ) / t;
|
|
}
|
|
|
|
return exp( -unity_FogParams.x * fogInt );
|
|
}
|