|
|
|
|
|
|
cmd.GetTemporaryRT(s_GBufferZ, width, height, 24, FilterMode.Point, RenderTextureFormat.Depth); |
|
|
|
cmd.GetTemporaryRT(s_CameraDepthTexture, width, height, 24, FilterMode.Point, RenderTextureFormat.Depth); |
|
|
|
cmd.GetTemporaryRT(s_CameraTarget, width, height, 0, FilterMode.Point, formatHDR, RenderTextureReadWrite.Default, 1, true); // rtv/uav
|
|
|
|
|
|
|
|
|
|
|
|
var colorMRTs = new RenderTargetIdentifier[4] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_GBufferEmission }; |
|
|
|
cmd.SetRenderTarget(colorMRTs, new RenderTargetIdentifier(s_GBufferZ)); |
|
|
|
cmd.ClearRenderTarget(true, true, new Color(0, 0, 0, 0)); |
|
|
|
|
|
|
return !disableFptl; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void CopyDepthAfterGBuffer(RenderLoop loop) |
|
|
|
{ |
|
|
|
var cmd = new CommandBuffer { name = "Copy depth" }; |
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmd.Blit(0, s_CameraTarget, m_DeferredMaterial, 0); |
|
|
|
cmd.Blit(0, s_CameraTarget, m_DeferredReflectionMaterial, 0); |
|
|
|
cmd.Blit(BuiltinRenderTextureType.CameraTarget, s_CameraTarget, m_DeferredMaterial, 0); |
|
|
|
cmd.Blit(BuiltinRenderTextureType.CameraTarget, s_CameraTarget, m_DeferredReflectionMaterial, 0); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return numLightsOut + numProbesOut; |
|
|
|
} |
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
public override void RenderSceneView(Camera camera, RenderLoop renderLoop) |
|
|
|
{ |
|
|
|
base.RenderSceneView(camera, renderLoop); |
|
|
|
renderLoop.PrepareForEditorRendering(camera, new RenderTargetIdentifier(s_CameraDepthTexture)); |
|
|
|
renderLoop.Submit(); |
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
public override void Render(Camera[] cameras, RenderLoop renderLoop) |
|
|
|
{ |
|
|
|
foreach (var camera in cameras) |
|
|
|
|
|
|
|
|
|
|
// debug views.
|
|
|
|
if (enableDrawLightBoundsDebug) DrawLightBoundsDebug(loop, cullResults.visibleLights.Length); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bind depth surface for editor grid/gizmo/selection rendering
|
|
|
|
if (camera.cameraType == CameraType.SceneView) |
|
|
|
{ |
|
|
|
var cmd = new CommandBuffer(); |
|
|
|
cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, new RenderTargetIdentifier(s_CameraDepthTexture)); |
|
|
|
loop.ExecuteCommandBuffer(cmd); |
|
|
|
cmd.Dispose(); |
|
|
|
} |
|
|
|
loop.Submit(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void DrawLightBoundsDebug(RenderLoop loop, int numLights) |
|
|
|