|
|
|
|
|
|
|
|
|
|
// Post-processing context and screen-space effects (recycled on every frame to avoid GC alloc)
|
|
|
|
readonly PostProcessRenderContext m_PostProcessContext; |
|
|
|
readonly ScreenSpaceAmbientOcclusionEffect m_SsaoEffect; |
|
|
|
|
|
|
|
// Stencil usage in HDRenderPipeline.
|
|
|
|
// Currently we use only 2 bits to identify the kind of lighting that is expected from the render pipeline
|
|
|
|
|
|
|
|
|
|
|
CommonSettings.Settings m_CommonSettings = CommonSettings.Settings.s_Defaultsettings; |
|
|
|
SkySettings m_SkySettings = null; |
|
|
|
ScreenSpaceAmbientOcclusionSettings.Settings m_SsaoSettings = ScreenSpaceAmbientOcclusionSettings.Settings.s_Defaultsettings; |
|
|
|
|
|
|
|
public CommonSettings.Settings commonSettingsToUse |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ScreenSpaceAmbientOcclusionSettings.Settings ssaoSettingsToUse |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
if (ScreenSpaceAmbientOcclusionSettingsSingleton.overrideSettings) |
|
|
|
return ScreenSpaceAmbientOcclusionSettingsSingleton.overrideSettings.settings; |
|
|
|
|
|
|
|
return m_SsaoSettings; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public HDRenderPipeline(HDRenderPipelineAsset asset) |
|
|
|
{ |
|
|
|
m_Asset = asset; |
|
|
|
|
|
|
m_SkyManager.skySettings = skySettingsToUse; |
|
|
|
|
|
|
|
m_PostProcessContext = new PostProcessRenderContext(); |
|
|
|
m_SsaoEffect = new ScreenSpaceAmbientOcclusionEffect(); |
|
|
|
m_SsaoEffect.Build(asset.renderPipelineResources); |
|
|
|
|
|
|
|
m_DebugDisplaySettings.RegisterDebug(); |
|
|
|
m_DebugFullScreenTempRT = HDShaderIDs._DebugFullScreenTexture; |
|
|
|
|
|
|
CoreUtils.Destroy(m_InternalSSSAsset); |
|
|
|
|
|
|
|
m_SkyManager.Cleanup(); |
|
|
|
|
|
|
|
m_SsaoEffect.Cleanup(); |
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
SupportedRenderingFeatures.active = SupportedRenderingFeatures.Default; |
|
|
|
|
|
|
{ |
|
|
|
using (new ProfilingSample(cmd, "Build Light list and render shadows")) |
|
|
|
{ |
|
|
|
// TODO: Everything here (SSAO, Shadow, Build light list, deffered shadow, material and light classification can be parallelize with Async compute)
|
|
|
|
// TODO: Everything here (SSAO, Shadow, Build light list, deferred shadow, material and light classification can be parallelize with Async compute)
|
|
|
|
if (ssaoSettingsToUse.enable) |
|
|
|
{ |
|
|
|
// Override v2's MSVO if the internal default one is enabled
|
|
|
|
m_SsaoEffect.Render(ssaoSettingsToUse, this, hdCamera, renderContext, cmd, m_Asset.renderingSettings.useForwardRenderingOnly); |
|
|
|
} |
|
|
|
else if (postProcessLayer != null) |
|
|
|
// Apply SSAO from PostprocessLayer
|
|
|
|
if (postProcessLayer != null) |
|
|
|
{ |
|
|
|
var settings = postProcessLayer.GetSettings<AmbientOcclusion>(); |
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
cmd.SetGlobalTexture(HDShaderIDs._AmbientOcclusionTexture, RuntimeUtilities.blackTexture); // Neutral is black, see the comment in the shaders
|
|
|
|
cmd.SetGlobalFloat(HDShaderIDs._AmbientOcclusionDirectLightStrenght, 0f); |
|
|
|
cmd.SetGlobalFloat(HDShaderIDs._AmbientOcclusionDirectLightStrenght, 0.0f); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|