From 592ae917785ae0463ec1aedaf7afd29d3455c3a2 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Tue, 27 Oct 2020 15:56:07 +0100 Subject: [PATCH 1/5] Fix linking of the field of view with the focal length in physical camera --- .../RenderPipeline/Camera/HDCameraUI.Drawers.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs index e78b29b0d24..d5ca4a9691f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs @@ -273,7 +273,12 @@ static void Drawer_Projection(SerializedHDCamera p, Editor owner) EditorGUI.BeginChangeCheck(); isPhysicalCamera = EditorGUILayout.Toggle(content, isPhysicalCamera); if (EditorGUI.EndChangeCheck()) + { p.projectionMatrixMode.intValue = isPhysicalCamera ? (int)ProjectionMatrixMode.PhysicalPropertiesBased : (int)ProjectionMatrixMode.Implicit; + // The next line ensures that we will not get any "popping" in the FoV slider when toggling the physical camera with vertical FoV. + // Horizontal FoV will still pop, because the aspect ration computation is different between physical and non-physical cameras + s_FovChanged = true; + } EditorGUILayout.EndHorizontal(); EditorGUI.EndProperty(); @@ -405,10 +410,14 @@ static void Drawer_PhysicalCamera(SerializedHDCamera p, Editor owner) using (new EditorGUI.PropertyScope(horizontal.rect, focalLengthContent, cam.focalLength)) using (var checkScope = new EditorGUI.ChangeCheckScope()) { + bool isPhysical = p.projectionMatrixMode.intValue == (int)ProjectionMatrixMode.PhysicalPropertiesBased; + // We need to update the focal length if the camera is physical and the FoV has changed. + bool focalLengthIsDirty = (s_FovChanged && isPhysical); + float sensorLength = cam.fovAxisMode.intValue == 0 ? cam.sensorSize.vector2Value.y : cam.sensorSize.vector2Value.x; - float focalLengthVal = s_FovChanged ? Camera.FieldOfViewToFocalLength(s_FovLastValue, sensorLength) : cam.focalLength.floatValue; + float focalLengthVal = focalLengthIsDirty ? Camera.FieldOfViewToFocalLength(s_FovLastValue, sensorLength) : cam.focalLength.floatValue; focalLengthVal = EditorGUILayout.FloatField(focalLengthContent, focalLengthVal); - if (checkScope.changed || s_FovChanged) + if (checkScope.changed || focalLengthIsDirty) cam.focalLength.floatValue = focalLengthVal; } From 8840557f256fb21fcf035e9db4a654594c9f1192 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Tue, 27 Oct 2020 15:57:47 +0100 Subject: [PATCH 2/5] Update changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 7c04adff75e..b1929671de0 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +### Fixed +- Fix linking of the field of view with the focal length in physical camera + ## [10.2.0] - 2020-10-19 ### Added From 0fd880bd4f7aca9624ce076410088941dea38ca2 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Tue, 27 Oct 2020 15:58:27 +0100 Subject: [PATCH 3/5] Update changelog 2 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index b1929671de0..b11b19f5d5f 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -10,7 +10,7 @@ Version Updated The version number for this package has increased due to a version update of a related graphics package. ### Fixed -- Fix linking of the field of view with the focal length in physical camera +- Fixed issue when linking the field of view with the focal length in physical camera ## [10.2.0] - 2020-10-19 From ff72179c8a8f4c491a61708ec15add4f7d17e8d6 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Tue, 27 Oct 2020 16:17:25 +0100 Subject: [PATCH 4/5] Revert small change to make behavior similar to URP --- .../Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs index d5ca4a9691f..455d9b2f070 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs @@ -273,12 +273,7 @@ static void Drawer_Projection(SerializedHDCamera p, Editor owner) EditorGUI.BeginChangeCheck(); isPhysicalCamera = EditorGUILayout.Toggle(content, isPhysicalCamera); if (EditorGUI.EndChangeCheck()) - { p.projectionMatrixMode.intValue = isPhysicalCamera ? (int)ProjectionMatrixMode.PhysicalPropertiesBased : (int)ProjectionMatrixMode.Implicit; - // The next line ensures that we will not get any "popping" in the FoV slider when toggling the physical camera with vertical FoV. - // Horizontal FoV will still pop, because the aspect ration computation is different between physical and non-physical cameras - s_FovChanged = true; - } EditorGUILayout.EndHorizontal(); EditorGUI.EndProperty(); From 6046090185a0e948acbdfb196eea2f043994954b Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Wed, 28 Oct 2020 09:47:08 +0100 Subject: [PATCH 5/5] Update changelog - move to 10.2 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index b11b19f5d5f..c282b9a3bc2 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -9,9 +9,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. -### Fixed -- Fixed issue when linking the field of view with the focal length in physical camera - ## [10.2.0] - 2020-10-19 ### Added @@ -54,6 +51,7 @@ The version number for this package has increased due to a version update of a r - Fixed issue when null parameters in a volume component would spam null reference errors. Produce a warning instead. - Fix volument component creation via script. - Fixed GC allocs in render graph. +- Fixed issue when linking the field of view with the focal length in physical camera ### Changed - Combined occlusion meshes into one to reduce draw calls and state changes with XR single-pass.