浏览代码

HDRenderPipeline: Fix issue with camera frame settings not working correctly in stand alone

This PR update the behavior of frameSettings.
At runtime, camera must init from DefaultFrameSettings to be correct.
Currently it init from the SerializedFrameSettings which is wrong if the
camera rendering path is set to Default
/main
Sebastien Lagarde 7 年前
当前提交
0cca4945
共有 2 个文件被更改,包括 61 次插入11 次删除
  1. 54
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDAdditionalCameraData.cs
  2. 18
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs

54
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDAdditionalCameraData.cs


float m_Version = 1.0f;
#pragma warning restore 414
Camera m_camera;
// This struct allow to add specialized path in HDRenderPipeline (can be use to render mini map or planar reflection etc...)
// A rendering path is the list of rendering pass that will be executed at runtime and depends on the associated FrameSettings
// Default is the default rendering path define by the HDRendeRPipelineAsset FrameSettings.

[FormerlySerializedAs("serializedFrameSettings")]
FrameSettings m_FrameSettings = new FrameSettings(); // Serialize frameSettings
// Not serialized, not visible
// Not serialized, visible only in the debug windows
bool m_frameSettingsIsDirty = true;
// Use for debug windows
// When camera name change we need to update the name in DebugWindows.
// This is the purpose of this class
bool m_IsDebugRegistered = false;
string m_CameraRegisterName;
// This is the function use outside to access FrameSettings. It return the current state of FrameSettings for the camera
// taking into account the customization via the debug menu
bool m_IsDebugRegistered = false;
Camera m_camera;
string m_CameraRegisterName;
// This function is call at the beginning of camera loop in HDRenderPipeline.Render()
// It allow to correctly init the m_FrameSettingsRuntime to use.
// If the camera use defaultFrameSettings it must be copied in m_FrameSettingsRuntime
// otherwise it is the serialized m_FrameSettings that are used
// This is required so each camera have its own debug settings even if they all use the RenderingPath.Default path
// and important at Runtime as Default Camera from Scene Preview doesn't exist
// defaultFrameSettings are the settings store in the HDRenderPipelineAsset
public void UpdateDirtyFrameSettings(FrameSettings defaultFrameSettings)
{
if (m_frameSettingsIsDirty)
{
// We do a copy of the settings to those effectively used
if (renderingPath == RenderingPath.Default)
{
defaultFrameSettings.CopyTo(m_FrameSettingsRuntime);
}
else
{
m_FrameSettings.CopyTo(m_FrameSettingsRuntime);
}
m_frameSettingsIsDirty = false;
}
}
// Note that we register m_FrameSettingsRuntime, so manipulating it in the Debug windows
// doesn't affect the serialized version
FrameSettings.RegisterDebug(m_camera.name, GetFrameSettings());
m_CameraRegisterName = m_camera.name;
m_IsDebugRegistered = true;

m_camera = GetComponent<Camera>();
m_camera.allowHDR = false;
m_FrameSettings.CopyTo(m_FrameSettingsRuntime);
// Tag as dirty so frameSettings are correctly initialize at next HDRenderPipeline.Render() call
m_frameSettingsIsDirty = true;
RegisterDebug();
}

// We need to detect name change in the editor and update debug windows accordingly
#if UNITY_EDITOR
if (m_camera.name != m_CameraRegisterName)
{

public void OnAfterDeserialize()
{
// We do a copy of the settings to those effectively used
m_FrameSettings.CopyTo(m_FrameSettingsRuntime);
// This is call on load or when this settings are change.
// When FrameSettings are manipulated or RenderPath change we reset them to reflect the change, discarding all the Debug Windows change.
// Tag as dirty so frameSettings are correctly initialize at next HDRenderPipeline.Render() call
m_frameSettingsIsDirty = true;
}
}
}

18
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


continue;
// First, get aggregate of frame settings base on global settings, camera frame settings and debug settings
// Note: the SceneView camera will never have additionalCameraData
// Note: the scene view camera will never have additionalCameraData
var srcFrameSettings = (additionalCameraData && additionalCameraData.renderingPath != HDAdditionalCameraData.RenderingPath.Default)
? additionalCameraData.GetFrameSettings()
: m_Asset.GetFrameSettings();
// Get the effective frame settings for this camera (This is camera frame settings and debug settings)
FrameSettings srcFrameSettings;
if (additionalCameraData)
{
additionalCameraData.UpdateDirtyFrameSettings(m_Asset.GetFrameSettings());
srcFrameSettings = additionalCameraData.GetFrameSettings();
}
else
{
srcFrameSettings = m_Asset.GetFrameSettings();
}
// Get the effective frame settings for this camera taking into account the global setting and camera type
FrameSettings.InitializeFrameSettings(camera, m_Asset.GetRenderPipelineSettings(), srcFrameSettings, ref m_FrameSettings);
// This is the main command buffer used for the frame.

正在加载...
取消
保存