|
|
|
|
|
|
|
|
|
|
// Various set of material use in render loop
|
|
|
|
readonly Material m_DebugViewMaterialGBuffer; |
|
|
|
readonly Material m_CombineSubsurfaceScattering; |
|
|
|
readonly Material m_FilterSubsurfaceScattering; |
|
|
|
readonly Material m_FilterAndCombineSubsurfaceScattering; |
|
|
|
readonly Material m_DebugDisplayShadowMap; |
|
|
|
|
|
|
|
// Various buffer
|
|
|
|
|
|
|
|
|
|
|
m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugViewMaterialGBuffer"); |
|
|
|
|
|
|
|
m_CombineSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering"); |
|
|
|
m_FilterSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering"); |
|
|
|
m_FilterSubsurfaceScattering.SetFloat("_DstBlend", (float)BlendMode.Zero); |
|
|
|
m_FilterSubsurfaceScattering.SetFloat("_FilterHorizontal", 0); |
|
|
|
|
|
|
|
m_FilterAndCombineSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering"); |
|
|
|
m_FilterAndCombineSubsurfaceScattering.SetFloat("_DstBlend", (float)BlendMode.One); |
|
|
|
m_FilterAndCombineSubsurfaceScattering.SetFloat("_FilterHorizontal", 1); |
|
|
|
|
|
|
|
m_DebugDisplayShadowMap = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugDisplayShadowMap"); |
|
|
|
|
|
|
|
m_ShadowPass = new ShadowRenderPass(owner.shadowSettings); |
|
|
|
|
|
|
|
|
|
|
// Assume that the height of the projection window is 2 meters.
|
|
|
|
float distanceToProjectionWindow = 1.0f / Mathf.Tan(0.5f * Mathf.Deg2Rad * hdCamera.camera.fieldOfView); |
|
|
|
m_CombineSubsurfaceScattering.SetFloat("_DistToProjWindow", distanceToProjectionWindow); |
|
|
|
m_CombineSubsurfaceScattering.SetFloat("_BilateralScale", 0.05f * sssParameters.bilateralScale); |
|
|
|
|
|
|
|
// Upload the kernel data.
|
|
|
|
Vector4[] kernelData = new Vector4[SubsurfaceScatteringParameters.maxNumProfiles * SubsurfaceScatteringProfile.numSamples]; |
|
|
|
|
|
|
kernelData[n * j + i] = sssParameters.profiles[j].filterKernel[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
m_CombineSubsurfaceScattering.SetVectorArray("_FilterKernels", kernelData); |
|
|
|
|
|
|
|
MaterialPropertyBlock properties = new MaterialPropertyBlock(); |
|
|
|
|
|
|
|
|
|
|
properties.SetFloat("_DstBlend", (float)BlendMode.Zero); // TODO: this doesn't work for some reason...
|
|
|
|
properties.SetFloat("_FilterHorizontal", 0); |
|
|
|
m_FilterSubsurfaceScattering.SetFloat("_DistToProjWindow", distanceToProjectionWindow); |
|
|
|
m_FilterSubsurfaceScattering.SetFloat("_BilateralScale", 0.05f * sssParameters.bilateralScale); |
|
|
|
m_FilterSubsurfaceScattering.SetVectorArray("_FilterKernels", kernelData); |
|
|
|
Utilities.DrawFullscreen(cmd, m_CombineSubsurfaceScattering, hdCamera, |
|
|
|
Utilities.DrawFullscreen(cmd, m_FilterSubsurfaceScattering, hdCamera, |
|
|
|
properties.SetFloat("_DstBlend", (float)BlendMode.One); // TODO: this doesn't work for some reason...
|
|
|
|
properties.SetFloat("_FilterHorizontal", 1); |
|
|
|
m_FilterAndCombineSubsurfaceScattering.SetFloat("_DistToProjWindow", distanceToProjectionWindow); |
|
|
|
m_FilterAndCombineSubsurfaceScattering.SetFloat("_BilateralScale", 0.05f * sssParameters.bilateralScale); |
|
|
|
m_FilterAndCombineSubsurfaceScattering.SetVectorArray("_FilterKernels", kernelData); |
|
|
|
Utilities.DrawFullscreen(cmd, m_CombineSubsurfaceScattering, hdCamera, |
|
|
|
Utilities.DrawFullscreen(cmd, m_FilterAndCombineSubsurfaceScattering, hdCamera, |
|
|
|
m_CameraColorBufferRT, m_CameraStencilBufferRT, properties); |
|
|
|
|
|
|
|
context.ExecuteCommandBuffer(cmd); |
|
|
|