|
|
|
|
|
|
RenderTargetIdentifier[] m_ColorMRTs; |
|
|
|
RenderTargetIdentifier[] m_RTIDs = new RenderTargetIdentifier[k_MaxDbuffer]; |
|
|
|
|
|
|
|
RenderTexture m_HTile; |
|
|
|
RenderTargetIdentifier m_HTileRT; |
|
|
|
|
|
|
|
|
|
|
|
public void InitDBuffers(RenderTextureDescriptor rtDesc, CommandBuffer cmd) |
|
|
|
{ |
|
|
|
dbufferCount = Decal.GetMaterialDBufferCount(); |
|
|
|
|
|
|
return m_ColorMRTs; |
|
|
|
} |
|
|
|
|
|
|
|
public void ClearNormalTarget(Color clearColor, CommandBuffer cmd) |
|
|
|
public void ClearNormalTargetAndHTile(Color clearColor, CommandBuffer cmd) |
|
|
|
CoreUtils.SetRenderTarget(cmd, m_HTileRT, ClearFlag.Color, CoreUtils.clearColorAllBlack); |
|
|
|
public void SetHTile(int bindSlot, CommandBuffer cmd) |
|
|
|
{ |
|
|
|
cmd.SetRandomWriteTarget(bindSlot, m_HTile); |
|
|
|
} |
|
|
|
|
|
|
|
public void UnSetHTile(CommandBuffer cmd) |
|
|
|
{ |
|
|
|
cmd.ClearRandomWriteTargets(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void Resize(HDCamera camera) |
|
|
|
{ |
|
|
|
CoreUtils.ResizeHTile(ref m_HTile, ref m_HTileRT, camera.renderTextureDesc); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
if (resolutionChanged || m_CameraDepthStencilBuffer == null) |
|
|
|
{ |
|
|
|
CreateDepthStencilBuffer(hdCamera); |
|
|
|
if (m_FrameSettings.enableDBuffer) |
|
|
|
{ |
|
|
|
m_DbufferManager.Resize(hdCamera); |
|
|
|
} |
|
|
|
|
|
|
|
if (m_FrameSettings.enableSubsurfaceScattering) |
|
|
|
{ |
|
|
|
|
|
|
{ |
|
|
|
// setup GBuffer for rendering
|
|
|
|
CoreUtils.SetRenderTarget(cmd, m_GbufferManager.GetGBuffers(), m_CameraDepthStencilBufferRT); |
|
|
|
if (m_FrameSettings.enableDBuffer) |
|
|
|
{ |
|
|
|
m_DbufferManager.SetHTile(m_GbufferManager.gbufferCount, cmd); |
|
|
|
} |
|
|
|
|
|
|
|
// Render opaque objects into GBuffer
|
|
|
|
if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled()) |
|
|
|
|
|
|
RenderOpaqueRenderList(cull, camera, renderContext, cmd, HDShaderPassNames.s_GBufferName, m_currentRendererConfigurationBakedLighting, HDRenderQueue.k_RenderQueue_AllOpaque, m_DepthStateOpaque); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (m_FrameSettings.enableDBuffer) |
|
|
|
{ |
|
|
|
m_DbufferManager.UnSetHTile(cmd); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// we need to do a separate clear for normals, because they are cleared to a different color
|
|
|
|
Color clearColorNormal = new Color(0.5f, 0.5f, 0.5f, 1.0f); // for normals 0.5 is neutral
|
|
|
|
m_DbufferManager.ClearNormalTarget(clearColorNormal, cmd); |
|
|
|
m_DbufferManager.ClearNormalTargetAndHTile(clearColorNormal, cmd); |
|
|
|
m_DbufferManager.SetHTile(m_DbufferManager.dbufferCount, cmd); |
|
|
|
m_DbufferManager.UnSetHTile(cmd); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|