|
|
|
|
|
|
enum ForwardPass |
|
|
|
{ |
|
|
|
Opaque, |
|
|
|
PreTransparent, |
|
|
|
PreRefraction, |
|
|
|
static readonly RenderQueueRange k_RenderQueue_PreTransparent = new RenderQueueRange { min = (int)HDRenderQueue.GeometryLast + 1, max = (int)HDRenderQueue.PreTransparent }; |
|
|
|
static readonly RenderQueueRange k_RenderQueue_Transparent = new RenderQueueRange { min = (int)HDRenderQueue.PreTransparent + 1, max = 5000 }; |
|
|
|
static readonly RenderQueueRange k_RenderQueue_PreRefraction = new RenderQueueRange { min = (int)HDRenderQueue.GeometryLast + 1, max = (int)HDRenderQueue.PreRefraction }; |
|
|
|
static readonly RenderQueueRange k_RenderQueue_Transparent = new RenderQueueRange { min = (int)HDRenderQueue.PreRefraction + 1, max = 5000 }; |
|
|
|
|
|
|
|
readonly HDRenderPipelineAsset m_Asset; |
|
|
|
|
|
|
|
|
|
|
// Do a depth pre-pass for transparent objects that want it that will fill the depth buffer to reduce the overdraw (typical usage is hair rendering)
|
|
|
|
RenderTransparentDepthPrepass(m_CullResults, camera, renderContext, cmd); |
|
|
|
|
|
|
|
// Render pre transparent objects
|
|
|
|
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.PreTransparent); |
|
|
|
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.PreTransparent); |
|
|
|
// Render pre refraction objects
|
|
|
|
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction); |
|
|
|
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction); |
|
|
|
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.PreTransparentColorPyramid); |
|
|
|
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.PreRefractionColorPyramid); |
|
|
|
|
|
|
|
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
|
|
|
|
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent); |
|
|
|
|
|
|
RendererConfiguration rendererConfiguration = 0, |
|
|
|
RenderStateBlock? stateBlock = null, |
|
|
|
Material overrideMaterial = null, |
|
|
|
bool preTransparentQueue = false) |
|
|
|
bool preRefractionQueue = false) |
|
|
|
rendererConfiguration, stateBlock, overrideMaterial, preTransparentQueue); |
|
|
|
rendererConfiguration, stateBlock, overrideMaterial, preRefractionQueue); |
|
|
|
} |
|
|
|
|
|
|
|
void RenderTransparentRenderList(CullResults cull, |
|
|
|
|
|
|
RendererConfiguration rendererConfiguration = 0, |
|
|
|
RenderStateBlock? stateBlock = null, |
|
|
|
Material overrideMaterial = null, |
|
|
|
bool preTransparentQueue = false) |
|
|
|
bool preRefractionQueue = false) |
|
|
|
{ |
|
|
|
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.displayTransparentObjects) |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
var filterSettings = new FilterRenderersSettings(true) |
|
|
|
{ |
|
|
|
renderQueueRange = preTransparentQueue |
|
|
|
? k_RenderQueue_PreTransparent |
|
|
|
renderQueueRange = preRefractionQueue |
|
|
|
? k_RenderQueue_PreRefraction |
|
|
|
: k_RenderQueue_Transparent |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
cmd.ClearRenderTarget(false, true, Color.clear); |
|
|
|
|
|
|
|
// Only transparent object can render distortion vectors
|
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, preTransparentQueue:true); |
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, preRefractionQueue:true); |
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_ForwardAndForwardOnlyPassNames, HDUtils.k_RendererConfigurationBakedLighting, preTransparentQueue: pass == ForwardPass.PreTransparent); |
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_ForwardAndForwardOnlyPassNames, HDUtils.k_RendererConfigurationBakedLighting, preRefractionQueue: pass == ForwardPass.PreRefraction); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
using (new ProfilingSample(cmd,"Forward Transparent Depth Prepass")) |
|
|
|
{ |
|
|
|
CoreUtils.SetRenderTarget(cmd, m_CameraDepthStencilBufferRT); |
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_TransparentDepthPrepassName, preTransparentQueue: true); |
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_TransparentDepthPrepassName, preTransparentQueue: false); |
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_TransparentDepthPrepassName, preRefractionQueue: true); |
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_TransparentDepthPrepassName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_ForwardErrorPassNames, 0, |
|
|
|
null, m_ErrorMaterial, pass == ForwardPass.PreTransparent); |
|
|
|
null, m_ErrorMaterial, pass == ForwardPass.PreRefraction); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|