|
|
|
|
|
|
|
|
|
|
// Various buffer
|
|
|
|
int m_CameraColorBuffer; |
|
|
|
int m_CameraDiffuseLightingBuffer; |
|
|
|
RenderTargetIdentifier m_CameraDiffuseLightingBufferRT; |
|
|
|
RenderTargetIdentifier m_CameraDepthBufferRT; |
|
|
|
RenderTargetIdentifier m_VelocityBufferRT; |
|
|
|
RenderTargetIdentifier m_DistortionBufferRT; |
|
|
|
|
|
|
UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity = true; |
|
|
|
UnityEngine.Rendering.GraphicsSettings.lightsUseCCT = true; |
|
|
|
|
|
|
|
m_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture"); |
|
|
|
m_CameraDepthBuffer = Shader.PropertyToID("_CameraDepthTexture"); |
|
|
|
m_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture"); |
|
|
|
m_CameraDiffuseLightingBuffer = Shader.PropertyToID("_CameraDiffuseLightingBuffer"); |
|
|
|
m_CameraDepthBuffer = Shader.PropertyToID("_CameraDepthTexture"); |
|
|
|
m_CameraColorBufferRT = new RenderTargetIdentifier(m_CameraColorBuffer); |
|
|
|
m_CameraDepthBufferRT = new RenderTargetIdentifier(m_CameraDepthBuffer); |
|
|
|
m_CameraColorBufferRT = new RenderTargetIdentifier(m_CameraColorBuffer); |
|
|
|
m_CameraDiffuseLightingBufferRT = new RenderTargetIdentifier(m_CameraDiffuseLightingBuffer); |
|
|
|
m_CameraDepthBufferRT = new RenderTargetIdentifier(m_CameraDepthBuffer); |
|
|
|
|
|
|
|
m_SkyManager.Build(); |
|
|
|
|
|
|
|
|
|
|
int w = camera.pixelWidth; |
|
|
|
int h = camera.pixelHeight; |
|
|
|
|
|
|
|
cmd.GetTemporaryRT(m_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
|
|
|
|
cmd.GetTemporaryRT(m_CameraDepthBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth); |
|
|
|
cmd.GetTemporaryRT(m_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
|
|
|
|
cmd.GetTemporaryRT(m_CameraDiffuseLightingBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
|
|
|
|
cmd.GetTemporaryRT(m_CameraDepthBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth); |
|
|
|
|
|
|
|
|
|
|
|
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT, ClearFlag.ClearDepth); |
|
|
|
RenderTargetIdentifier[] colorRTs = { m_CameraColorBuffer, m_CameraDiffuseLightingBufferRT }; |
|
|
|
Utilities.SetRenderTarget(renderContext, colorRTs, m_CameraDepthBufferRT, ClearFlag.ClearDepth); |
|
|
|
// Clear HDR target
|
|
|
|
// Clear the HDR target
|
|
|
|
// Clear the diffuse lighting target
|
|
|
|
using (new Utilities.ProfilingSample("Clear diffuse lighting target", renderContext)) |
|
|
|
{ |
|
|
|
Utilities.SetRenderTarget(renderContext, m_CameraDiffuseLightingBufferRT, m_CameraDepthBufferRT, ClearFlag.ClearColor, Color.black); |
|
|
|
} |
|
|
|
|
|
|
|
// Clear GBuffers
|
|
|
|
using (new Utilities.ProfilingSample("Clear GBuffer", renderContext)) |
|
|
|
|
|
|
|
|
|
|
// Bind material data
|
|
|
|
m_LitRenderLoop.Bind(); |
|
|
|
m_lightLoop.RenderDeferredLighting(hdCamera, renderContext, m_CameraColorBuffer); |
|
|
|
RenderTargetIdentifier[] colorRTs = { m_CameraColorBuffer, m_CameraDiffuseLightingBufferRT }; |
|
|
|
m_lightLoop.RenderDeferredLighting(hdCamera, renderContext, colorRTs); |
|
|
|
} |
|
|
|
|
|
|
|
void UpdateSkyEnvironment(HDCamera hdCamera, ScriptableRenderContext renderContext) |
|
|
|
|
|
|
// Bind material data
|
|
|
|
m_LitRenderLoop.Bind(); |
|
|
|
|
|
|
|
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT); |
|
|
|
RenderTargetIdentifier[] colorRTs = { m_CameraColorBuffer, m_CameraDiffuseLightingBufferRT }; |
|
|
|
Utilities.SetRenderTarget(renderContext, colorRTs, m_CameraDepthBufferRT); |
|
|
|
|
|
|
|
m_lightLoop.RenderForward(camera, renderContext, renderOpaque); |
|
|
|
|
|
|
|
|
|
|
// Bind material data
|
|
|
|
m_LitRenderLoop.Bind(); |
|
|
|
|
|
|
|
Utilities.SetRenderTarget(renderContext, m_CameraColorBufferRT, m_CameraDepthBufferRT); |
|
|
|
RenderTargetIdentifier[] colorRTs = { m_CameraColorBuffer, m_CameraDiffuseLightingBufferRT }; |
|
|
|
Utilities.SetRenderTarget(renderContext, colorRTs, m_CameraDepthBufferRT); |
|
|
|
|
|
|
|
m_lightLoop.RenderForward(camera, renderContext, true); |
|
|
|
RenderOpaqueRenderList(cullResults, camera, renderContext, "ForwardOnlyOpaque"); |
|
|
|