// not used during a frame.
public class HDCamera
{
public readonly Camera camera ;
public Matrix4x4 viewMatrix ;
public Matrix4x4 projMatrix ;
public Vector4 screenSize ;
public Camera camera ;
public Vector4 screenSize { get ; private set ; }
public Matrix4x4 viewProjectionMatrix { get ; private set ; }
public Matrix4x4 prevViewProjectionMatrix { get ; private set ; }
public Matrix4x4 invViewProjectionMatrix { get ; private set ; }
public Matrix4x4 invProjectionMatrix { get ; private set ; }
public Vector4 invProjectionParam { get ; private set ; }
public Matrix4x4 viewProjMatrix
{
get { return projMatrix * viewMatrix ; }
}
public Vector4 invProjParam
{
// Ref: An Efficient Depth Linearization Method for Oblique View Frustums, Eq. 6.
get { var p = projMatrix ; return new Vector4 ( p . m20 / ( p . m00 * p . m23 ) , p . m21 / ( p . m11 * p . m23 ) , - 1.0f / p . m23 , ( - p . m22 + p . m20 * p . m02 / p . m00 + p . m21 * p . m12 / p . m11 ) / p . m23 ) ; }
}
// View-projection matrix from the previous frame.
public Matrix4x4 prevViewProjMatrix ;
// The only way to reliably keep track of a frame change right now is to compare the frame
// count Unity gives us. We need this as a single camera could be rendered several times per
public void Update ( )
{
screenSize = new Vector4 ( camera . pixelWidth , camera . pixelHeight , 1.0f / camera . pixelWidth , 1.0f / camera . pixelHeight ) ;
var gpuProj = GL . GetGPUProjectionMatrix ( camera . projectionMatrix , false ) ;
var gpuProj = GL . GetGPUProjectionMatrix ( camera . projectionMatrix , true ) ; // Had to change this from 'false'
prevViewProjectionMatrix = ! m_FirstFrame
? viewProjectionMatrix
prevViewProjMatrix = ! m_FirstFrame
? viewProjMatrix
// Ref: An Efficient Depth Linearization Method for Oblique View Frustums, Eq. 6.
var invProjParam = new Vector4 (
gpuProj . m20 / ( gpuProj . m00 * gpuProj . m23 ) ,
gpuProj . m21 / ( gpuProj . m11 * gpuProj . m23 ) ,
- 1.0f / gpuProj . m23 ,
( - gpuProj . m22
+ gpuProj . m20 * gpuProj . m02 / gpuProj . m00
+ gpuProj . m21 * gpuProj . m12 / gpuProj . m11 ) / gpuProj . m23
) ;
viewProjectionMatrix = gpuVP ;
invViewProjectionMatrix = gpuVP . inverse ;
invProjectionMatrix = gpuProj . inverse ;
invProjectionParam = invProjParam ;
viewMatrix = camera . worldToCameraMatrix ;
projMatrix = gpuProj ;
screenSize = new Vector4 ( camera . pixelWidth , camera . pixelHeight , 1.0f / camera . pixelWidth , 1.0f / camera . pixelHeight ) ;
public void SetupMaterial ( Material material )
{
material . SetVector ( "_ScreenSize" , screenSize ) ;
material . SetMatrix ( "_ViewProjMatrix" , viewProjectionMatrix ) ;
material . SetMatrix ( "_PrevViewProjMatrix" , prevViewProjectionMatrix ) ;
material . SetMatrix ( "_InvViewProjMatrix" , invViewProjectionMatrix ) ;
material . SetMatrix ( "_InvProjMatrix" , invProjectionMatrix ) ;
material . SetVector ( "_InvProjParam" , invProjectionParam ) ;
}
public void Reset ( )
{
m_LastFrameActive = - 1 ;
m_Cameras . Remove ( cam ) ;
m_Cleanup . Clear ( ) ;
}
public void SetupGlobalParams ( CommandBuffer cmd )
{
cmd . SetGlobalMatrix ( "_ViewMatrix" , viewMatrix ) ;
cmd . SetGlobalMatrix ( "_InvViewMatrix" , viewMatrix . inverse ) ;
cmd . SetGlobalMatrix ( "_ProjMatrix" , projMatrix ) ;
cmd . SetGlobalMatrix ( "_InvProjMatrix" , projMatrix . inverse ) ;
cmd . SetGlobalMatrix ( "_ViewProjMatrix" , viewProjMatrix ) ;
cmd . SetGlobalMatrix ( "_InvViewProjMatrix" , viewProjMatrix . inverse ) ;
cmd . SetGlobalVector ( "_InvProjParam" , invProjParam ) ;
cmd . SetGlobalVector ( "_ScreenSize" , screenSize ) ;
cmd . SetGlobalMatrix ( "_PrevViewProjMatrix" , prevViewProjMatrix ) ;
}
// Does not modify global settings. Used for shadows, low res. rendering, etc.
public void OverrideGlobalParams ( Material material )
{
material . SetMatrix ( "_ViewMatrix" , viewMatrix ) ;
material . SetMatrix ( "_InvViewMatrix" , viewMatrix . inverse ) ;
material . SetMatrix ( "_ProjMatrix" , projMatrix ) ;
material . SetMatrix ( "_InvProjMatrix" , projMatrix . inverse ) ;
material . SetMatrix ( "_ViewProjMatrix" , viewProjMatrix ) ;
material . SetMatrix ( "_InvViewProjMatrix" , viewProjMatrix . inverse ) ;
material . SetVector ( "_InvProjParam" , invProjParam ) ;
material . SetVector ( "_ScreenSize" , screenSize ) ;
material . SetMatrix ( "_PrevViewProjMatrix" , prevViewProjMatrix ) ;
}
public void SetupComputeShader ( ComputeShader cs , CommandBuffer cmd )
{
cmd . SetComputeMatrixParam ( cs , "_ViewMatrix" , viewMatrix ) ;
cmd . SetComputeMatrixParam ( cs , "_InvViewMatrix" , viewMatrix . inverse ) ;
cmd . SetComputeMatrixParam ( cs , "_ProjMatrix" , projMatrix ) ;
cmd . SetComputeMatrixParam ( cs , "_InvProjMatrix" , projMatrix . inverse ) ;
cmd . SetComputeMatrixParam ( cs , "_ViewProjMatrix" , viewProjMatrix ) ;
cmd . SetComputeMatrixParam ( cs , "_InvViewProjMatrix" , viewProjMatrix . inverse ) ;
cmd . SetComputeVectorParam ( cs , "_InvProjParam" , invProjParam ) ;
cmd . SetComputeVectorParam ( cs , "_ScreenSize" , screenSize ) ;
cmd . SetComputeMatrixParam ( cs , "_PrevViewProjMatrix" , prevViewProjMatrix ) ;
}
}
m_CurrentHeight = camera . pixelHeight ;
}
public void PushGlobalParams ( HDCamera hdCamera , ScriptableRenderContext renderContext , SubsurfaceScatteringSettings sssParameters )
public void PushGlobalParams ( HDCamera hdCamera , CommandBuffer cmd , SubsurfaceScatteringSettings sssParameters )
var cmd = CommandBufferPool . Get ( "Push Global Parameters" ) ;
using ( new Utilities . ProfilingSample ( "Push Global Parameters" , cmd ) )
{
hdCamera . SetupGlobalParams ( cmd ) ;
cmd . SetGlobalVector ( "_ScreenSize" , hdCamera . screenSize ) ;
cmd . SetGlobalMatrix ( "_ViewProjMatrix" , hdCamera . viewProjectionMatrix ) ;
cmd . SetGlobalMatrix ( "_PrevViewProjMatrix" , hdCamera . prevViewProjectionMatrix ) ;
cmd . SetGlobalMatrix ( "_InvViewProjMatrix" , hdCamera . invViewProjectionMatrix ) ;
cmd . SetGlobalMatrix ( "_InvProjMatrix" , hdCamera . invProjectionMatrix ) ;
cmd . SetGlobalVector ( "_InvProjParam" , hdCamera . invProjectionParam ) ;
// TODO: cmd.SetGlobalInt() does not exist, so we are forced to use Shader.SetGlobalInt() instead.
// TODO: cmd.SetGlobalInt() does not exist, so we are forced to use Shader.SetGlobalInt() instead.
if ( m_SkyManager . IsSkyValid ( ) )
{
m_SkyManager . SetGlobalSkyTexture ( ) ;
Shader . SetGlobalInt ( "_EnvLightSkyEnabled" , 1 ) ;
}
else
{
Shader . SetGlobalInt ( "_EnvLightSkyEnabled" , 0 ) ;
}
if ( m_SkyManager . IsSkyValid ( ) )
{
m_SkyManager . SetGlobalSkyTexture ( ) ;
Shader . SetGlobalInt ( "_EnvLightSkyEnabled" , 1 ) ;
}
else
{
Shader . SetGlobalInt ( "_EnvLightSkyEnabled" , 0 ) ;
// Broadcast SSS parameters to all shaders.
Shader . SetGlobalInt ( "_EnableSSSAndTransmission" , m_DebugDisplaySettings . renderingDebugSettings . enableSSSAndTransmission ? 1 : 0 ) ;
Shader . SetGlobalInt ( "_TexturingModeFlags" , ( int ) sssParameters . texturingModeFlags ) ;
Shader . SetGlobalInt ( "_TransmissionFlags" , ( int ) sssParameters . transmissionFlags ) ;
cmd . SetGlobalFloatArray ( "_ThicknessRemaps" , sssParameters . thicknessRemaps ) ;
// We are currently supporting two different SSS mode: Jimenez (with 2-Gaussian profile) and Disney
// We have added the ability to switch between each other for subsurface scattering, but for transmittance this is more tricky as we need to add
// shader variant for forward, gbuffer and deferred shader. We want to avoid this.
// So for transmittance we use Disney profile formulation (that we know is more correct) in both case, and in the case of Jimenez we hack the parameters with 2-Gaussian parameters (Ideally we should fit but haven't find good fit) so it approximately match.
// Note: Jimenez SSS is in cm unit whereas Disney is in mm unit making an inconsistency here to compare model side by side
cmd . SetGlobalVectorArray ( "_ShapeParams" , sssParameters . useDisneySSS ? sssParameters . shapeParams : sssParameters . halfRcpWeightedVariances ) ;
cmd . SetGlobalVectorArray ( "_TransmissionTints" , sssParameters . transmissionTints ) ;
// Broadcast SSS parameters to all shaders.
Shader . SetGlobalInt ( "_EnableSSSAndTransmission" , m_DebugDisplaySettings . renderingDebugSettings . enableSSSAndTransmission ? 1 : 0 ) ;
Shader . SetGlobalInt ( "_TexturingModeFlags" , ( int ) sssParameters . texturingModeFlags ) ;
Shader . SetGlobalInt ( "_TransmissionFlags" , ( int ) sssParameters . transmissionFlags ) ;
cmd . SetGlobalFloatArray ( "_ThicknessRemaps" , sssParameters . thicknessRemaps ) ;
// We are currently supporting two different SSS mode: Jimenez (with 2-Gaussian profile) and Disney
// We have added the ability to switch between each other for subsurface scattering, but for transmittance this is more tricky as we need to add
// shader variant for forward, gbuffer and deferred shader. We want to avoid this.
// So for transmittance we use Disney profile formulation (that we know is more correct) in both case, and in the case of Jimenez we hack the parameters with 2-Gaussian parameters (Ideally we should fit but haven't find good fit) so it approximately match.
// Note: Jimenez SSS is in cm unit whereas Disney is in mm unit making an inconsistency here to compare model side by side
cmd . SetGlobalVectorArray ( "_ShapeParams" , sssParameters . useDisneySSS ? sssParameters . shapeParams : sssParameters . halfRcpWeightedVariances ) ;
cmd . SetGlobalVectorArray ( "_TransmissionTints" , sssParameters . transmissionTints ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
}
bool NeedDepthBufferCopy ( )
return m_CameraDepthStencilBuffer ;
}
private void CopyDepthBufferIfNeeded ( ScriptableRenderContext renderContext )
private void CopyDepthBufferIfNeeded ( CommandBuffer cmd )
var cmd = CommandBufferPool . Get ( NeedDepthBufferCopy ( ) ? "Copy DepthBuffer" : "Set DepthBuffer" ) ;
if ( NeedDepthBufferCopy ( ) )
using ( new Utilities . ProfilingSample ( NeedDepthBufferCopy ( ) ? "Copy DepthBuffer" : "Set DepthBuffer" , cmd ) )
using ( new Utilities . ProfilingSample ( "Copy depth-stencil buffer" , renderContext ) )
if ( NeedDepthBufferCopy ( ) )
cmd . CopyTexture ( m_CameraDepthStencilBufferRT , m_CameraDepthStencilBufferCopyRT ) ;
using ( new Utilities . ProfilingSample ( "Copy depth-stencil buffer" , cmd ) )
{
cmd . CopyTexture ( m_CameraDepthStencilBufferRT , m_CameraDepthStencilBufferCopyRT ) ;
}
cmd . SetGlobalTexture ( "_MainDepthTexture" , GetDepthTexture ( ) ) ;
cmd . SetGlobalTexture ( "_MainDepthTexture" , GetDepthTexture ( ) ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
}
public void UpdateCommonSettings ( )
GraphicsSettings . lightsUseLinearIntensity = true ;
GraphicsSettings . lightsUseColorTemperature = true ;
m_MaterialList . ForEach ( material = > material . RenderInit ( renderContext ) ) ;
// This is the main command buffer used for the frame.
CommandBuffer cmd = CommandBufferPool . Get ( "" ) ;
m_MaterialList . ForEach ( material = > material . RenderInit ( cmd ) ) ;
// Do anything we need to do upon a new frame.
m_LightLoop . NewFrame ( ) ;
// TODO: Add another path dedicated to planar reflection / real time cubemap that implement simpler lighting
string passName = "Forward" ; // It is up to the users to only send unlit object for this camera path
using ( new Utilities . ProfilingSample ( passName , renderContext ) )
using ( new Utilities . ProfilingSample ( passName , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor | ClearFlag . ClearDepth ) ;
RenderOpaqueRenderList ( m_CullResults , camera , renderContext , passName ) ;
RenderTransparentRenderList ( m_CullResults , camera , renderContext , passName ) ;
Utilities . SetRenderTarget ( cmd , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor | ClearFlag . ClearDepth ) ;
RenderOpaqueRenderList ( m_CullResults , camera , renderContext , cmd , passName ) ;
RenderTransparentRenderList ( m_CullResults , camera , renderContext , cmd , passName ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
InitAndClearBuffer ( camera , renderContext ) ;
InitAndClearBuffer ( camera , cmd ) ;
PushGlobalParams ( hdCamera , renderContext , m_Asset . sssSettings ) ;
PushGlobalParams ( hdCamera , cmd , m_Asset . sssSettings ) ;
RenderDepthPrepass ( m_CullResults , camera , renderContext ) ;
RenderDepthPrepass ( m_CullResults , camera , renderContext , cmd ) ;
RenderForwardOnlyOpaqueDepthPrepass ( m_CullResults , camera , renderContext ) ;
RenderGBuffer ( m_CullResults , camera , renderContext ) ;
RenderForwardOnlyOpaqueDepthPrepass ( m_CullResults , camera , renderContext , cmd ) ;
RenderGBuffer ( m_CullResults , camera , renderContext , cmd ) ;
CopyDepthBufferIfNeeded ( renderContext ) ;
CopyDepthBufferIfNeeded ( cmd ) ;
RenderDebugViewMaterial ( m_CullResults , hdCamera , renderContext ) ;
RenderDebugViewMaterial ( m_CullResults , hdCamera , renderContext , cmd ) ;
using ( new Utilities . ProfilingSample ( "Build Light list and render shadows" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Build Light list and render shadows" , cmd ) )
m_LightLoop . RenderShadows ( renderContext , m_CullResults ) ;
m_LightLoop . RenderShadows ( renderContext , cmd , m_CullResults ) ;
m_LightLoop . BuildGPULightLists ( camera , renderContext , m_CameraDepthStencilBufferRT ) ;
m_LightLoop . BuildGPULightLists ( camera , cmd , m_CameraDepthStencilBufferRT ) ;
UpdateSkyEnvironment ( hdCamera , renderContext ) ;
UpdateSkyEnvironment ( hdCamera , cmd ) ;
RenderDeferredLighting ( hdCamera , renderContext ) ;
RenderDeferredLighting ( hdCamera , cmd ) ;
CombineSubsurfaceScattering ( hdCamera , renderContext , m_Asset . sssSettings ) ;
CombineSubsurfaceScattering ( hdCamera , cmd , m_Asset . sssSettings ) ;
RenderForward ( m_CullResults , camera , renderContext , true ) ; // Render deferred or forward opaque
RenderForwardOnlyOpaque ( m_CullResults , camera , renderContext ) ;
RenderForward ( m_CullResults , camera , renderContext , cmd , true ) ; // Render deferred or forward opaque
RenderForwardOnlyOpaque ( m_CullResults , camera , renderContext , cmd ) ;
RenderLightingDebug ( hdCamera , renderContext , m_CameraColorBufferRT ) ;
RenderLightingDebug ( hdCamera , cmd , m_CameraColorBufferRT ) ;
CopyDepthBufferIfNeeded ( renderContext ) ;
CopyDepthBufferIfNeeded ( cmd ) ;
RenderSky ( hdCamera , renderContext ) ;
RenderSky ( hdCamera , cmd ) ;
RenderForward ( m_CullResults , camera , renderContext , false ) ;
RenderForward ( m_CullResults , camera , renderContext , cmd , false ) ;
// Simple blit
var cmd = CommandBufferPool . Get ( "Blit to final RT" ) ;
cmd . Blit ( m_CameraColorBufferRT , BuiltinRenderTextureType . CameraTarget ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
using ( new Utilities . ProfilingSample ( "Blit to final RT" , cmd ) )
{
// Simple blit
cmd . Blit ( m_CameraColorBufferRT , BuiltinRenderTextureType . CameraTarget ) ;
}
RenderVelocity ( m_CullResults , hdCamera , 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_CullResults , hdCamera , renderContext , cmd ) ; // 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 ( m_CullResults , camera , renderContext ) ;
RenderDistortion ( m_CullResults , camera , renderContext , cmd ) ;
RenderPostProcesses ( camera , renderContext ) ;
RenderPostProcesses ( camera , cmd ) ;
RenderDebug ( hdCamera , renderContext ) ;
RenderDebug ( hdCamera , cmd ) ;
var cmd = CommandBufferPool . Get ( ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
void RenderOpaqueRenderList ( CullResults cull , Camera camera , ScriptableRenderContext renderContext , string passName , RendererConfiguration rendererConfiguration = 0 )
void RenderOpaqueRenderList ( CullResults cull , Camera camera , ScriptableRenderContext renderContext , CommandBuffer cmd , string passName , RendererConfiguration rendererConfiguration = 0 )
// This is done here because DrawRenderers API lives outside command buffers so we need to make sur eto call this before doing any DrawRenders
renderContext . ExecuteCommandBuffer ( cmd ) ;
cmd . Clear ( ) ;
var settings = new DrawRendererSettings ( cull , camera , new ShaderPassName ( passName ) )
{
rendererConfiguration = rendererConfiguration ,
renderContext . DrawRenderers ( ref settings ) ;
}
void RenderTransparentRenderList ( CullResults cull , Camera camera , ScriptableRenderContext renderContext , string passName , RendererConfiguration rendererConfiguration = 0 )
void RenderTransparentRenderList ( CullResults cull , Camera camera , ScriptableRenderContext renderContext , CommandBuffer cmd , string passName , RendererConfiguration rendererConfiguration = 0 )
// This is done here because DrawRenderers API lives outside command buffers so we need to make sur eto call this before doing any DrawRenders
renderContext . ExecuteCommandBuffer ( cmd ) ;
cmd . Clear ( ) ;
var settings = new DrawRendererSettings ( cull , camera , new ShaderPassName ( passName ) )
{
rendererConfiguration = rendererConfiguration ,
renderContext . DrawRenderers ( ref settings ) ;
}
void RenderDepthPrepass ( CullResults cull , Camera camera , ScriptableRenderContext renderContext )
void RenderDepthPrepass ( CullResults cull , Camera camera , ScriptableRenderContext renderContext , CommandBuffer cmd )
{
// If we are forward only we will do a depth prepass
// TODO: Depth prepass should be enabled based on light loop settings. LightLoop define if they need a depth prepass + forward only...
using ( new Utilities . ProfilingSample ( "Depth Prepass" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Depth Prepass" , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_CameraDepthStencilBufferRT ) ;
RenderOpaqueRenderList ( cull , camera , renderContext , "DepthOnly" ) ;
Utilities . SetRenderTarget ( cmd , m_CameraDepthStencilBufferRT ) ;
RenderOpaqueRenderList ( cull , camera , renderContext , cmd , "DepthOnly" ) ;
void RenderGBuffer ( CullResults cull , Camera camera , ScriptableRenderContext renderContext )
void RenderGBuffer ( CullResults cull , Camera camera , ScriptableRenderContext renderContext , CommandBuffer cmd )
{
if ( m_Asset . renderingSettings . ShouldUseForwardRenderingOnly ( ) )
{
string passName = m_DebugDisplaySettings . IsDebugDisplayEnabled ( ) ? "GBufferDebugDisplay" : "GBuffer" ;
using ( new Utilities . ProfilingSample ( passName , renderContext ) )
using ( new Utilities . ProfilingSample ( passName , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_gbufferManager . GetGBuffers ( ) , m_CameraDepthStencilBufferRT ) ;
Utilities . SetRenderTarget ( cmd , m_gbufferManager . GetGBuffers ( ) , m_CameraDepthStencilBufferRT ) ;
RenderOpaqueRenderList ( cull , camera , renderContext , passName , Utilities . kRendererConfigurationBakedLighting ) ;
RenderOpaqueRenderList ( cull , camera , renderContext , cmd , passName , Utilities . kRendererConfigurationBakedLighting ) ;
void RenderForwardOnlyOpaqueDepthPrepass ( CullResults cull , Camera camera , ScriptableRenderContext renderContext )
void RenderForwardOnlyOpaqueDepthPrepass ( CullResults cull , Camera camera , ScriptableRenderContext renderContext , CommandBuffer cmd )
{
// If we are forward only we don't need to render ForwardOnlyOpaqueDepthOnly object
// But in case we request a prepass we render it
using ( new Utilities . ProfilingSample ( "Forward opaque depth" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Forward opaque depth" , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_CameraDepthStencilBufferRT ) ;
RenderOpaqueRenderList ( cull , camera , renderContext , "ForwardOnlyOpaqueDepthOnly" ) ;
Utilities . SetRenderTarget ( cmd , m_CameraDepthStencilBufferRT ) ;
RenderOpaqueRenderList ( cull , camera , renderContext , cmd , "ForwardOnlyOpaqueDepthOnly" ) ;
void RenderDebugViewMaterial ( CullResults cull , HDCamera hdCamera , ScriptableRenderContext renderContext )
void RenderDebugViewMaterial ( CullResults cull , HDCamera hdCamera , ScriptableRenderContext renderContext , CommandBuffer cmd )
using ( new Utilities . ProfilingSample ( "DisplayDebug ViewMaterial" , renderContext ) )
using ( new Utilities . ProfilingSample ( "DisplayDebug ViewMaterial" , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , Utilities . kClearAll , Color . black ) ;
RenderOpaqueRenderList ( cull , hdCamera . camera , renderContext , "ForwardDisplayDebug" , Utilities . kRendererConfigurationBakedLighting ) ;
Utilities . SetRenderTarget ( cmd , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , Utilities . kClearAll , Color . black ) ;
RenderOpaqueRenderList ( cull , hdCamera . camera , renderContext , cmd , "ForwardDisplayDebug" , Utilities . kRendererConfigurationBakedLighting ) ;
hdCamera . SetupMaterial ( m_DebugViewMaterialGBuffer ) ;
// TODO: Bind depth textures
var cmd = CommandBufferPool . Get ( "DebugViewMaterialGBuffer" ) ;
cmd . Blit ( null , m_CameraColorBufferRT , m_DebugViewMaterialGBuffer , 0 ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
using ( new Utilities . ProfilingSample ( "DebugViewMaterialGBuffer" , cmd ) )
{
// TODO: Bind depth textures
cmd . Blit ( null , m_CameraColorBufferRT , m_DebugViewMaterialGBuffer , 0 ) ;
}
RenderTransparentRenderList ( cull , hdCamera . camera , renderContext , "ForwardDisplayDebug" , Utilities . kRendererConfigurationBakedLighting ) ;
RenderTransparentRenderList ( cull , hdCamera . camera , renderContext , cmd , "ForwardDisplayDebug" , Utilities . kRendererConfigurationBakedLighting ) ;
var cmd = CommandBufferPool . Get ( "Blit DebugView Material Debug" ) ;
cmd . Blit ( m_CameraColorBufferRT , BuiltinRenderTextureType . CameraTarget ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
using ( new Utilities . ProfilingSample ( "Blit DebugView Material Debug" , cmd ) )
{
cmd . Blit ( m_CameraColorBufferRT , BuiltinRenderTextureType . CameraTarget ) ;
}
void RenderDeferredLighting ( HDCamera hdCamera , ScriptableRenderContext renderContext )
void RenderDeferredLighting ( HDCamera hdCamera , CommandBuffer cmd )
{
if ( m_Asset . renderingSettings . ShouldUseForwardRenderingOnly ( ) )
{
if ( m_DebugDisplaySettings . renderingDebugSettings . enableSSSAndTransmission )
{
// Output split lighting for materials asking for it (via stencil buffer)
m_LightLoop . RenderDeferredLighting ( hdCamera , renderContext , m_DebugDisplaySettings , colorRTs , m_CameraDepthStencilBufferRT , new RenderTargetIdentifier ( GetDepthTexture ( ) ) , true ) ;
m_LightLoop . RenderDeferredLighting ( hdCamera , cmd , m_DebugDisplaySettings , colorRTs , m_CameraDepthStencilBufferRT , new RenderTargetIdentifier ( GetDepthTexture ( ) ) , true ) ;
m_LightLoop . RenderDeferredLighting ( hdCamera , renderContext , m_DebugDisplaySettings , colorRTs , m_CameraDepthStencilBufferRT , new RenderTargetIdentifier ( GetDepthTexture ( ) ) , false ) ;
m_LightLoop . RenderDeferredLighting ( hdCamera , cmd , m_DebugDisplaySettings , colorRTs , m_CameraDepthStencilBufferRT , new RenderTargetIdentifier ( GetDepthTexture ( ) ) , false ) ;
void CombineSubsurfaceScattering ( HDCamera hdCamera , ScriptableRenderContext context , SubsurfaceScatteringSettings sssParameters )
void CombineSubsurfaceScattering ( HDCamera hdCamera , CommandBuffer cmd , SubsurfaceScatteringSettings sssParameters )
var cmd = CommandBufferPool . Get ( "Subsurface Scattering" ) ;
if ( sssSettings . useDisneySSS )
using ( new Utilities . ProfilingSample ( "Subsurface Scattering" , cmd ) )
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraSubsurfaceBufferRT ) ; // Cannot set a RT on a material
// Temp >>>
Matrix4x4 viewMatrix = hdCamera . camera . worldToCameraMatrix ;
viewMatrix . SetRow ( 2 , - viewMatrix . GetRow ( 2 ) ) ; // Make Z axis point forwards in the view space (left-handed CS)
Matrix4x4 projMatrix = GL . GetGPUProjectionMatrix ( hdCamera . camera . projectionMatrix , false ) ;
projMatrix . SetColumn ( 2 , - projMatrix . GetColumn ( 2 ) ) ; // Undo the view-space transformation
m_FilterAndCombineSubsurfaceScattering . SetMatrix ( "_ViewMatrix" , viewMatrix ) ;
m_FilterAndCombineSubsurfaceScattering . SetMatrix ( "_ProjMatrix" , projMatrix ) ;
// <<< Temp
m_FilterAndCombineSubsurfaceScattering . SetFloatArray ( "_WorldScales" , sssParameters . worldScales ) ;
m_FilterAndCombineSubsurfaceScattering . SetFloatArray ( "_FilterKernelsNearField" , sssParameters . filterKernelsNearField ) ;
m_FilterAndCombineSubsurfaceScattering . SetFloatArray ( "_FilterKernelsFarField" , sssParameters . filterKernelsFarField ) ;
if ( sssSettings . useDisneySSS )
{
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraSubsurfaceBufferRT ) ; // 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 ) ;
Utilities . DrawFullScreen ( cmd , m_FilterAndCombineSubsurfaceScattering , hdCamera , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
}
else
{
// Perform the vertical SSS filtering pass.
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraSubsurfaceBufferRT ) ; // 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 , hdCamera , m_CameraFilteringBufferRT , m_CameraDepthStencilBufferRT ) ;
Utilities . DrawFullScreen ( cmd , m_FilterAndCombineSubsurfaceScattering , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
}
else
{
// Perform the vertical SSS filtering pass.
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraSubsurfaceBufferRT ) ; // 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 ) ;
// Perform the horizontal SSS filtering pass, and combine diffuse and specular lighting.
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraFilteringBufferRT ) ; // Cannot set a RT on a material
m_FilterAndCombineSubsurfaceScattering . SetFloatArray ( "_WorldScales" , sssParameters . worldScales ) ;
m_FilterAndCombineSubsurfaceScattering . SetVectorArray ( "_FilterKernelsBasic" , sssParameters . filterKernelsBasic ) ;
m_FilterAndCombineSubsurfaceScattering . SetVectorArray ( "_HalfRcpWeightedVariances" , sssParameters . halfRcpWeightedVariances ) ;
Utilities . DrawFullScreen ( cmd , m_FilterAndCombineSubsurfaceScattering , hdCamera , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
// Perform the horizontal SSS filtering pass, and combine diffuse and specular lighting.
cmd . SetGlobalTexture ( "_IrradianceSource" , m_CameraFilteringBufferRT ) ; // Cannot set a RT on a material
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 ) ;
}
context . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
void UpdateSkyEnvironment ( HDCamera hdCamera , ScriptableRenderContext renderContext )
void UpdateSkyEnvironment ( HDCamera hdCamera , CommandBuffer cmd )
m_SkyManager . UpdateEnvironment ( hdCamera , m_LightLoop . GetCurrentSunLight ( ) , renderContext ) ;
m_SkyManager . UpdateEnvironment ( hdCamera , m_LightLoop . GetCurrentSunLight ( ) , cmd ) ;
void RenderSky ( HDCamera hdCamera , ScriptableRenderContext renderContext )
void RenderSky ( HDCamera hdCamera , CommandBuffer cmd )
m_SkyManager . RenderSky ( hdCamera , m_LightLoop . GetCurrentSunLight ( ) , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , renderContext ) ;
m_SkyManager . RenderSky ( hdCamera , m_LightLoop . GetCurrentSunLight ( ) , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , cmd ) ;
}
public Texture2D ExportSkyToTexture ( )
void RenderLightingDebug ( HDCamera camera , ScriptableRenderContext renderContext , RenderTargetIdentifier colorBuffer )
void RenderLightingDebug ( HDCamera camera , CommandBuffer cmd , RenderTargetIdentifier colorBuffer )
m_LightLoop . RenderLightingDebug ( camera , renderContext , colorBuffer ) ;
m_LightLoop . RenderLightingDebug ( camera , cmd , colorBuffer ) ;
void RenderForward ( CullResults cullResults , Camera camera , ScriptableRenderContext renderContext , bool renderOpaque )
void RenderForward ( CullResults cullResults , Camera camera , ScriptableRenderContext renderContext , CommandBuffer cmd , bool renderOpaque )
{
// TODO: Currently we can't render opaque object forward when deferred is enabled
// miss option
string passName = m_DebugDisplaySettings . IsDebugDisplayEnabled ( ) ? "ForwardDisplayDebug" : "Forward" ;
using ( new Utilities . ProfilingSample ( passName , renderContext ) )
using ( new Utilities . ProfilingSample ( passName , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
Utilities . SetRenderTarget ( cmd , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
m_LightLoop . RenderForward ( camera , renderContext , renderOpaque ) ;
m_LightLoop . RenderForward ( camera , cmd , renderOpaque ) ;
RenderOpaqueRenderList ( cullResults , camera , renderContext , passName , Utilities . kRendererConfigurationBakedLighting ) ;
RenderOpaqueRenderList ( cullResults , camera , renderContext , cmd , passName , Utilities . kRendererConfigurationBakedLighting ) ;
RenderTransparentRenderList ( cullResults , camera , renderContext , passName , Utilities . kRendererConfigurationBakedLighting ) ;
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , passName , Utilities . kRendererConfigurationBakedLighting ) ;
void RenderForwardOnlyOpaque ( CullResults cullResults , Camera camera , ScriptableRenderContext renderContext )
void RenderForwardOnlyOpaque ( CullResults cullResults , Camera camera , ScriptableRenderContext renderContext , CommandBuffer cmd )
using ( new Utilities . ProfilingSample ( passName , renderContext ) )
using ( new Utilities . ProfilingSample ( passName , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
Utilities . SetRenderTarget ( cmd , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT ) ;
m_LightLoop . RenderForward ( camera , renderContext , true ) ;
m_LightLoop . RenderForward ( camera , cmd , true ) ;
RenderOpaqueRenderList ( cullResults , camera , renderContext , passName , Utilities . kRendererConfigurationBakedLighting ) ;
RenderOpaqueRenderList ( cullResults , camera , renderContext , cmd , passName , Utilities . kRendererConfigurationBakedLighting ) ;
void RenderVelocity ( CullResults cullResults , HDCamera hdcam , ScriptableRenderContext renderContext )
void RenderVelocity ( CullResults cullResults , HDCamera hdcam , ScriptableRenderContext renderContext , CommandBuffer cmd )
using ( new Utilities . ProfilingSample ( "Velocity" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Velocity" , cmd ) )
{
// If opaque velocity have been render during GBuffer no need to render it here
if ( ( ShaderConfig . s_VelocityInGbuffer = = 1 ) | | m_Asset . renderingSettings . ShouldUseForwardRenderingOnly ( ) )
int w = ( int ) hdcam . screenSize . x ;
int h = ( int ) hdcam . screenSize . y ;
var cmd = CommandBufferPool . Get ( "" ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
RenderOpaqueRenderList ( cullResults , hdcam . camera , renderContext , "MotionVectors" , RendererConfiguration . PerObjectMotionVectors ) ;
RenderOpaqueRenderList ( cullResults , hdcam . camera , renderContext , cmd , "MotionVectors" , RendererConfiguration . PerObjectMotionVectors ) ;
void RenderDistortion ( CullResults cullResults , Camera camera , ScriptableRenderContext renderContext )
void RenderDistortion ( CullResults cullResults , Camera camera , ScriptableRenderContext renderContext , CommandBuffer cmd )
using ( new Utilities . ProfilingSample ( "Distortion" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Distortion" , cmd ) )
var cmd = CommandBufferPool . Get ( "" ) ;
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
RenderTransparentRenderList ( cullResults , camera , renderContext , "DistortionVectors" ) ;
RenderTransparentRenderList ( cullResults , camera , renderContext , cmd , "DistortionVectors" ) ;
void RenderPostProcesses ( Camera camera , ScriptableRenderContext renderContext )
void RenderPostProcesses ( Camera camera , CommandBuffer cmd )
using ( new Utilities . ProfilingSample ( "Post-processing" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Post-processing" , cmd ) )
var cmd = CommandBufferPool . Get ( "" ) ;
if ( postProcessLayer ! = null & & postProcessLayer . enabled )
{
{
cmd . Blit ( m_CameraColorBufferRT , BuiltinRenderTextureType . CameraTarget ) ;
}
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
}
}
}
MaterialPropertyBlock m_SharedPropertyBlock = new MaterialPropertyBlock ( ) ;
void RenderDebug ( HDCamera camera , ScriptableRenderContext renderContext )
void RenderDebug ( HDCamera camera , CommandBuffer cmd )
// We make sure the depth buffer is bound because we need it to write depth at near plane for overlays otherwise the editor grid end up visible in them.
Utilities . SetRenderTarget ( renderContext , BuiltinRenderTextureType . CameraTarget , m_CameraDepthStencilBufferRT ) ;
using ( new Utilities . ProfilingSample ( "Render Debug" , cmd ) )
{
// We make sure the depth buffer is bound because we need it to write depth at near plane for overlays otherwise the editor grid end up visible in them.
Utilities . SetRenderTarget ( cmd , BuiltinRenderTextureType . CameraTarget , m_CameraDepthStencilBufferRT ) ;
CommandBuffer debugCB = CommandBufferPool . Get ( ) ;
debugCB . name = "Render Debug" ;
// First render full screen debug texture
if ( m_DebugDisplaySettings . lightingDebugSettings . fullScreenDebugMode ! = FullScreenDebugMode . None & & m_FullScreenDebugPushed )
{
m_FullScreenDebugPushed = false ;
cmd . SetGlobalTexture ( "_DebugFullScreenTexture" , m_DebugFullScreenTempRT ) ;
m_DebugFullScreen . SetFloat ( "_FullScreenDebugMode" , ( float ) m_DebugDisplaySettings . lightingDebugSettings . fullScreenDebugMode ) ;
Utilities . DrawFullScreen ( cmd , m_DebugFullScreen , ( RenderTargetIdentifier ) BuiltinRenderTextureType . CameraTarget ) ;
}
// First render full screen debug texture
if ( m_DebugDisplaySettings . lightingDebugSettings . fullScreenDebugMode ! = FullScreenDebugMode . None & & m_FullScreenDebugPushed )
{
m_FullScreenDebugPushed = false ;
debugCB . SetGlobalTexture ( "_DebugFullScreenTexture" , m_DebugFullScreenTempRT ) ;
m_DebugFullScreen . SetFloat ( "_FullScreenDebugMode" , ( float ) m_DebugDisplaySettings . lightingDebugSettings . fullScreenDebugMode ) ;
Utilities . DrawFullScreen ( debugCB , m_DebugFullScreen , camera , BuiltinRenderTextureType . CameraTarget ) ;
}
// Then overlays
float x = 0 ;
float overlayRatio = m_DebugDisplaySettings . debugOverlayRatio ;
float overlaySize = Math . Min ( camera . camera . pixelHeight , camera . camera . pixelWidth ) * overlayRatio ;
float y = camera . camera . pixelHeight - overlaySize ;
// Then overlays
float x = 0 ;
float overlayRatio = m_DebugDisplaySettings . debugOverlayRatio ;
float overlaySize = Math . Min ( camera . camera . pixelHeight , camera . camera . pixelWidth ) * overlayRatio ;
float y = camera . camera . pixelHeight - overlaySize ;
LightingDebugSettings lightingDebug = m_DebugDisplaySettings . lightingDebugSettings ;
LightingDebugSettings lightingDebug = m_DebugDisplaySettings . lightingDebugSettings ;
if ( lightingDebug . displaySkyReflection )
{
Texture skyReflection = m_SkyManager . skyReflection ;
m_SharedPropertyBlock . SetTexture ( "_InputCubemap" , skyReflection ) ;
m_SharedPropertyBlock . SetFloat ( "_Mipmap" , lightingDebug . skyReflectionMipmap ) ;
cmd . SetViewport ( new Rect ( x , y , overlaySize , overlaySize ) ) ;
cmd . DrawProcedural ( Matrix4x4 . identity , m_DebugDisplayLatlong , 0 , MeshTopology . Triangles , 3 , 1 , m_SharedPropertyBlock ) ;
Utilities . NextOverlayCoord ( ref x , ref y , overlaySize , overlaySize , camera . camera . pixelWidth ) ;
}
if ( lightingDebug . displaySkyReflection )
{
Texture skyReflection = m_SkyManager . skyReflection ;
m_SharedPropertyBlock . SetTexture ( "_InputCubemap" , skyReflection ) ;
m_SharedPropertyBlock . SetFloat ( "_Mipmap" , lightingDebug . skyReflectionMipmap ) ;
debugCB . SetViewport ( new Rect ( x , y , overlaySize , overlaySize ) ) ;
debugCB . DrawProcedural ( Matrix4x4 . identity , m_DebugDisplayLatlong , 0 , MeshTopology . Triangles , 3 , 1 , m_SharedPropertyBlock ) ;
Utilities . NextOverlayCoord ( ref x , ref y , overlaySize , overlaySize , camera . camera . pixelWidth ) ;
m_LightLoop . RenderDebugOverlay ( camera . camera , cmd , m_DebugDisplaySettings , ref x , ref y , overlaySize , camera . camera . pixelWidth ) ;
renderContext . ExecuteCommandBuffer ( debugCB ) ;
CommandBufferPool . Release ( debugCB ) ;
m_LightLoop . RenderDebugOverlay ( camera . camera , renderContext , m_DebugDisplaySettings , ref x , ref y , overlaySize , camera . camera . pixelWidth ) ;
void InitAndClearBuffer ( Camera camera , ScriptableRenderContext renderContext )
void InitAndClearBuffer ( Camera camera , CommandBuffer cmd )
using ( new Utilities . ProfilingSample ( "InitAndClearBuffer" , renderContext ) )
using ( new Utilities . ProfilingSample ( "InitAndClearBuffer" , cmd ) )
using ( new Utilities . ProfilingSample ( "InitGBuffers and clear Depth/Stencil" , renderContext ) )
using ( new Utilities . ProfilingSample ( "InitGBuffers and clear Depth/Stencil" , cmd ) )
var cmd = CommandBufferPool . Get ( ) ;
cmd . name = "" ;
// Init buffer
// With scriptable render loop we must allocate ourself depth and color buffer (We must be independent of backbuffer for now, hope to fix that later).
// Also we manage ourself the HDR format, here allocating fp16 directly.
m_gbufferManager . InitGBuffers ( w , h , cmd ) ;
}
renderContext . ExecuteCommandBuffer ( cmd ) ;
CommandBufferPool . Release ( cmd ) ;
Utilities . SetRenderTarget ( renderContext , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearDepth ) ;
Utilities . SetRenderTarget ( cmd , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearDepth ) ;
using ( new Utilities . ProfilingSample ( "Clear SSS diffuse target" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Clear SSS diffuse target" , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_CameraSubsurfaceBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
Utilities . SetRenderTarget ( cmd , m_CameraSubsurfaceBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
using ( new Utilities . ProfilingSample ( "Clear SSS filtering target" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Clear SSS filtering target" , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_CameraFilteringBuffer , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
Utilities . SetRenderTarget ( cmd , m_CameraFilteringBuffer , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
}
// <<< Old SSS Model
using ( new Utilities . ProfilingSample ( "Clear HDR target" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Clear HDR target" , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
Utilities . SetRenderTarget ( cmd , m_CameraColorBufferRT , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
using ( new Utilities . ProfilingSample ( "Clear GBuffer" , renderContext ) )
using ( new Utilities . ProfilingSample ( "Clear GBuffer" , cmd ) )
Utilities . SetRenderTarget ( renderContext , m_gbufferManager . GetGBuffers ( ) , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
Utilities . SetRenderTarget ( cmd , m_gbufferManager . GetGBuffers ( ) , m_CameraDepthStencilBufferRT , ClearFlag . ClearColor , Color . black ) ;
}
}
// END TEMP