Skip to content

Scene exposure override #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add support of lightlayers on indirect lighting controller
- Added compute shader stripping.
- Added Cull Mode option for opaque materials and ShaderGraphs.
- Added scene view exposure override.

### Fixed
- Fix when rescale probe all direction below zero (1219246)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdIn
// Fix exposure is store in Exposure Textures at the beginning of the frame as there is no need for color buffer
// Dynamic exposure (Auto, curve) is store in Exposure Textures at the end of the frame (as it rely on color buffer)
// Texture current and previous are swapped at the beginning of the frame.
bool isFixedExposure = IsExposureFixed();
bool isFixedExposure = IsExposureFixed(camera);
if (isFixedExposure)
{
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.FixedExposure)))
Expand Down Expand Up @@ -489,7 +489,7 @@ void PoolSource(ref RTHandle src, RTHandle dst)

// Dynamic exposure - will be applied in the next frame
// Not considered as a post-process so it's not affected by its enabled state
if (!IsExposureFixed() && m_ExposureControlFS)
if (!IsExposureFixed(camera) && m_ExposureControlFS)
{
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.DynamicExposure)))
{
Expand Down Expand Up @@ -894,7 +894,7 @@ static void DoCopyAlpha(in DoCopyAlphaParameters parameters, RTHandle source, RT
#region Exposure

[MethodImpl(MethodImplOptions.AggressiveInlining)]
bool IsExposureFixed() => m_Exposure.mode.value == ExposureMode.Fixed || m_Exposure.mode.value == ExposureMode.UsePhysicalCamera;
bool IsExposureFixed(HDCamera camera) => m_Exposure.mode.value == ExposureMode.Fixed || m_Exposure.mode.value == ExposureMode.UsePhysicalCamera || (camera.camera.cameraType == CameraType.SceneView && HDAdditionalSceneViewSettings.sceneExposureOverriden);

public RTHandle GetExposureTexture(HDCamera camera)
{
Expand Down Expand Up @@ -979,10 +979,15 @@ void DoFixedExposure(CommandBuffer cmd, HDCamera camera)

int kernel = 0;

if (m_Exposure.mode.value == ExposureMode.Fixed)
if (m_Exposure.mode.value == ExposureMode.Fixed || (HDAdditionalSceneViewSettings.sceneExposureOverriden && camera.camera.cameraType == CameraType.SceneView))
{
kernel = cs.FindKernel("KFixedExposure");
cmd.SetComputeVectorParam(cs, HDShaderIDs._ExposureParams, new Vector4(m_Exposure.compensation.value + m_DebugExposureCompensation, m_Exposure.fixedExposure.value, 0f, 0f));
var exposureParam = new Vector4(m_Exposure.compensation.value + m_DebugExposureCompensation, m_Exposure.fixedExposure.value, 0f, 0f);
if (HDAdditionalSceneViewSettings.sceneExposureOverriden)
{
exposureParam = new Vector4(0.0f, HDAdditionalSceneViewSettings.sceneExposure, 0f, 0f);
}
cmd.SetComputeVectorParam(cs, HDShaderIDs._ExposureParams, exposureParam);
}
else if (m_Exposure.mode == ExposureMode.UsePhysicalCamera)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ static class Styles
{
public static readonly GUIContent AAMode = EditorGUIUtility.TrTextContent("Camera Anti-aliasing", "The anti-alising mode that will be used in the scene view camera.");
public static readonly GUIContent StopNaNs = EditorGUIUtility.TrTextContent("Camera Stop NaNs", "When enabled, any NaNs in the color buffer of the scene view camera will be suppressed.");
public static readonly GUIContent OverrideExposure = EditorGUIUtility.TrTextContent("Override Exposure", "When enabled, the scene exposure is overridden with the selected value.");
public static readonly GUIContent OverriddenExposure = EditorGUIUtility.TrTextContent("Scene Exposure", "The value for the overridden exposure.");
#if UNITY_2020_2_OR_NEWER
public static readonly string HelpBox = "Temporal Anti - aliasing in the Scene View is only supported when Always Refresh is enabled.";
#else
Expand Down Expand Up @@ -102,6 +104,21 @@ public static bool sceneViewStopNaNs
set => s_SceneViewStopNaNs.value = value;
}

static CachedEditorPref<bool> s_SceneExposureOverride = new CachedEditorPref<bool>("HDRP:SceneViewCamera:OverrideExposure", false);

public static bool sceneExposureOverriden
{
get => s_SceneExposureOverride.value;
set => s_SceneExposureOverride.value = value;
}

static CachedEditorPref<float> s_SceneExposure = new CachedEditorPref<float>("HDRP:SceneViewCamera:Exposure", 10.0f);

public static float sceneExposure
{
get => s_SceneExposure.value;
set => s_SceneExposure.value = value;
}
static HDAdditionalSceneViewSettings()
{
SceneViewCameraWindow.additionalSettingsGui += DoAdditionalSettings;
Expand All @@ -111,12 +128,15 @@ static void DoAdditionalSettings(SceneView sceneView)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("HD Render Pipeline", EditorStyles.boldLabel);

sceneViewAntialiasing = (AntialiasingMode)EditorGUILayout.EnumPopup(Styles.AAMode, sceneViewAntialiasing);
if (sceneViewAntialiasing == AntialiasingMode.TemporalAntialiasing)
EditorGUILayout.HelpBox(Styles.HelpBox, MessageType.Info);

sceneViewStopNaNs = EditorGUILayout.Toggle(Styles.StopNaNs, sceneViewStopNaNs);

sceneExposureOverriden = EditorGUILayout.Toggle(Styles.OverrideExposure, sceneExposureOverriden);
if (sceneExposureOverriden)
sceneExposure = EditorGUILayout.Slider(Styles.OverriddenExposure, sceneExposure, -11.0f, 16.0f);
}
}
#endif
Expand Down