Material m_CopyStencilBuffer ;
// Various set of material use in render loop
Material m_FilterAndCombineSubsurfaceScattering ;
Material m_SssHorizontalFilterAndCombinePass ;
Material m_FilterSubsurfaceScattering ;
Material m_SssVerticalFilterPass ;
// <<< Old SSS Model
Material m_CameraMotionVectorsMaterial ;
// Various buffer
readonly int m_CameraColorBuffer ;
readonly int m_CameraSubsurfa ceBuffer ;
readonly int m_CameraDiffuseIrradian ceBuffer ;
// 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'.
readonly RenderTargetIdentifier m_CameraColorBufferRT ;
readonly RenderTargetIdentifier m_CameraSubsurfa ceBufferRT ;
readonly RenderTargetIdentifier m_CameraDiffuseIrradian ceBufferRT ;
// 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 = Shader . PropertyToID ( "_CameraColorTexture" ) ;
m_CameraSubsurfaceBuffer = Shader . PropertyToID ( "_CameraSubsurfaceTexture" ) ;
m_CameraColorBuffer = Shader . PropertyToID ( "_CameraColorTexture" ) ;
m_CameraColorBufferRT = new RenderTargetIdentifier ( m_CameraColorBuffer ) ;
m_CameraDiffuseIrradianceBuffer = Shader . PropertyToID ( "_CameraDiffuseIrradianceTexture" ) ;
m_CameraDiffuseIrradianceBufferRT = new RenderTargetIdentifier ( m_CameraDiffuseIrradiance Buffer ) ;
m_CameraColorBufferRT = new RenderTargetIdentifier ( m_CameraColor Buffer ) ;
m_CameraSubsurfaceBufferRT = new RenderTargetIdentifier ( m_CameraSubsurfaceBuffer ) ;
// Old SSS Model >>>
m_CameraFilteringBuffer = Shader . PropertyToID ( "_CameraFilteringBuffer" ) ;
// Old SSS Model >>>
public void CreateSssMaterials ( bool useDisneySSS )
{
Utilities . Destroy ( m_FilterSubsurfaceScattering ) ;
m_FilterSubsurfaceScattering = Utilities . CreateEngineMaterial ( "Hidden/HDRenderPipeline/Combine SubsurfaceScattering" ) ;
Utilities . SelectKeyword ( m_FilterSubsurfaceScattering , "SSS_MODEL_DISNEY" , "SSS_MODEL_BASIC" , useDisneySSS ) ;
m_FilterSubsurfaceScattering . DisableKeyword ( "SSS_FILTER_HORIZONTAL_AND_COMBINE" ) ;
m_FilterSubsurfaceScattering . SetFloat ( "_DstBlend" , ( float ) BlendMode . Zero ) ;
Utilities . Destroy ( m_SssVerticalFilterPass ) ;
m_SssVerticalFilterPass = Utilities . CreateEngineMaterial ( "Hidden/HDRenderPipeline/SubsurfaceScattering" ) ;
Utilities . SelectKeyword ( m_SssVerticalFilterPass , "SSS_MODEL_DISNEY" , "SSS_MODEL_BASIC" , useDisneySSS ) ;
m_SssVerticalFilterPass . DisableKeyword ( "SSS_FILTER_HORIZONTAL_AND_COMBINE" ) ;
m_SssVerticalFilterPass . SetFloat ( "_DstBlend" , ( float ) BlendMode . Zero ) ;
Utilities . Destroy ( m_FilterAndCombineSubsurfaceScattering ) ;
m_FilterAndCombineSubsurfaceScattering = Utilities . CreateEngineMaterial ( "Hidden/HDRenderPipeline/Combine SubsurfaceScattering" ) ;
Utilities . SelectKeyword ( m_FilterAndCombineSubsurfaceScattering , "SSS_MODEL_DISNEY" , "SSS_MODEL_BASIC" , useDisneySSS ) ;
m_FilterAndCombineSubsurfaceScattering . EnableKeyword ( "SSS_FILTER_HORIZONTAL_AND_COMBINE" ) ;
m_FilterAndCombineSubsurfaceScattering . SetFloat ( "_DstBlend" , ( float ) BlendMode . One ) ;
Utilities . Destroy ( m_SssHorizontalFilterAndCombinePass ) ;
m_SssHorizontalFilterAndCombinePass = Utilities . CreateEngineMaterial ( "Hidden/HDRenderPipeline/SubsurfaceScattering" ) ;
Utilities . SelectKeyword ( m_SssHorizontalFilterAndCombinePass , "SSS_MODEL_DISNEY" , "SSS_MODEL_BASIC" , useDisneySSS ) ;
m_SssHorizontalFilterAndCombinePass . EnableKeyword ( "SSS_FILTER_HORIZONTAL_AND_COMBINE" ) ;
m_SssHorizontalFilterAndCombinePass . SetFloat ( "_DstBlend" , ( float ) BlendMode . One ) ;
}
// <<< Old SSS Model
// We compute subsurface scattering here. Therefore, no objects rendered afterwards will exhibit SSS.
// Currently, there is no efficient way to switch between SRT and MRT for the forward pass;
// therefore, forward-rendered objects do not output split lighting required for the SSS pass.
Combine SubsurfaceScattering( hdCamera , cmd , m_Asset . sssSettings ) ;
SubsurfaceScatteringPass ( hdCamera , cmd , m_Asset . sssSettings ) ;
// For opaque forward we have split rendering in two categories
// Material that are always forward and material that can be deferred or forward depends on render pipeline options (like switch to rendering forward only mode)
return ;
}
RenderTargetIdentifier [ ] colorRTs = { m_CameraColorBufferRT , m_CameraSubsurfa ceBufferRT } ;
RenderTargetIdentifier [ ] colorRTs = { m_CameraColorBufferRT , m_CameraDiffuseIrradian ceBufferRT } ;
RenderTargetIdentifier depthTexture = GetDepthTexture ( ) ;
if ( m_DebugDisplaySettings . renderingDebugSettings . enableSSSAndTransmission )
}
// Combines specular lighting and diffuse lighting with subsurface scattering.
void Combine SubsurfaceScattering( HDCamera hdCamera , CommandBuffer cmd , SubsurfaceScatteringSettings sssParameters )
void SubsurfaceScatteringPass ( HDCamera hdCamera , CommandBuffer cmd , SubsurfaceScatteringSettings sssParameters )
{
// Currently, forward-rendered objects do not output split lighting required for the SSS pass.
if ( ! m_DebugDisplaySettings . renderingDebugSettings . enableSSSAndTransmission | | m_Asset . renderingSettings . ShouldUseForwardRenderingOnly ( ) )
{
if ( sssSettings . useDisneySSS )
{
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraSubsurfa ceBufferRT ) ; // Cannot set a RT on a material
m_FilterAndCombineSubsurfaceScattering . SetFloatArray ( "_WorldScales" , sssParameters . worldScales ) ;
m_FilterAndCombineSubsurfaceScattering . SetFloatArray ( "_FilterKernelsNearField" , sssParameters . filterKernelsNearField ) ;
m_FilterAndCombineSubsurfaceScattering . SetFloatArray ( "_FilterKernelsFarField" , sssParameters . filterKernelsFarField ) ;
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraDiffuseIrradian ceBufferRT ) ; // Cannot set a RT on a material
m_SssHorizontalFilterAndCombinePass . SetFloatArray ( "_WorldScales" , sssParameters . worldScales ) ;
m_SssHorizontalFilterAndCombinePass . SetFloatArray ( "_FilterKernelsNearField" , sssParameters . filterKernelsNearField ) ;
m_SssHorizontalFilterAndCombinePass . SetFloatArray ( "_FilterKernelsFarField" , sssParameters . filterKernelsFarField ) ;
Utilities . DrawFullScreen ( cmd , m_FilterAndCombineSubsurfaceScattering , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
Utilities . DrawFullScreen ( cmd , m_SssHorizontalFilterAndCombinePass , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraSubsurfa ceBufferRT ) ; // Cannot set a RT on a material
m_FilterSubsurfaceScattering . SetFloatArray ( "_WorldScales" , sssParameters . worldScales ) ;
m_FilterSubsurfaceScattering . SetVectorArray ( "_FilterKernelsBasic" , sssParameters . filterKernelsBasic ) ;
m_FilterSubsurfaceScattering . SetVectorArray ( "_HalfRcpWeightedVariances" , sssParameters . halfRcpWeightedVariances ) ;
Utilities . DrawFullScreen ( cmd , m_FilterSubsurfaceScattering , m_CameraFilteringBufferRT , m_CameraDepthStencilBufferRT ) ;
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraDiffuseIrradian ceBufferRT ) ; // Cannot set a RT on a material
m_SssVerticalFilterPass . SetFloatArray ( "_WorldScales" , sssParameters . worldScales ) ;
m_SssVerticalFilterPass . SetVectorArray ( "_FilterKernelsBasic" , sssParameters . filterKernelsBasic ) ;
m_SssVerticalFilterPass . SetVectorArray ( "_HalfRcpWeightedVariances" , sssParameters . halfRcpWeightedVariances ) ;
Utilities . DrawFullScreen ( cmd , m_SssVerticalFilterPass , m_CameraFilteringBufferRT , m_CameraDepthStencilBufferRT ) ;
m_FilterAndCombineSubsurfaceScattering . SetFloatArray ( "_WorldScales" , sssParameters . worldScales ) ;
m_FilterAndCombineSubsurfaceScattering . SetVectorArray ( "_FilterKernelsBasic" , sssParameters . filterKernelsBasic ) ;
m_FilterAndCombineSubsurfaceScattering . SetVectorArray ( "_HalfRcpWeightedVariances" , sssParameters . halfRcpWeightedVariances ) ;
Utilities . DrawFullScreen ( cmd , m_FilterAndCombineSubsurfaceScattering , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
m_SssHorizontalFilterAndCombinePass . SetFloatArray ( "_WorldScales" , sssParameters . worldScales ) ;
m_SssHorizontalFilterAndCombinePass . SetVectorArray ( "_FilterKernelsBasic" , sssParameters . filterKernelsBasic ) ;
m_SssHorizontalFilterAndCombinePass . SetVectorArray ( "_HalfRcpWeightedVariances" , sssParameters . halfRcpWeightedVariances ) ;
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_CameraSubsurfaceBuffer , w , h , 0 , FilterMode . Point , RenderTextureFormat . RGB111110Float , RenderTextureReadWrite . Linear , 1 , true ) ; // Enable UAV
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
cmd . GetTemporaryRT ( m_CameraFilteringBuffer , 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
// <<< Old SSS Model
if ( ! m_Asset . renderingSettings . ShouldUseForwardRenderingOnly ( ) )
// Clear the diffuse SSS lighting target
using ( new Utilities . ProfilingSample ( "Clear SSS diffuse target" , cmd ) )
{
Utilities . SetRenderTarget ( cmd , m_CameraSubsurfa ceBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
Utilities . SetRenderTarget ( cmd , m_CameraDiffuseIrradian ceBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
}
// Old SSS Model >>>