Skip to content
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

Avoid issues causing faulty transitions in shadows (resulting in no shadows with unconventional aspect ratio) #2776

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e54311f
Fixed volume component tooltips using the same parameter name (#2754)
adrien-de-tocqueville Nov 26, 2020
0cace46
Use the proper history info for Bicubic resampling in TAA (#2759)
FrancescoC-unity Nov 26, 2020
0120a0f
Fixed lookdev movement (#2757)
adrien-de-tocqueville Nov 26, 2020
0dcb948
[HDRP] Fix issue with saving some quality settings in volume override…
pmavridis Nov 26, 2020
68eb5b1
[HDRP] Fixed NullReferenceException in HDRenderPipeline.UpgradeResour…
sebastienlagarde Nov 27, 2020
29a3d43
fix issue with confusing text (#2766)
sebastienlagarde Nov 27, 2020
4ce4727
Fix
FrancescoC-unity Nov 27, 2020
654929b
Fix white dots
FrancescoC-unity Nov 27, 2020
afa910b
Changelog
FrancescoC-unity Nov 27, 2020
de7b620
Rename the sunrise icon to fix typo, causing issue with 2x resolution…
johnpars Dec 1, 2020
5aec67f
Merge branch 'master' into hd/bugfix
sebastienlagarde Dec 2, 2020
12e69b1
[HDRP] Rename HDRP to HD Render Pipeline in menu item (#2819)
sebastienlagarde Dec 2, 2020
e2271c4
HDRP/Fix package version showing package after the last "verified" pa…
RSlysz Dec 2, 2020
630656c
Merge branch 'hd/bugfix' into HDRP/avoid-issues-with-wrong-transition…
FrancescoC-unity Dec 2, 2020
e3faa92
Revert bad changelog merge
FrancescoC-unity Dec 2, 2020
9ebeec2
Merge branch 'master' into HDRP/avoid-issues-with-wrong-transition-sh…
sebastienlagarde Dec 15, 2020
0e214a2
Update CHANGELOG.md
sebastienlagarde Dec 15, 2020
db856cf
Update CHANGELOG.md
sebastienlagarde Dec 15, 2020
d17656a
Merge branch 'hd/bugfix' into HDRP/avoid-issues-with-wrong-transition…
sebastienlagarde Dec 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 40 additions & 14 deletions com.unity.render-pipelines.core/Editor/LookDev/CameraController.cs
Expand Up @@ -38,9 +38,24 @@ enum Direction
bool m_InFlyMotion;

bool m_IsDragging;
ViewTool m_BehaviorState;
static TimeHelper s_Timer = new TimeHelper();

ViewTool m_BehaviorState;
ViewTool behaviorState
{
get { return m_BehaviorState; }
set
{
if (value != m_BehaviorState && m_BehaviorState == ViewTool.FPS)
{
isDragging = false;
inFlyMotion = false;
m_DirectionKeyPressed = Direction.None;
}
m_BehaviorState = value;
}
}

protected CameraState m_CameraState;
DisplayWindow m_Window;
protected Action m_Focused;
Expand Down Expand Up @@ -125,13 +140,13 @@ private void ResetCameraControl()
{
isDragging = false;
inFlyMotion = false;
m_BehaviorState = ViewTool.None;
behaviorState = ViewTool.None;
}

protected virtual void OnScrollWheel(WheelEvent evt)
{
// See UnityEditor.SceneViewMotion.HandleScrollWheel
switch (m_BehaviorState)
switch (behaviorState)
{
case ViewTool.FPS: OnChangeFPSCameraSpeed(evt); break;
default: OnZoom(evt); break;
Expand All @@ -140,7 +155,7 @@ protected virtual void OnScrollWheel(WheelEvent evt)

void OnMouseDrag(MouseMoveEvent evt)
{
switch (m_BehaviorState)
switch (behaviorState)
{
case ViewTool.Orbit: OnMouseDragOrbit(evt); break;
case ViewTool.FPS: OnMouseDragFPS(evt); break;
Expand Down Expand Up @@ -241,7 +256,7 @@ void OnKeyDownReset(KeyDownEvent evt)
void OnKeyUpOrDownFPS<T>(KeyboardEventBase<T> evt)
where T : KeyboardEventBase<T>, new()
{
if (m_BehaviorState != ViewTool.FPS)
if (behaviorState != ViewTool.FPS)
return;

//Note: Keydown is called in loop but between first occurence of the
Expand Down Expand Up @@ -319,29 +334,40 @@ bool GetKeyCombinationByID(string ID, out KeyCombination combination)
}
}

ViewTool GetBehaviorTool<T>(MouseEventBase<T> evt, bool onMac) where T : MouseEventBase<T>, new()
{
if (evt.button == 2)
return ViewTool.Pan;
else if (evt.button == 0 && evt.ctrlKey && onMac || evt.button == 1 && evt.altKey)
return ViewTool.Zoom;
else if (evt.button == 0)
return ViewTool.Orbit;
else if (evt.button == 1 && !evt.altKey)
return ViewTool.FPS;
return ViewTool.None;
}

void OnMouseUp(MouseUpEvent evt)
{
ResetCameraControl();
bool onMac = Application.platform == RuntimePlatform.OSXEditor;
var state = GetBehaviorTool(evt, onMac);

if (state == behaviorState)
ResetCameraControl();
evt.StopPropagation();
}

void OnMouseDown(MouseDownEvent evt)
{
bool onMac = Application.platform == RuntimePlatform.OSXEditor;
behaviorState = GetBehaviorTool(evt, onMac);

if (evt.button == 2)
m_BehaviorState = ViewTool.Pan;
else if (evt.button == 0 && evt.ctrlKey && onMac || evt.button == 1 && evt.altKey)
if (behaviorState == ViewTool.Zoom)
{
m_BehaviorState = ViewTool.Zoom;
m_StartZoom = m_CameraState.viewSize;
m_ZoomSpeed = Mathf.Max(Mathf.Abs(m_StartZoom), .3f);
m_TotalMotion = 0;
}
else if (evt.button == 0)
m_BehaviorState = ViewTool.Orbit;
else if (evt.button == 1 && !evt.altKey)
m_BehaviorState = ViewTool.FPS;

// see also SceneView.HandleClickAndDragToFocus()
if (evt.button == 1 && onMac)
Expand Down
Expand Up @@ -318,7 +318,7 @@ protected SerializedDataParameter Unpack(SerializedProperty property)
/// <param name="property">The property to draw in the editor</param>
protected void PropertyField(SerializedDataParameter property)
{
var title = EditorGUIUtility.TrTextContent(property.displayName);
var title = EditorGUIUtility.TrTextContent(property.displayName, property.GetAttribute<TooltipAttribute>()?.tooltip);
PropertyField(property, title);
}

Expand Down
6 changes: 6 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed
- Fixed probe volumes debug views.
- Fixed lookdev movement.
- Fixed volume component tooltips using the same parameter name.
- Fixed issue with saving some quality settings in volume overrides (case 1293747)
- Fixed NullReferenceException in HDRenderPipeline.UpgradeResourcesIfNeeded (case 1292524)

### Changed
- Removed the material pass probe volumes evaluation mode.
Expand Down Expand Up @@ -43,6 +47,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed the clear coat not being handled properly for SSR and RTR (case 1291654).
- Fixed ghosting in RTGI and RTAO when denoising is enabled and the RTHandle size is not equal to the Viewport size (case 1291654).
- Fixed alpha output when atmospheric scattering is enabled.
- Fixed issue with TAA history sharpening when view is downsampled.
- Fixed issue with faulty shadow transition when view is close to an object under some aspect ratio conditions

### Changed
- Volume Manager now always tests scene culling masks. This was required to fix hybrid workflow.
Expand Down
Expand Up @@ -98,17 +98,22 @@ public override void OnEnable()

void RayTracingQualityModeGUI()
{
PropertyField(m_MinSmoothness, k_MinimumSmoothnessText);
PropertyField(m_SmoothnessFadeStart, k_SmoothnessFadeStartText);
m_SmoothnessFadeStart.value.floatValue = Mathf.Max(m_MinSmoothness.value.floatValue, m_SmoothnessFadeStart.value.floatValue);
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_ClampValue, k_ClampValueText);
PropertyField(m_SampleCount, k_SampleCountText);
PropertyField(m_BounceCount, k_BounceCountText);
PropertyField(m_Denoise, k_DenoiseText);
base.OnInspectorGUI();
using (new HDEditorUtils.IndentScope())
using (new QualityScope(this))
{
PropertyField(m_DenoiserRadius, k_DenoiseRadiusText);
PropertyField(m_MinSmoothness, k_MinimumSmoothnessText);
PropertyField(m_SmoothnessFadeStart, k_SmoothnessFadeStartText);
m_SmoothnessFadeStart.value.floatValue = Mathf.Max(m_MinSmoothness.value.floatValue, m_SmoothnessFadeStart.value.floatValue);
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_ClampValue, k_ClampValueText);
PropertyField(m_SampleCount, k_SampleCountText);
PropertyField(m_BounceCount, k_BounceCountText);
PropertyField(m_Denoise, k_DenoiseText);
using (new HDEditorUtils.IndentScope())
{
PropertyField(m_DenoiserRadius, k_DenoiseRadiusText);
}
}
}

Expand Down
Expand Up @@ -8,7 +8,7 @@ namespace UnityEditor.Rendering.HighDefinition
{
static class DiffusionProfileMaterialUI
{
static GUIContent diffusionProfileNotInHDRPAsset = new GUIContent("You must make sure that this diffusion profile is either referenced in the HDRP asset or in the Diffusion Profile Override to make it work.", EditorGUIUtility.IconContent("console.infoicon").image);
static GUIContent diffusionProfileNotInHDRPAsset = new GUIContent("Make sure this Diffusion Profile is referenced in either a Diffusion Profile Override or the HDRP Default Settings. If the Diffusion Profile is not referenced in either, HDRP cannot use it. To add a reference to the Diffusion Profile in the HDRP Default Settings, press Fix.", EditorGUIUtility.IconContent("console.infoicon").image);

public static bool IsSupported(MaterialEditor materialEditor)
{
Expand Down
Expand Up @@ -145,11 +145,17 @@ public override void OnInspectorGUI()
break;
case RayTracingMode.Quality:
{
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_ClampValue);
PropertyField(m_SampleCount);
PropertyField(m_BounceCount);
DenoiserGUI();
base.OnInspectorGUI(); // Quality Setting

using (new HDEditorUtils.IndentScope())
using (new QualityScope(this))
{
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_ClampValue);
PropertyField(m_SampleCount);
PropertyField(m_BounceCount);
DenoiserGUI();
}
}
break;
}
Expand All @@ -158,11 +164,16 @@ public override void OnInspectorGUI()
else if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode ==
RenderPipelineSettings.SupportedRayTracingMode.Quality)
{
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_ClampValue);
PropertyField(m_SampleCount);
PropertyField(m_BounceCount);
DenoiserGUI();
base.OnInspectorGUI(); // Quality Setting
EditorGUI.indentLevel++;
using (new QualityScope(this))
{
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_ClampValue);
PropertyField(m_SampleCount);
PropertyField(m_BounceCount);
DenoiserGUI();
}
}
else
{
Expand Down
Expand Up @@ -206,12 +206,15 @@ int EvalShadow_GetSplitIndex(HDShadowContext shadowContext, int index, float3 po

// The above code will generate transitions on the whole cascade sphere boundary.
// It means that depending on the light and camera direction, sometimes the transition appears on the wrong side of the cascade
// To avoid that we attenuate the effect (lerp to 0.0) when view direction and cascade center to pixel vector face opposite directions.
// To avoid that we attenuate the effect (lerp very sharply to 0.0) when view direction and cascade center to pixel vector face opposite directions.
// This way you only get fade out on the right side of the cascade.
float3 viewDir = GetWorldSpaceViewDir(positionWS);
float cascDot = dot(viewDir, wposDir);
alpha = lerp(alpha, 0.0, saturate(cascDot * 4.0));

float cascDot = dot(viewDir, wposDir);
// At high border sizes the sharp lerp is noticeable, hence we need to lerp how sharpenss factor
// if we are below 80% we keep the very sharp transition.
float lerpSharpness = 8.0f + 512.0f * smoothstep(1.0f, 0.7f, border);// lerp(1024.0f, 8.0f, saturate(border - 0.8) / 0.2f);
alpha = lerp(alpha, 0.0, saturate(cascDot * lerpSharpness));
return shadowSplitIndex;
}

Expand Down Expand Up @@ -293,7 +296,7 @@ float EvalShadow_CascadedDepth_Dither(HDShadowContext shadowContext, Texture2D t

/* We select what split we need to sample from */
float nextSplit = min(shadowSplitIndex + 1, cascadeCount - 1);
bool evalNextCascade = nextSplit != shadowSplitIndex && step(InterleavedGradientNoise(positionSS.xy, _TaaFrameInfo.z), alpha);
bool evalNextCascade = nextSplit != shadowSplitIndex && alpha > 0 && step(InterleavedGradientNoise(positionSS.xy, _TaaFrameInfo.z), alpha);

if (evalNextCascade)
{
Expand Down
Expand Up @@ -1598,6 +1598,7 @@ struct TemporalAntiAliasingParameters
public MaterialPropertyBlock taaPropertyBlock;
public bool resetPostProcessingHistory;

public Vector4 previousScreenSize;
public Vector4 taaParameters;
public Vector4 taaFilterWeights;
public bool motionVectorRejection;
Expand Down Expand Up @@ -1681,6 +1682,8 @@ TemporalAntiAliasingParameters PrepareTAAParameters(HDCamera camera, bool PostDO

parameters.taaHistoryPropertyBlock = m_TAAHistoryBlitPropertyBlock;
parameters.taaPropertyBlock = m_TAAPropertyBlock;
Vector2Int prevViewPort = camera.historyRTHandleProperties.previousViewportSize;
parameters.previousScreenSize = new Vector4(prevViewPort.x, prevViewPort.y, 1.0f / prevViewPort.x, 1.0f / prevViewPort.y);

return parameters;
}
Expand Down Expand Up @@ -1719,9 +1722,7 @@ TemporalAntiAliasingParameters PrepareTAAParameters(HDCamera camera, bool PostDO

taaParams.taaPropertyBlock.SetTexture(HDShaderIDs._DepthTexture, depthMipChain);

Vector2 historySize = new Vector2(prevHistory.referenceSize.x * prevHistory.scaleFactor.x,
prevHistory.referenceSize.y * prevHistory.scaleFactor.y);
var taaHistorySize = new Vector4(historySize.x, historySize.y, 1.0f / historySize.x, 1.0f / historySize.y);
var taaHistorySize = taaParams.previousScreenSize;

taaParams.taaPropertyBlock.SetVector(HDShaderIDs._TaaPostParameters, taaParams.taaParameters);
taaParams.taaPropertyBlock.SetVector(HDShaderIDs._TaaHistorySize, taaHistorySize);
Expand Down
Expand Up @@ -399,7 +399,10 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau
m_RayTracingSupported = GatherRayTracingSupport(m_Asset.currentPlatformRenderPipelineSettings);

#if UNITY_EDITOR
m_Asset.EvaluateSettings();
// If defaultAsset is not ready (can happen due to loading order issue), then we should return
// There is a similar check in Render()
if (HDRenderPipeline.defaultAsset == null)
return;

UpgradeResourcesIfNeeded();

Expand Down