static readonly RenderQueueRange k_RenderQueue_PreRefraction = new RenderQueueRange { min = ( int ) HDRenderQueue . PreRefraction , max = ( int ) HDRenderQueue . Transparent - 1 } ;
static readonly RenderQueueRange k_RenderQueue_Transparent = new RenderQueueRange { min = ( int ) HDRenderQueue . Transparent , max = ( int ) HDRenderQueue . Overlay - 1 } ;
static readonly RenderQueueRange k_RenderQueue_AllTransparent = new RenderQueueRange { min = ( int ) HDRenderQueue . PreRefraction , max = ( int ) HDRenderQueue . Overlay - 1 } ;
readonly HDRenderPipelineAsset m_Asset ;
ShaderPassName [ ] m_AllTransparentPassNames = { HDShaderPassNames . s_TransparentBackfaceName ,
HDShaderPassNames . s_ForwardOnlyName ,
HDShaderPassNames . s_ForwardName ,
HDShaderPassNames . s_TransparentDepthPostpassName ,
HDShaderPassNames . s_TransparentDepthPostpassName ,
HDShaderPassNames . s_SRPDefaultUnlitName } ;
ShaderPassName [ ] m_AllForwardDebugDisplayPassNames = { HDShaderPassNames . s_TransparentBackfaceDebugDisplayName ,
ShaderPassName [ ] m_DepthOnlyAndDepthForwardOnlyPassNames = { HDShaderPassNames . s_DepthForwardOnlyName , HDShaderPassNames . s_DepthOnlyName } ;
ShaderPassName [ ] m_DepthForwardOnlyPassNames = { HDShaderPassNames . s_DepthForwardOnlyName } ;
ShaderPassName [ ] m_DepthOnlyPassNames = { HDShaderPassNames . s_DepthOnlyName } ;
ShaderPassName [ ] m_TransparentDepthOnlyPassNames = { HDShaderPassNames . s_TransparentDepthPrepassName } ;
ShaderPassName [ ] m_TransparentDepthPrePassNames = { HDShaderPassNames . s_TransparentDepthPrePassName } ;
ShaderPassName [ ] m_TransparentDepthPostPassNames = { HDShaderPassNames . s_TransparentDepthPostPassName } ;
ShaderPassName [ ] m_ForwardErrorPassNames = { HDShaderPassNames . s_AlwaysName , HDShaderPassNames . s_ForwardBaseName , HDShaderPassNames . s_DeferredName , HDShaderPassNames . s_PrepassBaseName , HDShaderPassNames . s_VertexName , HDShaderPassNames . s_VertexLMRGBMName , HDShaderPassNames . s_VertexLMName } ;
ShaderPassName [ ] m_SinglePassName = new ShaderPassName [ 1 ] ;
{
CoreUtils . SetRenderTarget ( cmd , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . Color | ClearFlag . Depth ) ;
RenderOpaqueRenderList ( m_CullResults , camera , renderContext , cmd , HDShaderPassNames . s_ForwardName ) ;
RenderTransparentRenderList ( m_CullResults , camera , renderContext , cmd , HDShaderPassNames . s_ForwardName , false ) ;
RenderTransparentRenderList ( m_CullResults , camera , renderContext , cmd , HDShaderPassNames . s_ForwardName ) ;
}
renderContext . ExecuteCommandBuffer ( cmd ) ;
RenderForward ( m_CullResults , hdCamera , renderContext , cmd , ForwardPass . Transparent ) ;
RenderForwardError ( m_CullResults , camera , renderContext , cmd , ForwardPass . Transparent ) ;
// Fill depth buffer to reduce artifact for transparent object
RenderTransparentDepthPostPass ( m_CullResults , camera , renderContext , cmd , ForwardPass . Transparent ) ;
PushFullScreenDebugTexture ( cmd , m_CameraColorBuffer , camera , renderContext , FullScreenDebugMode . NanTracker ) ;
// Planar and real time cubemap doesn't need post process and render in FP16
var filterSettings = new FilterRenderersSettings ( true )
{
renderQueueRange = inRenderQueueRange = = null
? RenderQueueRange . opaque
: inRenderQueueRange . Value
renderQueueRange = inRenderQueueRange = = null ? RenderQueueRange . opaque : inRenderQueueRange . Value
} ;
if ( stateBlock = = null )
ScriptableRenderContext renderContext ,
CommandBuffer cmd ,
ShaderPassName passName ,
bool preRefractionQueue ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderTransparentRenderList ( cull , camera , renderContext , cmd , m_SinglePassName , preRefractionQueue ,
rendererConfiguration , stateBlock , overrideMaterial ) ;
RenderTransparentRenderList ( cull , camera , renderContext , cmd , m_SinglePassName ,
rendererConfiguration , inRenderQueueRange , stateBlock , overrideMaterial ) ;
}
void RenderTransparentRenderList ( CullResults cull ,
ShaderPassName [ ] passNames ,
bool preRefractionQueue ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null
)
var filterSettings = new FilterRenderersSettings ( true )
{
renderQueueRange = preRefractionQueue
? k_RenderQueue_PreRefraction
: k_RenderQueue_Transparent
renderQueueRange = inRenderQueueRange = = null ? k_RenderQueue_AllTransparent : inRenderQueueRange . Value
} ;
if ( stateBlock = = null )
cmd . ClearRenderTarget ( false , true , Color . clear ) ;
// Only transparent object can render distortion vectors
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , HDShaderPassNames . s_DistortionVectorsName , true ) ;
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , HDShaderPassNames . s_DistortionVectorsName , false ) ;
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , HDShaderPassNames . s_DistortionVectorsName ) ;
}
}
RenderOpaqueRenderList ( cull , camera , renderContext , cmd , m_DepthOnlyPassNames , 0 , renderQueueRange , m_DepthStateOpaque ) ;
}
}
}
// Render transparent depth prepass after opaque one
RenderTransparentRenderList ( cull , camera , renderContext , cmd , m_TransparentDepthOnlyPassNames , true ) ;
RenderTransparentRenderList ( cull , camera , renderContext , cmd , m_TransparentDepthOnlyPassNames , false ) ;
// Render transparent depth prepass after opaque one
using ( new ProfilingSample ( cmd , "Transparent Depth Prepass" , GetSampler ( CustomSamplerId . TransparentDepthPrepass ) ) )
{
RenderTransparentRenderList ( cull , camera , renderContext , cmd , m_TransparentDepthPrePassNames ) ;
}
}
RenderOpaqueRenderList ( cull , hdCamera . camera , renderContext , cmd , m_AllForwardDebugDisplayPassNames , m_currentRendererConfigurationBakedLighting ) ;
// Render forward transparent
RenderTransparentRenderList ( cull , hdCamera . camera , renderContext , cmd , m_AllForwardDebugDisplayPassNames , true , m_currentRendererConfigurationBakedLighting ) ;
RenderTransparentRenderList ( cull , hdCamera . camera , renderContext , cmd , m_AllForwardDebugDisplayPassNames , false , m_currentRendererConfigurationBakedLighting ) ;
RenderTransparentRenderList ( cull , hdCamera . camera , renderContext , cmd , m_AllForwardDebugDisplayPassNames , m_currentRendererConfigurationBakedLighting ) ;
}
}
CoreUtils . SetRenderTarget ( cmd , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
var passNames = m_CurrentDebugDisplaySettings . IsDebugDisplayEnabled ( ) ? m_AllTransparentDebugDisplayPassNames : m_AllTransparentPassNames ;
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , passNames , pass = = ForwardPass . PreRefraction , m_currentRendererConfigurationBakedLighting ) ;
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , passNames , m_currentRendererConfigurationBakedLighting , pass = = ForwardPass . PreRefraction ? k_RenderQueue_PreRefraction : k_RenderQueue_Transparent ) ;
}
}
}
}
else
{
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , m_ForwardErrorPassNames , pass = = ForwardPass . PreRefraction , 0 , null , m_ErrorMaterial ) ;
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , m_ForwardErrorPassNames , 0 , pass = = ForwardPass . PreRefraction ? k_RenderQueue_PreRefraction : k_RenderQueue_Transparent , null , m_ErrorMaterial ) ;
}
}
void RenderTransparentDepthPostPass ( CullResults cullResults , Camera camera , ScriptableRenderContext renderContext , CommandBuffer cmd , ForwardPass pass )
{
using ( new ProfilingSample ( cmd , "Render Transparent Depth Post " , GetSampler ( CustomSamplerId . TransparentDepthPostPass ) ) )
{
CoreUtils . SetRenderTarget ( cmd , m_CameraDepthStencilBufferRT ) ;
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , m_TransparentDepthPostPassNames ) ;
}
}