}
}
private RenderTargetIdentifier [ ] m_ColorMRTs ;
var colorMRTs = new RenderTargetIdentifier [ gbufferCount ] ;
if ( m_ColorMRTs = = null | | m_ColorMRTs . Length ! = gbufferCount )
m_ColorMRTs = new RenderTargetIdentifier [ gbufferCount ] ;
colorMRTs [ index ] = RTIDs [ index ] ;
m_ColorMRTs [ index ] = RTIDs [ index ] ;
return colorMRTs ;
return m_ColorMRTs ;
}
public int gbufferCount { get ; set ; }
m_ShadowSettings . directionalLightNearPlaneOffset = commonSettings . shadowNearPlaneOffset ;
}
CullResults m_CullResults ;
public override void Render ( ScriptableRenderContext renderContext , Camera [ ] cameras )
{
base . Render ( renderContext , cameras ) ;
// we only want to render one camera for now
// select the most main camera!
Camera camera = cameras . OrderByDescending ( x = > x . tag = = "MainCamera" ) . FirstOrDefault ( ) ;
Camera camera = null ;
foreach ( var cam in cameras )
{
if ( cam = = Camera . main )
{
camera = cam ;
break ;
}
}
if ( camera = = null & & cameras . Length > 0 )
camera = cameras [ 0 ] ;
if ( camera = = null )
{
renderContext . Submit ( ) ;
}
m_LightLoop . UpdateCullingParameters ( ref cullingParams ) ;
var cullResults = CullResults . Cull ( ref cullingParams , renderContext ) ;
CullResults . Cull ( ref cullingParams , renderContext , ref m_CullResults ) ;
Resize ( camera ) ;
PushGlobalParams ( hdCamera , renderContext , m_Asset . sssSettings ) ;
RenderDepthPrepass ( c ullResults, camera , renderContext ) ;
RenderDepthPrepass ( m_C ullResults, camera , renderContext ) ;
RenderForwardOnlyOpaqueDepthPrepass ( c ullResults, camera , renderContext ) ;
RenderGBuffer ( c ullResults, camera , renderContext ) ;
RenderForwardOnlyOpaqueDepthPrepass ( m_C ullResults, camera , renderContext ) ;
RenderGBuffer ( m_C ullResults, camera , renderContext ) ;
// If full forward rendering, we did not do any rendering yet, so don't need to copy the buffer.
// If Deferred then the depth buffer is full (regular GBuffer + ForwardOnly depth prepass are done so we can copy it safely.
if ( m_DebugDisplaySettings . IsDebugMaterialDisplayEnabled ( ) )
{
RenderDebugViewMaterial ( c ullResults, hdCamera , renderContext ) ;
RenderDebugViewMaterial ( m_C ullResults, hdCamera , renderContext ) ;
}
else
{
m_SsaoEffect . Render ( ssaoSettingsToUse , this , hdCamera , renderContext , m_Asset . renderingSettings . useForwardRenderingOnly ) ;
m_LightLoop . PrepareLightsForGPU ( m_ShadowSettings , c ullResults, camera ) ;
m_LightLoop . RenderShadows ( renderContext , c ullResults) ;
m_LightLoop . PrepareLightsForGPU ( m_ShadowSettings , m_C ullResults, camera ) ;
m_LightLoop . RenderShadows ( renderContext , m_C ullResults) ;
renderContext . SetupCameraProperties ( camera ) ; // Need to recall SetupCameraProperties after m_ShadowPass.Render
m_LightLoop . BuildGPULightLists ( camera , renderContext , m_CameraDepthStencilBufferRT ) ;
}
// 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)
// Material that are always forward are unlit and complex (Like Hair) and don't require sorting, so it is ok to split them.
RenderForward ( c ullResults, camera , renderContext , true ) ; // Render deferred or forward opaque
RenderForwardOnlyOpaque ( c ullResults, camera , renderContext ) ;
RenderForward ( m_C ullResults, camera , renderContext , true ) ; // Render deferred or forward opaque
RenderForwardOnlyOpaque ( m_C ullResults, camera , renderContext ) ;
RenderLightingDebug ( hdCamera , renderContext , m_CameraColorBufferRT ) ;
RenderSky ( hdCamera , renderContext ) ;
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
RenderForward ( c ullResults, camera , renderContext , false ) ;
RenderForward ( m_C ullResults, camera , renderContext , false ) ;
// Planar and real time cubemap doesn't need post process and render in FP16
if ( camera . cameraType = = CameraType . Reflection )
}
else
{
RenderVelocity ( c ullResults, camera , renderContext ) ; // Note we may have to render velocity earlier if we do temporalAO, temporal volumetric etc... Mean we will not take into account forward opaque in case of deferred rendering ?
RenderVelocity ( m_C ullResults, camera , renderContext ) ; // Note we may have to render velocity earlier if we do temporalAO, temporal volumetric etc... Mean we will not take into account forward opaque in case of deferred rendering ?
RenderDistortion ( c ullResults, camera , renderContext ) ;
RenderDistortion ( m_C ullResults, camera , renderContext ) ;
RenderPostProcesses ( camera , renderContext ) ;
}
}
}
MaterialPropertyBlock m_SharedPropertyBlock = new MaterialPropertyBlock ( ) ;
void RenderDebug ( HDCamera camera , ScriptableRenderContext renderContext )
{
// We don't want any overlay for these kind of rendering
float overlayRatio = m_DebugDisplaySettings . debugOverlayRatio ;
float overlaySize = Math . Min ( camera . camera . pixelHeight , camera . camera . pixelWidth ) * overlayRatio ;
float y = camera . camera . pixelHeight - overlaySize ;
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock ( ) ;
propertyBlock . SetTexture ( "_InputCubemap" , skyReflection ) ;
propertyBlock . SetFloat ( "_Mipmap" , lightingDebug . skyReflectionMipmap ) ;
m_SharedPropertyBlock . SetTexture ( "_InputCubemap" , skyReflection ) ;
m_SharedPropertyBlock . SetFloat ( "_Mipmap" , lightingDebug . skyReflectionMipmap ) ;
debugCB . DrawProcedural ( Matrix4x4 . identity , m_DebugDisplayLatlong , 0 , MeshTopology . Triangles , 3 , 1 , propertyBlock ) ;
debugCB . DrawProcedural ( Matrix4x4 . identity , m_DebugDisplayLatlong , 0 , MeshTopology . Triangles , 3 , 1 , m_SharedPropertyBlock ) ;
Utilities . NextOverlayCoord ( ref x , ref y , overlaySize , overlaySize , camera . camera . pixelWidth ) ;
}