Skip to content

Fix shadows culling with XR #2223

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 4 commits into from
Oct 14, 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
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed a migration issue with the rendering queue in ShaderGraph when upgrading to 10.x;
- Fixed null reference in the Undo callback of the graphics compositor
- Fixed cullmode for SceneSelectionPass.
- Fixed XR shadows culling.

### Changed
- Preparation pass for RTSSShadows to be supported by render graph.
Expand Down Expand Up @@ -202,6 +203,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Changed which local frame is used for multi-bounce RTReflections.
- Move System Generated Values semantics out of VaryingsMesh structure.
- Other forms of FSAA are silently deactivated, when path tracing is on.
- Disable field of view UI settings when XR is enabled on the camera.

## [10.0.0] - 2019-06-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,19 @@ static void Drawer_Projection(SerializedHDCamera p, Editor owner)

var cam = p.baseCameraSettings;

// In XR mode, some settings can't be changed because the values come from the device
if (p.xrRendering.boolValue)
{
cam.orthographic.boolValue = false;
cam.fovAxisMode.intValue = (int)Camera.FieldOfViewAxis.Vertical;
p.projectionMatrixMode.intValue = (int)ProjectionMatrixMode.Implicit;
}

Rect perspectiveRect = EditorGUILayout.GetControlRect();

ProjectionType projectionType;
EditorGUI.BeginProperty(perspectiveRect, projectionContent, cam.orthographic);
EditorGUI.BeginDisabledGroup(p.xrRendering.boolValue);
{
projectionType = cam.orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective;

Expand All @@ -212,8 +221,9 @@ static void Drawer_Projection(SerializedHDCamera p, Editor owner)
if (EditorGUI.EndChangeCheck())
cam.orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
}
EditorGUI.EndDisabledGroup();
EditorGUI.EndProperty();

if (cam.orthographic.hasMultipleDifferentValues)
return;

Expand All @@ -228,6 +238,7 @@ static void Drawer_Projection(SerializedHDCamera p, Editor owner)
bool isPhysicalCamera = p.projectionMatrixMode.intValue == (int)ProjectionMatrixMode.PhysicalPropertiesBased;

var rect = EditorGUILayout.GetControlRect();
EditorGUI.BeginDisabledGroup(p.xrRendering.boolValue);

var guiContent = EditorGUI.BeginProperty(rect, FOVAxisModeContent, cam.fovAxisMode);
EditorGUI.showMixedValue = cam.fovAxisMode.hasMultipleDifferentValues;
Expand Down Expand Up @@ -285,6 +296,7 @@ static void Drawer_Projection(SerializedHDCamera p, Editor owner)
: Camera.HorizontalToVerticalFieldOfView(s_FovLastValue, (p.serializedObject.targetObjects[0] as Camera).aspect);
}

EditorGUI.EndDisabledGroup();
EditorGUILayout.Space();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,10 @@ protected override void Render(ScriptableRenderContext renderContext, Camera[] c
{
var needCulling = true;

// In XR mode, sync the FOV on the camera to match the projection from the device in order to cull accurately
if (hdCamera.xr.enabled)
camera.fieldOfView = Mathf.Rad2Deg * Mathf.Atan(1.0f / hdCamera.xr.cullingParams.stereoProjectionMatrix.m00) * 2.0f;

// In XR multipass, culling results can be shared if the pass has the same culling id
if (xrPass.multipassId > 0)
{
Expand Down