// Various set of material use in render loop
ComputeShader m_SubsurfaceScatteringCS { get { return m_Asset . renderPipelineResources . subsurfaceScatteringCS ; } }
int m_SubsurfaceScatteringKernel ;
Material m_CombineLightingPass ;
// Old SSS Model >>>
Material m_SssVerticalFilterPass ;
Material m_SssHorizontalFilterAndCombinePass ;
// Various buffer
readonly int m_CameraColorBuffer ;
readonly int m_CameraDiffuseIrradiance Buffer ;
readonly int m_CameraSssDiffuseLighting Buffer ;
// Old SSS Model >>>
readonly int m_CameraFilteringBuffer ;
// <<< Old SSS Model
// 'm_CameraColorBuffer' does not contain diffuse lighting of SSS materials until the SSS pass.
// It is stored within 'm_CameraSubsurfaceBufferRT'.
// 'm_CameraColorBuffer' does not contain diffuse lighting of SSS materials until the SSS pass. It is stored within 'm_CameraSssDiffuseLightingBuffer'.
readonly RenderTargetIdentifier m_CameraDiffuseIrradianceBufferRT ;
readonly RenderTargetIdentifier m_CameraSssDiffuseLightingBufferRT ;
// Old SSS Model >>>
readonly RenderTargetIdentifier m_CameraFilteringBufferRT ;
// <<< Old SSS Model
// whereas it work. Don't know what is hapening, DebugDisplay use the same code and name is correct there.
// Debug.Assert(m_DeferredMaterial != null);
m_CameraColorBuffer = HDShaderIDs . _CameraColorTexture ;
m_CameraColorBufferRT = new RenderTargetIdentifier ( m_CameraColorBuffer ) ;
m_CameraDiffuseIrradianceBuffer = HDShaderIDs . _CameraDiffuseIrradianceTexture ;
m_CameraDiffuseIrradianceBufferRT = new RenderTargetIdentifier ( m_CameraDiffuseIrradianceBuffer ) ;
m_CameraColorBuffer = HDShaderIDs . _CameraColorTexture ;
m_CameraColorBufferRT = new RenderTargetIdentifier ( m_CameraColorBuffer ) ;
m_CameraSssDiffuseLightingBuffer = HDShaderIDs . _CameraSssDiffuseLightingBuffer ;
m_CameraSssDiffuseLightingBufferRT = new RenderTargetIdentifier ( m_CameraSssDiffuseLightingBuffer ) ;
m_CameraFilteringBuffer = HDShaderIDs . _CameraFilteringBuffer ;
m_CameraFilteringBufferRT = new RenderTargetIdentifier ( m_CameraFilteringBuffer ) ;
// Old SSS Model >>>
m_CameraFilteringBuffer = HDShaderIDs . _CameraFilteringBuffer ;
m_CameraFilteringBufferRT = new RenderTargetIdentifier ( m_CameraFilteringBuffer ) ;
// <<< Old SSS Model
m_CopyStencilForSplitLighting = Utilities . CreateEngineMaterial ( "Hidden/HDRenderPipeline/CopyStencilBuffer" ) ;
m_CopyStencilForSplitLighting . EnableKeyword ( "EXPORT_HTILE" ) ;
public void CreateSssMaterials ( bool useDisneySSS )
{
m_SubsurfaceScatteringKernel = m_SubsurfaceScatteringCS . FindKernel ( "SubsurfaceScattering" ) ;
Utilities . Destroy ( m_CombineLightingPass ) ;
m_CombineLightingPass = Utilities . CreateEngineMaterial ( "Hidden/HDRenderPipeline/CombineLighting" ) ;
// Old SSS Model >>>
Utilities . Destroy ( m_SssVerticalFilterPass ) ;
return ;
}
RenderTargetIdentifier [ ] colorRTs = { m_CameraColorBufferRT , m_CameraDiffuseIrradiance BufferRT } ;
RenderTargetIdentifier [ ] colorRTs = { m_CameraColorBufferRT , m_CameraSssDiffuseLighting BufferRT } ;
// Output split lighting for materials asking for it (via stencil buffer)
// Output split lighting for materials asking for it (masked in the stencil buffer)
m_LightLoop . RenderDeferredLighting ( hdCamera , cmd , m_DebugDisplaySettings , colorRTs , m_CameraDepthStencilBufferRT , depthTexture , true ) ;
}
cmd . SetComputeVectorArrayParam ( m_SubsurfaceScatteringCS , HDShaderIDs . _FilterKernels , sssParameters . filterKernels ) ;
cmd . SetComputeVectorArrayParam ( m_SubsurfaceScatteringCS , HDShaderIDs . _ShapeParams , sssParameters . shapeParams ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture0 , m_gbufferManager . GetGBuffers ( ) [ 0 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture1 , m_gbufferManager . GetGBuffers ( ) [ 1 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture2 , m_gbufferManager . GetGBuffers ( ) [ 2 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture3 , m_gbufferManager . GetGBuffers ( ) [ 3 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _DepthTexture , GetDepthTexture ( ) ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _StencilTexture , GetStencilTexture ( ) ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _HTile , GetHTile ( ) ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _IrradianceSource , m_CameraDiffuseIrradianceBufferRT ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _CameraColorTexture , m_CameraColorBufferRT ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture0 , m_gbufferManager . GetGBuffers ( ) [ 0 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture1 , m_gbufferManager . GetGBuffers ( ) [ 1 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture2 , m_gbufferManager . GetGBuffers ( ) [ 2 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture3 , m_gbufferManager . GetGBuffers ( ) [ 3 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _DepthTexture , GetDepthTexture ( ) ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _StencilTexture , GetStencilTexture ( ) ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _HTile , GetHTile ( ) ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _IrradianceSource , m_CameraSssDiffuseLightingBufferRT ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _CameraColorTexture , m_CameraColorBufferRT ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _CameraFilteringBuffer , m_CameraFilteringBufferRT ) ;
// Perform the SSS filtering pass which fills 'm_CameraFilteringBufferRT'.
cmd . SetGlobalTexture ( HDShaderIDs . _IrradianceSource , m_CameraFilteringBufferRT ) ; // Cannot set a RT on a material
// Combine diffuse and specular lighting into 'm_CameraColorBufferRT'.
Utilities . DrawFullScreen ( cmd , m_CombineLightingPass , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
// Perform the vertical SSS filtering pass.
cmd . SetGlobalTexture ( HDShaderIDs . _IrradianceSource , m_CameraDiffuseIrradianceBufferRT ) ; // Cannot set a RT on a material
cmd . SetGlobalTexture ( HDShaderIDs . _IrradianceSource , m_CameraSssDiffuseLightingBufferRT ) ; // Cannot set a RT on a material
// Perform the vertical SSS filtering pass which fills 'm_CameraFilteringBufferRT'.
// Perform the horizontal SSS filtering pass, and combine diffuse and specular lighting.
// Perform the horizontal SSS filtering pass, and combine diffuse and specular lighting into 'm_CameraColorBufferRT'.
Utilities . DrawFullScreen ( cmd , m_SssHorizontalFilterAndCombinePass , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
}
}
int w = camera . pixelWidth ;
int h = camera . pixelHeight ;
cmd . GetTemporaryRT ( m_CameraColorBuffer , w , h , 0 , FilterMode . Point , RenderTextureFormat . ARGBHalf , RenderTextureReadWrite . Linear , 1 , true ) ; // Enable UAV
cmd . GetTemporaryRT ( m_CameraDiffuseIrradianceBuffer , w , h , 0 , FilterMode . Point , RenderTextureFormat . RGB111110Float , RenderTextureReadWrite . Linear , 1 , true ) ; // Enable UAV
// Old SSS Model >>>
cmd . GetTemporaryRT ( m_CameraFilteringBuffer , w , h , 0 , FilterMode . Point , RenderTextureFormat . RGB111110Float , RenderTextureReadWrite . Linear , 1 , true ) ; // Enable UAV
// <<< Old SSS Model
cmd . GetTemporaryRT ( m_CameraColorBuffer , w , h , 0 , FilterMode . Point , RenderTextureFormat . ARGBHalf , RenderTextureReadWrite . Linear , 1 , true ) ; // Enable UAV
cmd . GetTemporaryRT ( m_CameraSssDiffuseLightingBuffer , w , h , 0 , FilterMode . Point , RenderTextureFormat . RGB111110Float , RenderTextureReadWrite . Linear , 1 , true ) ; // Enable UAV
cmd . GetTemporaryRT ( m_CameraFilteringBuffer , w , h , 0 , FilterMode . Point , RenderTextureFormat . RGB111110Float , RenderTextureReadWrite . Linear , 1 , true ) ; // Enable UAV
if ( ! m_Asset . renderingSettings . ShouldUseForwardRenderingOnly ( ) )
{
// Clear the diffuse SSS lighting target
using ( new Utilities . ProfilingSample ( "Clear SSS diffuse target" , cmd ) )
{
Utilities . SetRenderTarget ( cmd , m_CameraDiffuseIrradiance BufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
Utilities . SetRenderTarget ( cmd , m_CameraSssDiffuseLighting BufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
}
// Old SSS Model >>>