public bool displayTransparentObjects = true ;
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 useDepthPrepass = false ;
public bool enableTonemap = true ;
public float exposure = 0 ;
// END TEMP
}
// TODO: Create an opaque and transparent list!
void RenderOpaqueNoLightingRenderList ( CullResults cull , Camera camera , RenderLoop renderLoop , string passName )
{
if ( ! debugParameters . displayOpaqueObjects )
return ;
var settings = new DrawRendererSettings ( cull , camera , new ShaderPassName ( passName ) )
{
rendererConfiguration = 0 ,
sorting = { sortOptions = SortOptions . SortByMaterialThenMesh }
} ;
settings . inputFilter . SetQueuesOpaque ( ) ;
renderLoop . DrawRenderers ( ref settings ) ;
}
DrawRendererSettings settings = new DrawRendererSettings ( cull , camera , new ShaderPassName ( passName ) ) ;
settings . sorting . sortOptions = SortOptions . SortByMaterialThenMesh ;
var settings = new DrawRendererSettings ( cull , camera , new ShaderPassName ( passName ) )
{
rendererConfiguration = RendererConfiguration . PerObjectLightProbe | RendererConfiguration . PerObjectReflectionProbes | RendererConfiguration . PerObjectLightmaps | RendererConfiguration . PerObjectLightProbeProxyVolume ,
sorting = { sortOptions = SortOptions . SortByMaterialThenMesh }
} ;
settings . rendererConfiguration = RendererConfiguration . PerObjectLightProbe | RendererConfiguration . PerObjectReflectionProbes | RendererConfiguration . PerObjectLightmaps | RendererConfiguration . PerObjectLightProbeProxyVolume ;
renderLoop . DrawRenderers ( ref settings ) ;
}
void RenderTransparentNoLightingRenderList ( CullResults cull , Camera camera , RenderLoop renderLoop , string passName )
{
if ( ! debugParameters . displayTransparentObjects )
return ;
var settings = new DrawRendererSettings ( cull , camera , new ShaderPassName ( passName ) )
{
rendererConfiguration = 0 ,
sorting = { sortOptions = SortOptions . BackToFront }
} ;
settings . inputFilter . SetQueuesTransparent ( ) ;
void RenderTransparentRenderList ( CullResults cull , Camera camera , RenderLoop renderLoop , string passName )
void RenderTransparentRenderList ( CullResults cull , Camera camera , RenderLoop renderLoop , string passName )
{
if ( ! debugParameters . displayTransparentObjects )
return ;
renderLoop . DrawRenderers ( ref settings ) ;
}
void RenderDepthPrepass ( CullResults cull , Camera camera , RenderLoop renderLoop )
{
// 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...
if ( ! debugParameters . useDepthPrepass )
return ;
// TODO: Must do opaque then alpha masked for performance!
// TODO: front to back for opaque and by materal for opaque tested when we split in two
var cmd = new CommandBuffer { name = "Depth Prepass" } ;
cmd . SetRenderTarget ( new RenderTargetIdentifier ( s_CameraDepthBuffer ) ) ;
renderLoop . ExecuteCommandBuffer ( cmd ) ;
cmd . Dispose ( ) ;
RenderOpaqueNoLightingRenderList ( cull , camera , renderLoop , "DepthOnly" ) ;
}
void RenderGBuffer ( CullResults cull , Camera camera , RenderLoop renderLoop )
{
if ( debugParameters . useForwardRenderingOnly )
// render opaque objects into GBuffer
RenderOpaqueRenderList ( cull , camera , renderLoop , "GBuffer" ) ;
}
// This pass is use in case of forward opaque and deferred rendering. We need to render forward objects before tile lighting pass
void RenderForwardOpaqueDepth ( CullResults cull , Camera camera , RenderLoop renderLoop )
{
// If we have render a depth prepass, no need for this pass
if ( debugParameters . useDepthPrepass )
return ;
// TODO: Use the render queue index to only send the forward opaque!
var cmd = new CommandBuffer { name = "Depth Prepass" } ;
cmd . SetRenderTarget ( new RenderTargetIdentifier ( s_CameraDepthBuffer ) ) ;
renderLoop . ExecuteCommandBuffer ( cmd ) ;
cmd . Dispose ( ) ;
RenderOpaqueNoLightingRenderList ( cull , camera , renderLoop , "DepthOnly" ) ;
}
void RenderDebugViewMaterial ( CullResults cull , Camera camera , RenderLoop renderLoop )
renderLoop . ExecuteCommandBuffer ( cmd ) ;
cmd . Dispose ( ) ;
RenderOpaqueRenderList ( cullResults , camera , renderLoop , "ForwardUnlit" ) ;
RenderTransparentRenderList ( cullResults , camera , renderLoop , "ForwardUnlit" ) ;
RenderOpaqueNoLighting RenderList ( cullResults , camera , renderLoop , "ForwardUnlit" ) ;
RenderTransparentNoLighting RenderList ( cullResults , camera , renderLoop , "ForwardUnlit" ) ;
}
void RenderVelocity ( CullResults cullResults , Camera camera , RenderLoop renderLoop )
renderLoop . ExecuteCommandBuffer ( cmd ) ;
cmd . Dispose ( ) ;
RenderOpaqueRenderList ( cullResults , camera , renderLoop , "MotionVectors" ) ;
RenderOpaqueNoLighting RenderList ( cullResults , camera , renderLoop , "MotionVectors" ) ;
#pragma warning restore 162, 429
}
cmd . Dispose ( ) ;
// Only transparent object can render distortion vectors
RenderTransparentRenderList ( cullResults , camera , renderLoop , "DistortionVectors" ) ;
RenderTransparentNoLighting RenderList ( cullResults , camera , renderLoop , "DistortionVectors" ) ;
}
InitAndClearBuffer ( camera , renderLoop ) ;
RenderDepthPrepass ( cullResults , camera , renderLoop ) ;
// For tile lighting with forward opaque
//RenderForwardOpaqueDepth(cullResults, camera, renderLoop);
if ( debugParameters . debugViewMaterial ! = 0 )
{