优化体积渲染:添加 phase_function 和修正累积公式
新增功能: - 添加 phase_function()(返回 1.0) - 使用 Unity 的累积公式:Sint = (S - S * exp(-sigmaE * step)) / sigmaE - 添加 sigmaE 避免除零 与 Unity 版本的主要差异: - 缺少 volumetric_shadow 体积阴影 - 缺少 ambient_light 环境光 - 缺少 acc_density 累积限制 - 缺少 Gamma 校正
This commit is contained in:
@@ -85,6 +85,11 @@ bool get_hdda_hit(inout pnanovdb_readaccessor_t acc, inout float tmin, float3 or
|
||||
return hit;
|
||||
}
|
||||
|
||||
float phase_function()
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
PSInput MainVS(VSInput input)
|
||||
{
|
||||
PSInput output;
|
||||
@@ -167,9 +172,12 @@ float4 MainPS(PSInput input) : SV_TARGET
|
||||
continue;
|
||||
}
|
||||
|
||||
float3 S = density * float3(1, 1, 1);
|
||||
color += transmittance * S * _StepSize;
|
||||
transmittance *= exp(-density * _StepSize);
|
||||
float sigmaS = density;
|
||||
float sigmaE = max(0.000001, sigmaS);
|
||||
float3 S = sigmaS * phase_function() * float3(1, 1, 1);
|
||||
float3 Sint = (S - S * exp(-sigmaE * _StepSize)) / sigmaE;
|
||||
color += transmittance * Sint;
|
||||
transmittance *= exp(-sigmaE * _StepSize);
|
||||
|
||||
tmin += _StepSize;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user