浏览代码

Null check before using CommonSettings

/Branch_Batching2
Keijiro Takahashi 8 年前
当前提交
925e0fdd
共有 2 个文件被更改,包括 22 次插入16 次删除
  1. 16
      Assets/ScriptableRenderPipeline/HDRenderPipeline/AmbientOcclusion/Runtime/AmbientOcclusionContext.cs
  2. 22
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs

16
Assets/ScriptableRenderPipeline/HDRenderPipeline/AmbientOcclusion/Runtime/AmbientOcclusionContext.cs


internal static readonly int _CameraGBufferTexture1 = Shader.PropertyToID("_CameraGBufferTexture1");
}
CommonSettings.ScreenSpaceAmbientOcclusionSettings m_Settings;
public AmbientOcclusionContext(CommonSettings.ScreenSpaceAmbientOcclusionSettings settings, RenderTargetIdentifier[] gbufferIDs)
public AmbientOcclusionContext(RenderTargetIdentifier[] gbufferIDs)
m_Settings = settings;
public void Render(Camera camera, ScriptableRenderContext renderContext, RenderTargetIdentifier depthID)
public void Render(CommonSettings.ScreenSpaceAmbientOcclusionSettings settings, Camera camera, ScriptableRenderContext renderContext, RenderTargetIdentifier depthID)
if (settings == null) return;
if (m_Sheet == null)
{
var shader = Shader.Find("Hidden/HDPipeline/ScreenSpaceAmbientOcclusion");

var width = camera.pixelWidth;
var height = camera.pixelHeight;
var downsize = m_Settings.downsampling ? 2 : 1;
var downsize = settings.downsampling ? 2 : 1;
m_Sheet.properties.SetFloat(Uniforms._Intensity, m_Settings.intensity);
m_Sheet.properties.SetFloat(Uniforms._Radius, m_Settings.radius);
m_Sheet.properties.SetFloat(Uniforms._Intensity, settings.intensity);
m_Sheet.properties.SetFloat(Uniforms._Radius, settings.radius);
m_Sheet.properties.SetFloat(Uniforms._SampleCount, m_Settings.sampleCount);
m_Sheet.properties.SetFloat(Uniforms._SampleCount, settings.sampleCount);
// Start building a command buffer.
var cmd = new CommandBuffer { name = "Ambient Occlusion" };

22
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


public TextureSettings textureSettings { get { return m_TextureSettings; } set { m_TextureSettings = value; } }
// Renderer Settings (per "scene")
[SerializeField] private CommonSettings m_CommonSettings;
[SerializeField] private CommonSettings m_CommonSettings;
[SerializeField] private SkySettings m_SkySettings;
public CommonSettings commonSettingsToUse

public void UpdateCommonSettings()
{
var commonSettings = commonSettingsToUse.settings;
if (commonSettingsToUse != null)
{
var commonSettings = commonSettingsToUse.settings;
m_ShadowSettings.directionalLightCascadeCount = commonSettings.shadowCascadeCount;
m_ShadowSettings.directionalLightCascades = new Vector3(commonSettings.shadowCascadeSplit0, commonSettings.shadowCascadeSplit1, commonSettings.shadowCascadeSplit2);
m_ShadowSettings.maxShadowDistance = commonSettings.shadowMaxDistance;
m_ShadowSettings.directionalLightNearPlaneOffset = commonSettings.shadowNearPlaneOffset;
m_ShadowSettings.directionalLightCascadeCount = commonSettings.shadowCascadeCount;
m_ShadowSettings.directionalLightCascades = new Vector3(commonSettings.shadowCascadeSplit0, commonSettings.shadowCascadeSplit1, commonSettings.shadowCascadeSplit2);
m_ShadowSettings.maxShadowDistance = commonSettings.shadowMaxDistance;
m_ShadowSettings.directionalLightNearPlaneOffset = commonSettings.shadowNearPlaneOffset;
}
}
public void OnValidate()

m_SkyManager.skySettings = owner.skySettingsToUse;
m_PostProcessContext = new PostProcessRenderContext();
m_SsaoContext = new AmbientOcclusionContext(owner.commonSettingsToUse.screenSpaceAmbientOcclusionSettings, m_gbufferManager.GetGBuffers());
m_SsaoContext = new AmbientOcclusionContext(m_gbufferManager.GetGBuffers());
}
void InitializeDebugMaterials()

RenderForwardOnlyOpaqueDepthPrepass(cullResults, camera, renderContext);
RenderGBuffer(cullResults, camera, renderContext);
m_SsaoContext.Render(camera, renderContext, m_CameraDepthStencilBufferRT);
if (m_Owner.commonSettingsToUse != null)
{
m_SsaoContext.Render(m_Owner.commonSettingsToUse.screenSpaceAmbientOcclusionSettings, camera, renderContext, m_CameraDepthStencilBufferRT);
}
// If full forward rendering, we did not do any rendering yet, so don't need to copy the buffer.
// If Deferred then the depth buffer is full (regular GBuffer + ForwardOnly depth prepass are done so we can copy it safely.

正在加载...
取消
保存