|
|
|
|
|
|
|
|
|
|
private Material m_DebugViewMaterialGBuffer; |
|
|
|
private Material m_DebugDisplayLatlong; |
|
|
|
private Material m_DebugFullScreen; |
|
|
|
|
|
|
|
// Various buffer
|
|
|
|
readonly int m_CameraColorBuffer; |
|
|
|
|
|
|
|
|
|
|
// Debugging
|
|
|
|
public DebugDisplaySettings m_DebugDisplaySettings = new DebugDisplaySettings(); |
|
|
|
private int m_DebugFullScreenTempRT; |
|
|
|
|
|
|
|
public SubsurfaceScatteringSettings sssSettings |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
private CommonSettings.Settings m_CommonSettings = CommonSettings.Settings.s_Defaultsettings; |
|
|
|
private SkySettings m_SkySettings; |
|
|
|
private ScreenSpaceAmbientOcclusionSettings.Settings m_SsaoSettings = ScreenSpaceAmbientOcclusionSettings.Settings.s_Defaultsettings; |
|
|
|
|
|
|
|
public CommonSettings.Settings commonSettingsToUse |
|
|
|
{ |
|
|
|
|
|
|
return SkySettingsSingleton.overrideSettings; |
|
|
|
|
|
|
|
return m_SkySettings; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ScreenSpaceAmbientOcclusionSettings.Settings ssaoSettingsToUse |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
if (ScreenSpaceAmbientOcclusionSettingsSingleton.overrideSettings) |
|
|
|
return ScreenSpaceAmbientOcclusionSettingsSingleton.overrideSettings.settings; |
|
|
|
|
|
|
|
return m_SsaoSettings; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
m_SsaoEffect.Build(asset.renderPipelineResources); |
|
|
|
|
|
|
|
m_DebugDisplaySettings.RegisterDebug(); |
|
|
|
m_DebugFullScreenTempRT = Shader.PropertyToID("_DebugFullScreenTexture"); |
|
|
|
} |
|
|
|
|
|
|
|
void InitializeDebugMaterials() |
|
|
|
|
|
|
m_DebugFullScreen = Utilities.CreateEngineMaterial(m_Asset.renderPipelineResources.debugFullScreenShader); |
|
|
|
} |
|
|
|
|
|
|
|
public void OnSceneLoad() |
|
|
|
|
|
|
using (new Utilities.ProfilingSample("Build Light list and render shadows", renderContext)) |
|
|
|
{ |
|
|
|
// TODO: Everything here (SSAO, Shadow, Build light list, material and light classification can be parallelize with Async compute)
|
|
|
|
m_SsaoEffect.Render(m_Asset.ssaoSettingsToUse, hdCamera, renderContext, GetDepthTexture(), m_Asset.renderingSettings.useForwardRenderingOnly); |
|
|
|
m_SsaoEffect.Render(ssaoSettingsToUse, this, hdCamera, renderContext, GetDepthTexture(), m_Asset.renderingSettings.useForwardRenderingOnly); |
|
|
|
m_LightLoop.PrepareLightsForGPU(m_ShadowSettings, cullResults, camera); |
|
|
|
m_LightLoop.RenderShadows(renderContext, cullResults); |
|
|
|
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
RenderDebugOverlay(camera, renderContext); |
|
|
|
RenderDebug(hdCamera, renderContext); |
|
|
|
|
|
|
|
// bind depth surface for editor grid/gizmo/selection rendering
|
|
|
|
if (camera.cameraType == CameraType.SceneView) |
|
|
|
|
|
|
Shader.SetGlobalVector("_DebugLightingSmoothness", debugSmoothness); |
|
|
|
} |
|
|
|
|
|
|
|
void RenderDebugOverlay(Camera camera, ScriptableRenderContext renderContext) |
|
|
|
public void PushFullScreenDebugTexture(CommandBuffer cb, int textureID, Camera camera, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode) |
|
|
|
{ |
|
|
|
if(debugMode == m_DebugDisplaySettings.lightingDebugSettings.fullScreenDebugMode) |
|
|
|
{ |
|
|
|
cb.GetTemporaryRT(m_DebugFullScreenTempRT, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear); |
|
|
|
cb.Blit(textureID, m_DebugFullScreenTempRT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void RenderDebug(HDCamera camera, ScriptableRenderContext renderContext) |
|
|
|
if (camera.cameraType == CameraType.Reflection || camera.cameraType == CameraType.Preview) |
|
|
|
if (camera.camera.cameraType == CameraType.Reflection || camera.camera.cameraType == CameraType.Preview) |
|
|
|
debugCB.name = "Debug Overlay"; |
|
|
|
debugCB.name = "Render Debug"; |
|
|
|
|
|
|
|
// First render full screen debug texture
|
|
|
|
if(m_DebugDisplaySettings.lightingDebugSettings.fullScreenDebugMode != FullScreenDebugMode.None) |
|
|
|
{ |
|
|
|
debugCB.SetGlobalTexture("_DebugFullScreenTexture", m_DebugFullScreenTempRT); |
|
|
|
m_DebugFullScreen.SetFloat("_FullScreenDebugMode", (float)m_DebugDisplaySettings.lightingDebugSettings.fullScreenDebugMode); |
|
|
|
Utilities.DrawFullScreen(debugCB, m_DebugFullScreen, camera, BuiltinRenderTextureType.CameraTarget); |
|
|
|
} |
|
|
|
// Then overlays
|
|
|
|
float overlaySize = Math.Min(camera.pixelHeight, camera.pixelWidth) * overlayRatio; |
|
|
|
float y = camera.pixelHeight - overlaySize; |
|
|
|
float overlaySize = Math.Min(camera.camera.pixelHeight, camera.camera.pixelWidth) * overlayRatio; |
|
|
|
float y = camera.camera.pixelHeight - overlaySize; |
|
|
|
|
|
|
|
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock(); |
|
|
|
|
|
|
|
|
|
|
Texture skyReflection = m_SkyManager.skyReflection; |
|
|
|
propertyBlock.SetTexture("_InputCubemap", skyReflection); |
|
|
|
propertyBlock.SetFloat("_Mipmap", lightingDebug.skyReflectionMipmap); |
|
|
|
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize)); |
|
|
|
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize)); |
|
|
|
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth); |
|
|
|
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, camera.camera.pixelWidth); |
|
|
|
m_LightLoop.RenderDebugOverlay(camera, renderContext, m_DebugDisplaySettings, ref x, ref y, overlaySize, camera.pixelWidth); |
|
|
|
m_LightLoop.RenderDebugOverlay(camera.camera, renderContext, m_DebugDisplaySettings, ref x, ref y, overlaySize, camera.camera.pixelWidth); |
|
|
|
} |
|
|
|
|
|
|
|
void InitAndClearBuffer(Camera camera, ScriptableRenderContext renderContext) |
|
|
|