} ;
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_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 ;
Material m_currentDebugViewMaterialGBuffer ;
Material m_DebugDisplayLatlong ;
Material m_DebugFullScreen ;
Material m_DebugColorPicker ;
Material m_Blit ;
Material m_ErrorMaterial ;
RenderTargetIdentifier m_CameraStencilBufferCopyRT ;
// The pass "SRPDefaultUnlit" is a fall back to legacy unlit rendering and is required to support unity 2d + unity UI that render in the scene.
ShaderPassName [ ] m_ForwardAndForwardOnlyPassNames = { new ShaderPassName ( ) , new ShaderPassName ( ) , HDShaderPassNames . s_SRPDefaultUnlitName } ;
ShaderPassName [ ] m_ForwardOnlyPassNames = { new ShaderPassName ( ) , HDShaderPassNames . s_SRPDefaultUnlitName } ;
ShaderPassName [ ] m_ForwardAndForwardOnlyPassNames = { new ShaderPassName ( ) , new ShaderPassName ( ) , HDShaderPassNames . s_SRPDefaultUnlitName } ;
ShaderPassName [ ] m_ForwardOnlyPassNames = { new ShaderPassName ( ) , HDShaderPassNames . s_SRPDefaultUnlitName } ;
ShaderPassName [ ] m_AllTransparentPassNames = { HDShaderPassNames . s_TransparentBackfaceName ,
HDShaderPassNames . s_ForwardOnlyName ,
[Flags]
public enum StencilBitMask
{
Clear = 0 , // 0x0
LightingMask = 7 , // 0x7 - 3 bit
ObjectVelocity = 1 2 8 , // 0x80 - 1 bit
All = 2 5 5 // 0xFF - 8 bit
Clear = 0 , // 0x0
LightingMask = 7 , // 0x7 - 3 bit
ObjectVelocity = 1 2 8 , // 0x80 - 1 bit
All = 2 5 5 // 0xFF - 8 bit
}
RenderStateBlock m_DepthStateOpaque ;
FrameSettings m_FrameSettings ; // Init every frame
// For debug
int m_DebugColorPickerRT ;
int m_DebugFullScreenTempRT ;
bool m_FullScreenDebugPushed ;
// whereas it work. Don't know what is happening, DebugDisplay use the same code and name is correct there.
// Debug.Assert(m_DeferredMaterial != null);
m_CameraColorBuffer = HDShaderIDs . _CameraColorTexture ;
m_CameraColorBufferRT = new RenderTargetIdentifier ( m_CameraColorBuffer ) ;
m_CameraSssDiffuseLightingBuffer = HDShaderIDs . _CameraSssDiffuseLightingBuffer ;
m_CameraColorBuffer = HDShaderIDs . _CameraColorTexture ;
m_CameraColorBufferRT = new RenderTargetIdentifier ( m_CameraColorBuffer ) ;
m_CameraSssDiffuseLightingBuffer = HDShaderIDs . _CameraSssDiffuseLightingBuffer ;
m_CameraSssDiffuseLightingBufferRT = new RenderTargetIdentifier ( m_CameraSssDiffuseLightingBuffer ) ;
m_SSSBufferManager . Build ( asset ) ;
m_DebugDisplaySettings . RegisterDebug ( ) ;
FrameSettings . RegisterDebug ( "Default Camera" , m_Asset . GetFrameSettings ( ) ) ;
m_DebugColorPickerRT = HDShaderIDs . _DebugColorPickerTexture ;
m_DebugFullScreenTempRT = HDShaderIDs . _DebugFullScreenTexture ;
// For debugging
m_DebugViewMaterialGBufferShadowMask . EnableKeyword ( "SHADOWS_SHADOWMASK" ) ;
m_DebugDisplayLatlong = CoreUtils . CreateEngineMaterial ( m_Asset . renderPipelineResources . debugDisplayLatlongShader ) ;
m_DebugFullScreen = CoreUtils . CreateEngineMaterial ( m_Asset . renderPipelineResources . debugFullScreenShader ) ;
m_DebugColorPicker = CoreUtils . CreateEngineMaterial ( m_Asset . renderPipelineResources . debugColorPickerShader ) ;
m_Blit = CoreUtils . CreateEngineMaterial ( m_Asset . renderPipelineResources . blit ) ;
m_ErrorMaterial = CoreUtils . CreateEngineMaterial ( "Hidden/InternalErrorShader" ) ;
}
CoreUtils . Destroy ( m_DebugViewMaterialGBufferShadowMask ) ;
CoreUtils . Destroy ( m_DebugDisplayLatlong ) ;
CoreUtils . Destroy ( m_DebugFullScreen ) ;
CoreUtils . Destroy ( m_DebugColorPicker ) ;
CoreUtils . Destroy ( m_Blit ) ;
CoreUtils . Destroy ( m_ErrorMaterial ) ;
{
// For now we consider only PS4 to be able to read from a bound depth buffer.
// TODO: test/implement for other platforms.
return SystemInfo . graphicsDeviceType ! = GraphicsDeviceType . PlayStation4 & &
return SystemInfo . graphicsDeviceType ! = GraphicsDeviceType . PlayStation4 & &
SystemInfo . graphicsDeviceType ! = GraphicsDeviceType . XboxOne & &
SystemInfo . graphicsDeviceType ! = GraphicsDeviceType . XboxOneD3D12 ;
}
using ( new ProfilingSample ( cmd , "Volume Update" , CustomSamplerId . VolumeUpdate . GetSampler ( ) ) )
{
LayerMask layerMask = - 1 ;
if ( additionalCameraData ! = null )
if ( additionalCameraData ! = null )
{
layerMask = additionalCameraData . volumeLayerMask ;
}
// This is arbitrary and should be editable in the scene view somehow.
if ( camera . cameraType = = CameraType . SceneView )
if ( camera . cameraType = = CameraType . SceneView )
{
layerMask = ( - 1 & ~ m_Asset . renderPipelineSettings . lightLoopSettings . skyLightingOverrideLayerMask ) ;
}
continue ;
}
m_LightLoop . UpdateCullingParameters ( ref cullingParams ) ;
m_LightLoop . UpdateCullingParameters ( ref cullingParams ) ;
#if UNITY_EDITOR
// emit scene view UI
}
#endif
// decal system needs to be updated with current camera
if ( m_FrameSettings . enableDBuffer )
DecalSystem . instance . BeginCull ( camera ) ;
if ( m_FrameSettings . enableDBuffer )
DecalSystem . instance . BeginCull ( camera ) ;
CullResults . Cull ( ref cullingParams , renderContext , ref m_CullResults ) ;
CullResults . Cull ( ref cullingParams , renderContext , ref m_CullResults ) ;
}
m_DbufferManager . vsibleDecalCount = 0 ;
}
ConfigureForShadowMask ( enableBakeShadowMask , cmd ) ;
InitAndClearBuffer ( hdCamera , enableBakeShadowMask , cmd ) ;
InitAndClearBuffer ( hdCamera , enableBakeShadowMask , cmd ) ;
bool forcePrepassForDecals = m_DbufferManager . vsibleDecalCount > 0 ;
RenderDepthPrepass ( m_CullResults , hdCamera , renderContext , cmd , forcePrepassForDecals ) ;
if ( m_CurrentDebugDisplaySettings . IsDebugMaterialDisplayEnabled ( ) )
{
RenderDebugViewMaterial ( m_CullResults , hdCamera , renderContext , cmd ) ;
PushColorPickerDebugTexture ( cmd , m_CameraColorBufferRT , hdCamera ) ;
}
else
{
cmd . ReleaseTemporaryRT ( m_DeferredShadowBuffer ) ;
CoreUtils . CreateCmdTemporaryRT ( cmd , m_DeferredShadowBuffer , hdCamera . renderTextureDesc , 0 , FilterMode . Point , RenderTextureFormat . ARGB32 , RenderTextureReadWrite . Linear , 1 , true ) ;
m_LightLoop . RenderDeferredDirectionalShadow ( hdCamera , m_DeferredShadowBufferRT , GetDepthTexture ( ) , cmd ) ;
PushFullScreenDebugTexture ( cmd , m_DeferredShadowBuffer , hdCamera , renderContext , FullScreenDebugMode . DeferredShadows ) ;
PushFullScreenDebugTexture ( cmd , m_DeferredShadowBuffer , hdCamera , FullScreenDebugMode . DeferredShadows ) ;
// TODO: Move this code inside LightLoop
// TODO: Move this code inside LightLoop
if ( m_LightLoop . GetFeatureVariantsEnabled ( ) )
{
// For material classification we use compute shader and so can't read into the stencil, so prepare it.
RenderForward ( m_CullResults , hdCamera , renderContext , cmd , ForwardPass . PreRefraction ) ;
RenderForwardError ( m_CullResults , camera , renderContext , cmd , ForwardPass . PreRefraction ) ;
RenderGaussianPyramidColor ( camera , cmd , renderContext , FullScreenDebugMode . PreRefractionColorPyramid ) ;
RenderGaussianPyramidColor ( camera , cmd , renderContext , true ) ;
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
RenderForward ( m_CullResults , hdCamera , renderContext , cmd , ForwardPass . Transparent ) ;
RenderTransparentDepthPostpass ( m_CullResults , camera , renderContext , cmd , ForwardPass . Transparent ) ;
PushFullScreenDebugTexture ( cmd , m_CameraColorBuffer , hdCamera , renderContext , FullScreenDebugMode . NanTracker ) ;
PushFullScreenDebugTexture ( cmd , m_CameraColorBuffer , hdCamera , renderContext , FullScreenDebugMode . HDRBuffer ) ;
PushFullScreenDebugTexture ( cmd , m_CameraColorBuffer , hdCamera , renderContext , FullScreenDebugMode . LuxMeterBuffer ) ;
PushFullScreenDebugTexture ( cmd , m_CameraColorBuffer , hdCamera , FullScreenDebugMode . NanTracker ) ;
RenderGaussianPyramidColor ( camera , cmd , renderContext , FullScreenDebugMode . FinalColorPyramid ) ;
RenderGaussianPyramidColor ( camera , cmd , renderContext , false ) ;
PushColorPickerDebugTexture ( cmd , m_CameraColorBufferRT , hdCamera ) ;
// Final blit
if ( m_FrameSettings . enablePostprocess & & CoreUtils . IsPostProcessingActive ( postProcessLayer ) )
} // For each camera
}
void RenderOpaqueRenderList ( CullResults cull ,
Camera camera ,
void RenderOpaqueRenderList ( CullResults cull ,
Camera camera ,
CommandBuffer cmd ,
ShaderPassName passName ,
RendererConfiguration rendererConfiguration = 0 ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
CommandBuffer cmd ,
ShaderPassName passName ,
RendererConfiguration rendererConfiguration = 0 ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
void RenderOpaqueRenderList ( CullResults cull ,
Camera camera ,
void RenderOpaqueRenderList ( CullResults cull ,
Camera camera ,
CommandBuffer cmd ,
ShaderPassName [ ] passNames ,
RendererConfiguration rendererConfiguration = 0 ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
CommandBuffer cmd ,
ShaderPassName [ ] passNames ,
RendererConfiguration rendererConfiguration = 0 ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
{
if ( ! m_FrameSettings . enableOpaqueObjects )
return ;
renderQueueRange = inRenderQueueRange = = null ? RenderQueueRange . opaque : inRenderQueueRange . Value
} ;
if ( stateBlock = = null )
if ( stateBlock = = null )
void RenderTransparentRenderList ( CullResults cull ,
Camera camera ,
void RenderTransparentRenderList ( CullResults cull ,
Camera camera ,
CommandBuffer cmd ,
ShaderPassName passName ,
RendererConfiguration rendererConfiguration = 0 ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
CommandBuffer cmd ,
ShaderPassName passName ,
RendererConfiguration rendererConfiguration = 0 ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null )
{
m_SinglePassName [ 0 ] = passName ;
RenderTransparentRenderList ( cull , camera , renderContext , cmd , m_SinglePassName ,
void RenderTransparentRenderList ( CullResults cull ,
Camera camera ,
void RenderTransparentRenderList ( CullResults cull ,
Camera camera ,
CommandBuffer cmd ,
ShaderPassName [ ] passNames ,
RendererConfiguration rendererConfiguration = 0 ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null
CommandBuffer cmd ,
ShaderPassName [ ] passNames ,
RendererConfiguration rendererConfiguration = 0 ,
RenderQueueRange ? inRenderQueueRange = null ,
RenderStateBlock ? stateBlock = null ,
Material overrideMaterial = null
)
{
if ( ! m_FrameSettings . enableTransparentObjects )
renderQueueRange = inRenderQueueRange = = null ? k_RenderQueue_AllTransparent : inRenderQueueRange . Value
} ;
if ( stateBlock = = null )
if ( stateBlock = = null )
renderContext . DrawRenderers ( cull . visibleRenderers , ref drawSettings , filterSettings ) ;
else
renderContext . DrawRenderers ( cull . visibleRenderers , ref drawSettings , filterSettings , stateBlock . Value ) ;
using ( new ProfilingSample ( cmd , addAlphaTestedOnly ? "Depth Prepass alpha test" : "Depth Prepass" , CustomSamplerId . DepthPrepass . GetSampler ( ) ) )
{
CoreUtils . SetRenderTarget ( cmd , m_CameraDepthStencilBufferRT ) ;
if ( forcePrepass | | ( addFullDepthPrepass & & ! addAlphaTestedOnly ) ) // Always true in case of forward rendering, use in case of deferred rendering if requesting a full depth prepass
if ( forcePrepass | | ( addFullDepthPrepass & & ! addAlphaTestedOnly ) ) // Always true in case of forward rendering, use in case of deferred rendering if requesting a full depth prepass
{
// We render first the opaque object as opaque alpha tested are more costly to render and could be reject by early-z (but not Hi-z as it is disable with clip instruction)
// This is handled automatically with the RenderQueue value (OpaqueAlphaTested have a different value and thus are sorted after Opaque)
{
if ( m_FrameSettings . enableDepthPrepassWithDeferredRendering )
{
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 } ;
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 , m_currentRendererConfigurationBakedLighting , rangeOpaqueNoAlphaTest , m_FrameSettings . enableAlphaTestOnlyInDeferredPrepass ? m_DepthStateOpaque : m_DepthStateOpaqueWithPrepass ) ;
cmd . SetGlobalTexture ( HDShaderIDs . _MainDepthTexture , GetDepthTexture ( ) ) ;
CoreUtils . SetRenderTarget ( cmd , m_DbufferManager . GetDBuffers ( ) , m_CameraDepthStencilBufferRT , ClearFlag . Color , CoreUtils . clearColorAllBlack ) ;
DecalSystem . instance . Render ( renderContext , camera , cmd ) ;
DecalSystem . instance . Render ( renderContext , camera , cmd ) ;
}
}
CoreUtils . CreateCmdTemporaryRT ( cmd , HDShaderIDs . _AmbientOcclusionTexture , hdCamera . renderTextureDesc , 0 , FilterMode . Bilinear , RenderTextureFormat . R8 , RenderTextureReadWrite . Linear , msaaSamples : 1 , enableRandomWrite : true ) ;
postProcessLayer . BakeMSVOMap ( cmd , camera , HDShaderIDs . _AmbientOcclusionTexture , GetDepthTexture ( ) , true ) ;
cmd . SetGlobalVector ( HDShaderIDs . _AmbientOcclusionParam , new Vector4 ( settings . color . value . r , settings . color . value . g , settings . color . value . b , settings . directLightingStrength . value ) ) ;
PushFullScreenDebugTexture ( cmd , HDShaderIDs . _AmbientOcclusionTexture , hdCamera , renderContext , FullScreenDebugMode . SSAO ) ;
PushFullScreenDebugTexture ( cmd , HDShaderIDs . _AmbientOcclusionTexture , hdCamera , FullScreenDebugMode . SSAO ) ;
return ;
}
}
void UpdateSkyEnvironment ( HDCamera hdCamera , CommandBuffer cmd )
{
m_SkyManager . UpdateEnvironment ( hdCamera , m_LightLoop . GetCurrentSunLight ( ) , cmd ) ;
m_SkyManager . UpdateEnvironment ( hdCamera , m_LightLoop . GetCurrentSunLight ( ) , cmd ) ;
}
void RenderSky ( HDCamera hdCamera , CommandBuffer cmd )
CoreUtils . DrawFullScreen ( cmd , m_CameraMotionVectorsMaterial , m_VelocityBufferRT , m_CameraDepthStencilBufferRT , null , 0 ) ;
PushFullScreenDebugTexture ( cmd , m_VelocityBuffer , hdcamera , renderContext , FullScreenDebugMode . MotionVectors ) ;
PushFullScreenDebugTexture ( cmd , m_VelocityBuffer , hdcamera , FullScreenDebugMode . MotionVectors ) ;
void RenderGaussianPyramidColor ( Camera camera , CommandBuffer cmd , ScriptableRenderContext renderContext , FullScreenDebugMode debugMode )
void RenderGaussianPyramidColor ( Camera camera , CommandBuffer cmd , ScriptableRenderContext renderContext , bool isPreRefraction )
if ( debugMode = = FullScreenDebugMode . PreRefractionColorPyramid )
if ( isPreRefraction )
else if ( debugMode = = FullScreenDebugMode . FinalColorPyramid )
else
{
// TODO: This final Gaussian pyramid can be reuse by Bloom and SSR in the future, so disable it only if there is no postprocess AND no distortion
if ( ! m_FrameSettings . enableDistortion & & ! m_FrameSettings . enablePostprocess & & ! m_FrameSettings . enableSSR )
var colorPyramidDesc = m_GaussianPyramidColorBufferDesc ;
var pyramidSideSize = GetPyramidSize ( colorPyramidDesc ) ;
// The g aussian pyramid compute works in blocks of 8x8 so make sure the last lod has a
// The G aussian pyramid compute works in blocks of 8x8 so make sure the last lod has a
// minimum size of 8x8
int lodCount = Mathf . FloorToInt ( Mathf . Log ( pyramidSideSize , 2f ) - 3f ) ;
if ( lodCount > HDShaderIDs . _GaussianPyramidColorMips . Length )
last = HDShaderIDs . _GaussianPyramidColorMips [ i + 1 ] ;
}
PushFullScreenDebugTextureMip ( cmd , m_GaussianPyramidColorBufferRT , lodCount , m_GaussianPyramidColorBufferDesc , debugMode ) ;
PushFullScreenDebugTextureMip ( cmd , m_GaussianPyramidColorBufferRT , lodCount , m_GaussianPyramidColorBufferDesc , isPreRefraction ? FullScreenDebugMo de. PreRefractionColorPyramid : FullScreenDe bugMode. FinalColorPyramid ) ;
cmd . SetGlobalTexture ( HDShaderIDs . _GaussianPyramidColorTexture , m_GaussianPyramidColorBuffer ) ;
{
using ( new ProfilingSample ( cmd , "Post-processing" , CustomSamplerId . PostProcessing . GetSampler ( ) ) )
{
// Note: Here we don't use GetDepthTexture() to get the depth texture but m_CameraDepthStencilBuffer as the Forward transparent pass can
// write extra data to deal with DOF/MB
cmd . SetGlobalTexture ( HDShaderIDs . _CameraDepthTexture , m_CameraDepthStencilBuffer ) ;
cmd . SetGlobalTexture ( HDShaderIDs . _CameraMotionVectorsTexture , m_VelocityBufferRT ) ;
// Note: Here we don't use GetDepthTexture() to get the depth texture but m_CameraDepthStencilBuffer as the Forward transparent pass can
// write extra data to deal with DOF/MB
cmd . SetGlobalTexture ( HDShaderIDs . _CameraDepthTexture , m_CameraDepthStencilBuffer ) ;
cmd . SetGlobalTexture ( HDShaderIDs . _CameraMotionVectorsTexture , m_VelocityBufferRT ) ;
var context = hdcamera . postprocessRenderContext ;
context . Reset ( ) ;
context . source = m_CameraColorBufferRT ;
context . destination = BuiltinRenderTextureType . CameraTarget ;
context . command = cmd ;
context . camera = hdcamera . camera ;
context . sourceFormat = RenderTextureFormat . ARGBHalf ;
context . flip = true ;
var context = hdcamera . postprocessRenderContext ;
context . Reset ( ) ;
context . source = m_CameraColorBufferRT ;
context . destination = BuiltinRenderTextureType . CameraTarget ;
context . command = cmd ;
context . camera = hdcamera . camera ;
context . sourceFormat = RenderTextureFormat . ARGBHalf ;
context . flip = true ;
layer . Render ( context ) ;
}
layer . Render ( context ) ;
}
public void ApplyDebugDisplaySettings ( HDCamera hdCamera , CommandBuffer cmd )
{
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 ) ;
var luxMeterParam = new Vector4 ( lightingDebugSettings . kLuxMeterThreshold0Debug , lightingDebugSettings . kLuxMeterThreshold1Debug , lightingDebugSettings . kLuxMeterThreshold2Debug , lightingDebugSettings . kLuxMeterThreshold3Debug ) ;
cmd . SetGlobalVector ( HDShaderIDs . _DebugLuxMeterParam , luxMeterParam ) ;
cmd . SetGlobalVector ( HDShaderIDs . _DebugLightingSmoothness , debugSmoothness ) ;
Vector2 mousePixelCoord = MousePositionDebug . instance . GetMousePosition ( hdCamera . screenSize . y ) ;
cmd . SetGlobalTexture ( HDShaderIDs . _DebugFont , m_Asset . renderPipelineResources . debugFontTexture ) ;
}
public void PushFullScreenDebugTexture ( CommandBuffer cb , RenderTargetIdentifier textureID , HDCamera hdCamera , ScriptableRenderContext renderContext , FullScreenDebugMode debugMode )
public void PushColorPickerDebugTexture ( CommandBuffer cmd , RenderTargetIdentifier textureID , HDCamera hdCamera )
{
if ( m_CurrentDebugDisplaySettings . colorPickerDebugSettings . colorPickerMode ! = ColorPickerDebugMode . None )
{
cmd . ReleaseTemporaryRT ( m_DebugColorPickerRT ) ;
CoreUtils . CreateCmdTemporaryRT ( cmd , m_DebugColorPickerRT , hdCamera . renderTextureDesc , 0 , FilterMode . Point , RenderTextureFormat . ARGBHalf , RenderTextureReadWrite . Linear ) ;
cmd . Blit ( textureID , m_DebugColorPickerRT ) ;
}
}
public void PushFullScreenDebugTexture ( CommandBuffer cmd , RenderTargetIdentifier textureID , HDCamera hdCamera , FullScreenDebugMode debugMode )
m_FullScreenDebugPushed = true ; // We need this flag because otherwise if no fullscreen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
cb . ReleaseTemporaryRT ( m_DebugFullScreenTempRT ) ;
CoreUtils . CreateCmdTemporaryRT ( cb , m_DebugFullScreenTempRT , hdCamera . renderTextureDesc , 0 , FilterMode . Point , RenderTextureFormat . ARGBHalf , RenderTextureReadWrite . Linear ) ;
cb . Blit ( textureID , m_DebugFullScreenTempRT ) ;
m_FullScreenDebugPushed = true ; // We need this flag because otherwise if no full screen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
cmd . ReleaseTemporaryRT ( m_DebugFullScreenTempRT ) ;
CoreUtils . CreateCmdTemporaryRT ( cmd , m_DebugFullScreenTempRT , hdCamera . renderTextureDesc , 0 , FilterMode . Point , RenderTextureFormat . ARGBHalf , RenderTextureReadWrite . Linear ) ;
cmd . Blit ( textureID , m_DebugFullScreenTempRT ) ;
var mipIndex = Mathf . FloorToInt ( m_CurrentDebugDisplaySettings . fullscreenDebugMip * ( lodCount ) ) ;
m_FullScreenDebugPushed = true ; // We need this flag because otherwise if no fullscreen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
var mipIndex = Mathf . FloorToInt ( m_CurrentDebugDisplaySettings . fullscreenDebugMip * ( lodCount ) ) ;
m_FullScreenDebugPushed = true ; // We need this flag because otherwise if no full screen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
cmd . ReleaseTemporaryRT ( m_DebugFullScreenTempRT ) ;
desc . width = desc . width > > mipIndex ;
}
void PushFullScreenDebugDepthMip ( CommandBuffer cmd , RenderTargetIdentifier textureID , int lodCount , RenderTextureDescriptor desc , FullScreenDebugMode debugMode )
{
var mipIndex = Mathf . FloorToInt ( m_CurrentDebugDisplaySettings . fullscreenDebugMip * ( lodCount ) ) ;
{
var mipIndex = Mathf . FloorToInt ( m_CurrentDebugDisplaySettings . fullscreenDebugMip * ( lodCount ) ) ;
m_FullScreenDebugPushed = true ; // We need this flag because otherwise if no fullscreen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
cmd . ReleaseTemporaryRT ( m_DebugFullScreenTempRT ) ;
}
}
public void PushFullScreenDebugTexture ( CommandBuffer cb , int textureID , HDCamera hdCamera , ScriptableRenderContext renderContext , FullScreenDebugMode debugMode )
public void PushFullScreenDebugTexture ( CommandBuffer cb , int textureID , HDCamera hdCamera , FullScreenDebugMode debugMode )
PushFullScreenDebugTexture ( cb , new RenderTargetIdentifier ( textureID ) , hdCamera , renderContext , debugMode ) ;
PushFullScreenDebugTexture ( cb , new RenderTargetIdentifier ( textureID ) , hdCamera , debugMode ) ;
void RenderDebug ( HDCamera c amera, CommandBuffer cmd )
void RenderDebug ( HDCamera hdC amera, CommandBuffer cmd )
if ( c amera. camera . cameraType = = CameraType . Reflection | | c amera. camera . cameraType = = CameraType . Preview )
if ( hdC amera. camera . cameraType = = CameraType . Reflection | | hdC amera. camera . cameraType = = CameraType . Preview )
return ;
using ( new ProfilingSample ( cmd , "Render Debug" , CustomSamplerId . RenderDebug . GetSampler ( ) ) )
{
m_FullScreenDebugPushed = false ;
cmd . SetGlobalTexture ( HDShaderIDs . _DebugFullScreenTexture , m_DebugFullScreenTempRT ) ;
// TODO: Replace with command buffer call when available
PushColorPickerDebugTexture ( cmd , m_DebugFullScreenTempRT , hdCamera ) ;
float overlaySize = Math . Min ( camera . camera . pixelHeight , camera . camera . pixelWidth ) * overlayRatio ;
float y = camera . camera . pixelHeight - overlaySize ;
float overlaySize = Math . Min ( hdCamera . camera . pixelHeight , hdCamera . camera . pixelWidth ) * overlayRatio ;
float y = hdCamera . camera . pixelHeight - overlaySize ;
var lightingDebug = m_CurrentDebugDisplaySettings . lightingDebugSettings ;
m_SharedPropertyBlock . SetFloat ( HDShaderIDs . _Mipmap , lightingDebug . skyReflectionMipmap ) ;
cmd . SetViewport ( new Rect ( x , y , overlaySize , overlaySize ) ) ;
cmd . DrawProcedural ( Matrix4x4 . identity , m_DebugDisplayLatlong , 0 , MeshTopology . Triangles , 3 , 1 , m_SharedPropertyBlock ) ;
HDUtils . NextOverlayCoord ( ref x , ref y , overlaySize , overlaySize , camera . camera . pixelWidth ) ;
HDUtils . NextOverlayCoord ( ref x , ref y , overlaySize , overlaySize , hdCamera . camera . pixelWidth ) ;
m_LightLoop . RenderDebugOverlay ( camera , cmd , m_CurrentDebugDisplaySettings , ref x , ref y , overlaySize , camera . camera . pixelWidth ) ;
m_LightLoop . RenderDebugOverlay ( hdCamera , cmd , m_CurrentDebugDisplaySettings , ref x , ref y , overlaySize , hdCamera . camera . pixelWidth ) ;
if ( m_CurrentDebugDisplaySettings . colorPickerDebugSettings . colorPickerMode ! = ColorPickerDebugMode . None )
{
ColorPickerDebugSettings colorPickerDebugSettings = m_CurrentDebugDisplaySettings . colorPickerDebugSettings ;
// Here we have three cases:
// - Material debug is enabled, this is the buffer we display
// - Otherwise we display the HDR buffer before postprocess and distortion
// - If fullscreen debug is enabled we always use it
cmd . SetGlobalTexture ( HDShaderIDs . _DebugColorPickerTexture , m_DebugColorPickerRT ) ; // No SetTexture with RenderTarget identifier... so use SetGlobalTexture
// TODO: Replace with command buffer call when available
m_DebugColorPicker . SetColor ( HDShaderIDs . _ColorPickerFontColor , colorPickerDebugSettings . fontColor ) ;
var colorPickerParam = new Vector4 ( colorPickerDebugSettings . colorThreshold0 , colorPickerDebugSettings . colorThreshold1 , colorPickerDebugSettings . colorThreshold2 , colorPickerDebugSettings . colorThreshold3 ) ;
m_DebugColorPicker . SetVector ( HDShaderIDs . _ColorPickerParam , colorPickerParam ) ;
m_DebugColorPicker . SetInt ( HDShaderIDs . _ColorPickerMode , ( int ) colorPickerDebugSettings . colorPickerMode ) ;
CoreUtils . DrawFullScreen ( cmd , m_DebugColorPicker , ( RenderTargetIdentifier ) BuiltinRenderTextureType . CameraTarget ) ;
}
}
}