using UnityEngine.Rendering ;
using System ;
using System.Diagnostics ;
using System.Linq ;
using UnityEngine.Rendering.PostProcessing ;
using UnityEngine.Experimental.Rendering.HDPipeline.TilePass ;
[Serializable]
public class RenderingSettings
{
public bool useForwardRenderingOnly = false ; // TODO: Currently there is no way to strip the extra forward shaders generated by the shaders compiler, so we can switch dynamically.
public bool useDepthPrepassWithDeferredRendering = false ;
public bool renderAlphaTestOnlyInDeferredPrepass = false ;
public bool useForwardRenderingOnly ; // TODO: Currently there is no way to strip the extra forward shaders generated by the shaders compiler, so we can switch dynamically.
public bool useDepthPrepassWithDeferredRendering ;
public bool renderAlphaTestOnlyInDeferredPrepass ;
// We have to fall back to forward-only rendering when scene view is using wireframe rendering mode --
// as rendering everything in wireframe + deferred do not play well together
readonly RenderPipelineMaterial m_DeferredMaterial ;
readonly List < RenderPipelineMaterial > m_MaterialList = new List < RenderPipelineMaterial > ( ) ;
readonly GBufferManager m_g bufferManager = new GBufferManager ( ) ;
readonly GBufferManager m_G bufferManager = new GBufferManager ( ) ;
Material m_CopyStencilForSplitLighting ;
Material m_CopyStencilForRegularLighting ;
readonly RenderTargetIdentifier m_DeferredShadowBufferRT ;
RenderTexture m_CameraDepthStencilBuffer = null ;
RenderTexture m_CameraDepthBufferCopy = null ;
RenderTexture m_CameraStencilBufferCopy = null ;
RenderTexture m_HTile = null ; // If the hardware does not expose it, we compute our own, optimized to only contain the SSS bit
RenderTexture m_CameraDepthStencilBuffer ;
RenderTexture m_CameraDepthBufferCopy ;
RenderTexture m_CameraStencilBufferCopy ;
RenderTexture m_HTile ; // If the hardware does not expose it, we compute our own, optimized to only contain the SSS bit
RenderTargetIdentifier m_CameraDepthStencilBufferRT ;
RenderTargetIdentifier m_CameraDepthBufferCopyRT ;
MaterialPropertyBlock m_SharedPropertyBlock = new MaterialPropertyBlock ( ) ;
DebugDisplaySettings m_DebugDisplaySettings = new DebugDisplaySettings ( ) ;
static DebugDisplaySettings s_NeutralDebugDisplaySettings = new DebugDisplaySettings ( ) ;
DebugDisplaySettings m_CurrentDebugDisplaySettings = null ;
DebugDisplaySettings m_CurrentDebugDisplaySettings ;
bool m_FullScreenDebugPushed = false ;
bool m_FullScreenDebugPushed ;
public SubsurfaceScatteringSettings sssSettings
{
m_MaterialList = CoreUtils . GetRenderPipelineMaterialList ( ) ;
// Find first material that have non 0 Gbuffer count and assign it as deferredMaterial
m_DeferredMaterial = null ;
foreach ( RenderPipelineMaterial material in m_MaterialList )
foreach ( var material in m_MaterialList )
{
}
}
// TODO: Handle the case of no Gbuffer material
InitializeDebugMaterials ( ) ;
// Init Gbuffer description
m_g bufferManager . gbufferCount = m_DeferredMaterial . GetMaterialGBufferCount ( ) ;
RenderTextureFormat [ ] RT Format;
RenderTextureReadWrite [ ] RT ReadWrite;
m_DeferredMaterial . GetMaterialGBufferDescription ( out RTFormat , out RT ReadWrite) ;
m_G bufferManager . gbufferCount = m_DeferredMaterial . GetMaterialGBufferCount ( ) ;
RenderTextureFormat [ ] rt Format;
RenderTextureReadWrite [ ] rt ReadWrite;
m_DeferredMaterial . GetMaterialGBufferDescription ( out rtFormat , out rt ReadWrite) ;
for ( int gbufferIndex = 0 ; gbufferIndex < m_g bufferManager . gbufferCount ; + + gbufferIndex )
for ( int gbufferIndex = 0 ; gbufferIndex < m_G bufferManager . gbufferCount ; + + gbufferIndex )
m_g bufferManager . SetBufferDescription ( gbufferIndex , "_GBufferTexture" + gbufferIndex , RT Format[ gbufferIndex ] , RT ReadWrite[ gbufferIndex ] ) ;
m_G bufferManager . SetBufferDescription ( gbufferIndex , "_GBufferTexture" + gbufferIndex , rt Format[ gbufferIndex ] , rt ReadWrite[ gbufferIndex ] ) ;
}
m_VelocityBuffer = HDShaderIDs . _VelocityTexture ;
m_gbufferManager . SetBufferDescription ( m_gbufferManager . gbufferCount , "_VelocityTexture" , Builtin . GetVelocityBufferFormat ( ) , Builtin . GetVelocityBufferReadWrite ( ) ) ;
m_gbufferManager . gbufferCount + + ;
m_GbufferManager . SetBufferDescription ( m_GbufferManager . gbufferCount , "_VelocityTexture" , Builtin . GetVelocityBufferFormat ( ) , Builtin . GetVelocityBufferReadWrite ( ) ) ;
m_GbufferManager . gbufferCount + + ;
}
m_VelocityBufferRT = new RenderTargetIdentifier ( m_VelocityBuffer ) ;
void RegisterDebug ( )
{
// These need to be Runtime Only because those values are hold by the HDRenderPipeline asset so if user change them through the editor debug menu they might change the value in the asset without noticing it.
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Forward Only" , ( ) = > ( bool ) m_Asset . renderingSettings . useForwardRenderingOnly , ( value ) = > m_Asset . renderingSettings . useForwardRenderingOnly = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Deferred Depth Prepass" , ( ) = > ( bool ) m_Asset . renderingSettings . useDepthPrepassWithDeferredRendering , ( value ) = > m_Asset . renderingSettings . useDepthPrepassWithDeferredRendering = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Deferred Depth Prepass ATest Only" , ( ) = > ( bool ) m_Asset . renderingSettings . renderAlphaTestOnlyInDeferredPrepass , ( value ) = > m_Asset . renderingSettings . renderAlphaTestOnlyInDeferredPrepass = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Forward Only" , ( ) = > m_Asset . renderingSettings . useForwardRenderingOnly , ( value ) = > m_Asset . renderingSettings . useForwardRenderingOnly = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Deferred Depth Prepass" , ( ) = > m_Asset . renderingSettings . useDepthPrepassWithDeferredRendering , ( value ) = > m_Asset . renderingSettings . useDepthPrepassWithDeferredRendering = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Deferred Depth Prepass ATest Only" , ( ) = > m_Asset . renderingSettings . renderAlphaTestOnlyInDeferredPrepass , ( value ) = > m_Asset . renderingSettings . renderAlphaTestOnlyInDeferredPrepass = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Tile/Cluster" , ( ) = > ( bool ) m_Asset . tileSettings . enableTileAndCluster , ( value ) = > m_Asset . tileSettings . enableTileAndCluster = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Big Tile" , ( ) = > ( bool ) m_Asset . tileSettings . enableBigTilePrepass , ( value ) = > m_Asset . tileSettings . enableBigTilePrepass = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Cluster" , ( ) = > ( bool ) m_Asset . tileSettings . enableClustered , ( value ) = > m_Asset . tileSettings . enableClustered = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Compute Lighting" , ( ) = > ( bool ) m_Asset . tileSettings . enableComputeLightEvaluation , ( value ) = > m_Asset . tileSettings . enableComputeLightEvaluation = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Light Classification" , ( ) = > ( bool ) m_Asset . tileSettings . enableComputeLightVariants , ( value ) = > m_Asset . tileSettings . enableComputeLightVariants = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Material Classification" , ( ) = > ( bool ) m_Asset . tileSettings . enableComputeMaterialVariants , ( value ) = > m_Asset . tileSettings . enableComputeMaterialVariants = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Tile/Cluster" , ( ) = > m_Asset . tileSettings . enableTileAndCluster , ( value ) = > m_Asset . tileSettings . enableTileAndCluster = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Big Tile" , ( ) = > m_Asset . tileSettings . enableBigTilePrepass , ( value ) = > m_Asset . tileSettings . enableBigTilePrepass = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Cluster" , ( ) = > m_Asset . tileSettings . enableClustered , ( value ) = > m_Asset . tileSettings . enableClustered = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Compute Lighting" , ( ) = > m_Asset . tileSettings . enableComputeLightEvaluation , ( value ) = > m_Asset . tileSettings . enableComputeLightEvaluation = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Light Classification" , ( ) = > m_Asset . tileSettings . enableComputeLightVariants , ( value ) = > m_Asset . tileSettings . enableComputeLightVariants = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
DebugMenuManager . instance . AddDebugItem < bool > ( "HDRP" , "Enable Material Classification" , ( ) = > m_Asset . tileSettings . enableComputeMaterialVariants , ( value ) = > m_Asset . tileSettings . enableComputeMaterialVariants = ( bool ) value , DebugItemFlag . RuntimeOnly ) ;
}
void InitializeDebugMaterials ( )
void InitializeRenderStateBlocks ( )
{
m_DepthStateOpaque . depthState = new DepthState ( true , CompareFunction . LessEqual ) ;
m_DepthStateOpaque . mask = RenderStateMask . Depth ;
m_DepthStateOpaque = new RenderStateBlock
{
depthState = new DepthState ( true , CompareFunction . LessEqual ) ,
mask = RenderStateMask . Depth
} ;
m_DepthStateOpaqueWithPrepass . depthState = new DepthState ( false , CompareFunction . Equal ) ;
m_DepthStateOpaqueWithPrepass . mask = RenderStateMask . Depth ;
m_DepthStateOpaqueWithPrepass = new RenderStateBlock
{
depthState = new DepthState ( false , CompareFunction . Equal ) ,
mask = RenderStateMask . Depth
} ;
}
public void OnSceneLoad ( )
void CreateDepthStencilBuffer ( Camera camera )
{
if ( m_CameraDepthStencilBuffer ! = null )
{
}
m_CameraDepthStencilBuffer = new RenderTexture ( camera . pixelWidth , camera . pixelHeight , 2 4 , RenderTextureFormat . Depth ) ;
m_CameraDepthStencilBuffer . filterMode = FilterMode . Point ;
if ( NeedDepthBufferCopy ( ) )
{
if ( m_CameraDepthBufferCopy ! = null )
{
}
m_CameraDepthBufferCopy = new RenderTexture ( camera . pixelWidth , camera . pixelHeight , 2 4 , RenderTextureFormat . Depth ) ;
m_CameraDepthBufferCopy . filterMode = FilterMode . Point ;
m_CameraDepthBufferCopy . Create ( ) ;
if ( NeedStencilBufferCopy ( ) )
{
if ( m_CameraStencilBufferCopy ! = null )
{
}
m_CameraStencilBufferCopy = new RenderTexture ( camera . pixelWidth , camera . pixelHeight , 0 , RenderTextureFormat . R8 , RenderTextureReadWrite . Linear ) ; // DXGI_FORMAT_R8_UINT is not supported by Unity
m_CameraStencilBufferCopy . filterMode = FilterMode . Point ;
m_CameraStencilBufferCopy . Create ( ) ;
if ( NeedHTileCopy ( ) )
{
if ( m_HTile ! = null )
{
}
// We use 8x8 tiles in order to match the native GCN HTile as closely as possible.
m_HTile = new RenderTexture ( ( camera . pixelWidth + 7 ) / 8 , ( camera . pixelHeight + 7 ) / 8 , 0 , RenderTextureFormat . R8 , RenderTextureReadWrite . Linear ) ; // DXGI_FORMAT_R8_UINT is not supported by Unity
m_HTile . filterMode = FilterMode . Point ;
bool resolutionChanged = camera . pixelWidth ! = m_CurrentWidth | | camera . pixelHeight ! = m_CurrentHeight ;
if ( resolutionChanged | | m_CameraDepthStencilBuffer = = null )
{
}
{
}
{
}
// update recorded window resolution
m_CurrentWidth = camera . pixelWidth ;
}
// This is the main command buffer used for the frame.
CommandBuffe r cmd = CommandBufferPool . Get ( "" ) ;
va r cmd = CommandBufferPool . Get ( "" ) ;
m_MaterialList . ForEach ( material = > material . RenderInit ( cmd ) ) ;
// we only want to render one camera for now
// select the most main camera!
Camera camera = null ;
foreach ( var cam in cameras )
{
if ( cam = = Camera . main )
{
camera = cam ;
break ;
}
}
var camera = cameras . FirstOrDefault ( cam = > cam = = Camera . main ) ;
if ( camera = = null & & cameras . Length > 0 )
camera = cameras [ 0 ] ;
renderContext . SetupCameraProperties ( camera ) ;
var postProcessLayer = camera . GetComponent < PostProcessLayer > ( ) ;
HDCamera hdCamera = HDCamera . Get ( camera , postProcessLayer ) ;
var hdCamera = HDCamera . Get ( camera , postProcessLayer ) ;
PushGlobalParams ( hdCamera , cmd , m_Asset . sssSettings ) ;
// TODO: Find a correct place to bind these material textures
m_LightLoop . BuildGPULightLists ( camera , cmd , m_CameraDepthStencilBufferRT , GetStencilTexture ( ) ) ;
}
// Don't update the sky environment if we are rendering a cubemap (it should be update already)
if ( camera . cameraType ! = CameraType . Reflection )
{
// Simple blit
cmd . Blit ( m_CameraColorBufferRT , BuiltinRenderTextureType . CameraTarget ) ;
}
}
else
{
#if UNITY_EDITOR
// bind depth surface for editor grid/gizmo/selection rendering
if ( camera . cameraType = = CameraType . SceneView )
{
}
#endif
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBuffer cmd ,
ShaderPassName passName ,
RendererConfiguration rendererConfiguration = 0 ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
{
}
if ( overrideMaterial ! = null )
{
}
var filterSettings = new FilterRenderersSettings ( true ) { renderQueueRange = inRenderQueueRange = = null ? RenderQueueRange . opaque : inRenderQueueRange . Value } ;
var filterSettings = new FilterRenderersSettings ( true )
{
renderQueueRange = inRenderQueueRange = = null
? RenderQueueRange . opaque
: inRenderQueueRange . Value
} ;
if ( stateBlock = = null )
renderContext . DrawRenderers ( cull . visibleRenderers , ref drawSettings , filterSettings ) ;
else
void RenderTransparentRenderList ( CullResults cull ,
Camera camera ,
ScriptableRenderContext renderContext ,
CommandBuffer cmd ,
ShaderPassName passName ,
RendererConfiguration rendererConfiguration = 0 ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
void RenderTransparentRenderList ( CullResults cull ,
Camera camera ,
ScriptableRenderContext renderContext ,
CommandBuffer cmd ,
ShaderPassName passName ,
RendererConfiguration rendererConfiguration = 0 ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
void RenderTransparentRenderList ( CullResults cull ,
Camera camera ,
ScriptableRenderContext renderContext ,
CommandBuffer cmd ,
ShaderPassName [ ] passNames ,
RendererConfiguration rendererConfiguration = 0 ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
void RenderTransparentRenderList ( CullResults cull ,
Camera camera ,
ScriptableRenderContext renderContext ,
CommandBuffer cmd ,
ShaderPassName [ ] passNames ,
RendererConfiguration rendererConfiguration = 0 ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
{
if ( ! m_CurrentDebugDisplaySettings . renderingDebugSettings . displayTransparentObjects )
return ;
}
if ( overrideMaterial ! = null )
{
}
if ( stateBlock = = null )
renderContext . DrawRenderers ( cull . visibleRenderers , ref drawSettings , filterSettings ) ;
else
using ( new ProfilingSample ( cmd , addDepthPrepass ? "Depth Prepass" : "Depth Prepass forward opaque" ) )
{
// Default depth prepass (forward and deferred) will render all opaque geometry.
RenderQueueRange renderQueueRange = RenderQueueRange . opaque ;
var renderQueueRange = RenderQueueRange . opaque ;
// If we want only alpha tested geometry in prepass for deferred we change the RenderQueueRange
if ( ! m_Asset . renderingSettings . ShouldUseForwardRenderingOnly ( ) & & m_Asset . renderingSettings . useDepthPrepassWithDeferredRendering & & m_Asset . renderingSettings . renderAlphaTestOnlyInDeferredPrepass )
renderQueueRange = new RenderQueueRange { min = ( int ) RenderQueue . AlphaTest , max = ( int ) RenderQueue . GeometryLast - 1 } ;
using ( new ProfilingSample ( cmd , m_CurrentDebugDisplaySettings . IsDebugDisplayEnabled ( ) ? "GBufferDebugDisplay" : "GBuffer" ) )
{
// setup GBuffer for rendering
CoreUtils . SetRenderTarget ( cmd , m_g bufferManager . GetGBuffers ( ) , m_CameraDepthStencilBufferRT ) ;
CoreUtils . SetRenderTarget ( cmd , m_G bufferManager . GetGBuffers ( ) , m_CameraDepthStencilBufferRT ) ;
// Render opaque objects into GBuffer
if ( m_CurrentDebugDisplaySettings . IsDebugDisplayEnabled ( ) )
{
if ( m_Asset . renderingSettings . useDepthPrepassWithDeferredRendering )
{
RenderQueueRange rangeOpaqueNoAlphaTest = new RenderQueueRange { min = ( int ) RenderQueue . Geometry , max = ( int ) RenderQueue . AlphaTest - 1 } ;
RenderQueueRange rangeOpaqueAlphaTest = new RenderQueueRange { min = ( int ) RenderQueue . AlphaTest , max = ( int ) RenderQueue . GeometryLast - 1 } ;
var rangeOpaqueNoAlphaTest = new RenderQueueRange { min = ( int ) RenderQueue . Geometry , max = ( int ) RenderQueue . AlphaTest - 1 } ;
var rangeOpaqueAlphaTest = new RenderQueueRange { min = ( int ) RenderQueue . AlphaTest , max = ( int ) RenderQueue . GeometryLast - 1 } ;
// When using depth prepass for opaque alpha test only we need to use regular depth test for normal opaque objects.
RenderOpaqueRenderList ( cull , camera , renderContext , cmd , HDShaderPassNames . s_GBufferName , HDUtils . k_RendererConfigurationBakedLighting , rangeOpaqueNoAlphaTest , m_Asset . renderingSettings . renderAlphaTestOnlyInDeferredPrepass ? m_DepthStateOpaque : m_DepthStateOpaqueWithPrepass ) ;
return ;
}
RenderTargetIdentifier [ ] colorRTs = { m_CameraColorBufferRT , m_CameraSssDiffuseLightingBufferRT } ;
RenderTargetIdentifier depthTexture = GetDepthTexture ( ) ;
var colorRTs = new [ ] { m_CameraColorBufferRT , m_CameraSssDiffuseLightingBufferRT } ;
var depthTexture = GetDepthTexture ( ) ;
LightLoop . LightingPassOptions options = new LightLoop . LightingPassOptions ( ) ;
var options = new LightLoop . LightingPassOptions ( ) ;
options . volumetricLightingEnabled = m_VolumetricLightingEnabled ;
if ( m_CurrentDebugDisplaySettings . renderingDebugSettings . enableSSSAndTransmission )
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_g bufferManager . GetGBuffers ( ) [ 0 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture1 , m_g bufferManager . GetGBuffers ( ) [ 1 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture2 , m_g bufferManager . GetGBuffers ( ) [ 2 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture3 , m_g bufferManager . GetGBuffers ( ) [ 3 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture0 , m_G bufferManager . GetGBuffers ( ) [ 0 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture1 , m_G bufferManager . GetGBuffers ( ) [ 1 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture2 , m_G bufferManager . GetGBuffers ( ) [ 2 ] ) ;
cmd . SetComputeTextureParam ( m_SubsurfaceScatteringCS , m_SubsurfaceScatteringKernel , HDShaderIDs . _GBufferTexture3 , m_G bufferManager . 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 ( ) ) ;
m_LightLoop . RenderForward ( camera , cmd , renderOpaque ) ;
// The pass "SRPDefaultUnlit" is a fallback to legacy unlit rendering and is required to support unity 2d + unity UI that render in the scene.
ShaderPassName [ ] arrayNames = { passName , HDShaderPassNames . s_SRPDefaultUnlitName } ;
var arrayNames = new [ ] { passName , HDShaderPassNames . s_SRPDefaultUnlitName } ;
if ( renderOpaque )
{
{
m_ShadowSettings . enabled = m_CurrentDebugDisplaySettings . lightingDebugSettings . enableShadows ;
LightingDebugSettings lightingDebugSettings = m_CurrentDebugDisplaySettings . lightingDebugSettings ;
Vector4 debugAlbedo = new Vector4 ( lightingDebugSettings . debugLightingAlbedo . r , lightingDebugSettings . debugLightingAlbedo . g , lightingDebugSettings . debugLightingAlbedo . b , 0.0f ) ;
Vector4 debugSmoothness = new Vector4 ( lightingDebugSettings . overrideSmoothness ? 1.0f : 0.0f , lightingDebugSettings . overrideSmoothnessValue , 0.0f , 0.0f ) ;
var lightingDebugSettings = m_CurrentDebugDisplaySettings . lightingDebugSettings ;
var debugAlbedo = new Vector4 ( lightingDebugSettings . debugLightingAlbedo . r , lightingDebugSettings . debugLightingAlbedo . g , lightingDebugSettings . debugLightingAlbedo . b , 0.0f ) ;
var debugSmoothness = new Vector4 ( lightingDebugSettings . overrideSmoothness ? 1.0f : 0.0f , lightingDebugSettings . overrideSmoothnessValue , 0.0f , 0.0f ) ;
Shader . SetGlobalInt ( HDShaderIDs . _DebugViewMaterial , ( int ) m_CurrentDebugDisplaySettings . GetDebugMaterialIndex ( ) ) ;
Shader . SetGlobalInt ( HDShaderIDs . _DebugLightingMode , ( int ) m_CurrentDebugDisplaySettings . GetDebugLightingMode ( ) ) ;
float overlaySize = Math . Min ( camera . camera . pixelHeight , camera . camera . pixelWidth ) * overlayRatio ;
float y = camera . camera . pixelHeight - overlaySize ;
LightingDebugSettings lightingDebug = m_CurrentDebugDisplaySettings . lightingDebugSettings ;
var lightingDebug = m_CurrentDebugDisplaySettings . lightingDebugSettings ;
Texture skyReflection = m_SkyManager . skyReflection ;
var skyReflection = m_SkyManager . skyReflection ;
m_SharedPropertyBlock . SetTexture ( HDShaderIDs . _InputCubemap , skyReflection ) ;
m_SharedPropertyBlock . SetFloat ( HDShaderIDs . _Mipmap , lightingDebug . skyReflectionMipmap ) ;
cmd . SetViewport ( new Rect ( x , y , overlaySize , overlaySize ) ) ;
// End
if ( ! m_Asset . renderingSettings . ShouldUseForwardRenderingOnly ( ) )
{
m_gbufferManager . InitGBuffers ( w , h , cmd ) ;
}
m_GbufferManager . InitGBuffers ( w , h , cmd ) ;
CoreUtils . SetRenderTarget ( cmd , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . Depth ) ;
}
}
if ( m_VolumetricLightingEnabled )
{
}
// TEMP: As we are in development and have not all the setup pass we still clear the color in emissive buffer and gbuffer, but this will be removed later.
{
using ( new ProfilingSample ( cmd , "Clear GBuffer" ) )
{
CoreUtils . SetRenderTarget ( cmd , m_g bufferManager . GetGBuffers ( ) , m_CameraDepthStencilBufferRT , ClearFlag . Color , Color . black ) ;
CoreUtils . SetRenderTarget ( cmd , m_G bufferManager . GetGBuffers ( ) , m_CameraDepthStencilBufferRT , ClearFlag . Color , Color . black ) ;
}
}
// END TEMP