浏览代码

Add preliminary ambient probe support

/main
Evgenii Golubev 7 年前
当前提交
03f7d07a
共有 4 个文件被更改,包括 19 次插入1 次删除
  1. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  2. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/Resources/VolumetricLighting.compute
  3. 13
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _Source4 = Shader.PropertyToID("_Source4");
public static readonly int _Result1 = Shader.PropertyToID("_Result1");
public static readonly int _AmbientProbe = Shader.PropertyToID("_AmbientProbe");
public static readonly int _GlobalFog_Extinction = Shader.PropertyToID("_GlobalFog_Extinction");
public static readonly int _GlobalFog_Scattering = Shader.PropertyToID("_GlobalFog_Scattering");
public static readonly int _GlobalFog_Asymmetry = Shader.PropertyToID("_GlobalFog_Asymmetry");

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/Resources/VolumetricLighting.compute


float phase = IsotropicPhaseFunction();
#endif
// Sample the light probe.
float3 probeRadiance = _AmbientProbe.rgb * (4 * PI) * TransmittanceIntegralHomogeneousMedium(extinction, dt);
totalRadiance += (transmittance * phase) * scattering * blendedRadiance;
totalRadiance += (transmittance * phase) * scattering * (blendedRadiance + probeRadiance);
// Compute the optical depth up to the center of the interval.
opticalDepth += 0.5 * extinction * dt;

13
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs


return depthParams;
}
Vector4 GetAmbientLightProbe()
{
Vector4 probe = new Vector4();
SphericalHarmonicsL2 probeSH = RenderSettings.ambientProbe;
probe.x = probeSH[0, 0];
probe.y = probeSH[1, 0];
probe.z = probeSH[2, 0];
return probe;
}
public void PushGlobalParams(HDCamera camera, CommandBuffer cmd)
{
if (preset == VolumetricLightingPreset.Off) return;

cmd.SetGlobalVector( HDShaderIDs._VBufferDepthEncodingParams, ComputeLogarithmicDepthEncodingParams(m_VBufferNearPlane, m_VBufferFarPlane, k_LogScale));
cmd.SetGlobalVector( HDShaderIDs._VBufferDepthDecodingParams, ComputeLogarithmicDepthDecodingParams(m_VBufferNearPlane, m_VBufferFarPlane, k_LogScale));
cmd.SetGlobalTexture(HDShaderIDs._VBufferLighting, vBuffer.GetLightingIntegralBuffer());
cmd.SetGlobalVector( HDShaderIDs._AmbientProbe, GetAmbientLightProbe());
}
// Ref: https://en.wikipedia.org/wiki/Close-packing_of_equal_spheres

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl


float2 _TaaFrameRotation; // {x = sin(_TaaFrameIndex * PI/2), y = cos(_TaaFrameIndex * PI/2), z = unused}
uint _TaaFrameIndex; // [0, 7]
// Volumetric lighting.
float4 _AmbientProbe;
float _GlobalFog_Asymmetry;
float3 _GlobalFog_Scattering;
float _GlobalFog_Extinction;

正在加载...
取消
保存