mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-10 04:53:15 +08:00
Added extra checks regarding HDRP rendering on ForcedMatrix freecam method.
This commit is contained in:
@@ -80,6 +80,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
public static Toggle followRotationToggle;
|
public static Toggle followRotationToggle;
|
||||||
static bool disabledCinemachine;
|
static bool disabledCinemachine;
|
||||||
static bool disabledOrthographic;
|
static bool disabledOrthographic;
|
||||||
|
static bool disabledOcclusionCulling;
|
||||||
static List<string> stringComponentsToDisable = new();
|
static List<string> stringComponentsToDisable = new();
|
||||||
|
|
||||||
private class DisableTarget
|
private class DisableTarget
|
||||||
@@ -319,6 +320,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
// so we will try to move the real camera as well.
|
// so we will try to move the real camera as well.
|
||||||
MaybeToggleCinemachine(false);
|
MaybeToggleCinemachine(false);
|
||||||
MaybeToggleOrthographic(false);
|
MaybeToggleOrthographic(false);
|
||||||
|
MaybeToggleOcclusionCulling(false);
|
||||||
ToggleCustomComponents(false);
|
ToggleCustomComponents(false);
|
||||||
|
|
||||||
cameraMatrixOverrider = new GameObject("CUE Camera").AddComponent<Camera>();
|
cameraMatrixOverrider = new GameObject("CUE Camera").AddComponent<Camera>();
|
||||||
@@ -392,6 +394,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
case FreeCameraType.ForcedMatrix:
|
case FreeCameraType.ForcedMatrix:
|
||||||
MaybeToggleCinemachine(true);
|
MaybeToggleCinemachine(true);
|
||||||
MaybeToggleOrthographic(true);
|
MaybeToggleOrthographic(true);
|
||||||
|
MaybeToggleOcclusionCulling(true);
|
||||||
ToggleCustomComponents(true);
|
ToggleCustomComponents(true);
|
||||||
MethodInfo resetCullingMatrixMethod = typeof(Camera).GetMethod("ResetCullingMatrix", new Type[] {});
|
MethodInfo resetCullingMatrixMethod = typeof(Camera).GetMethod("ResetCullingMatrix", new Type[] {});
|
||||||
resetCullingMatrixMethod.Invoke(ourCamera, null);
|
resetCullingMatrixMethod.Invoke(ourCamera, null);
|
||||||
@@ -528,6 +531,22 @@ namespace UnityExplorer.UI.Panels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MaybeToggleOcclusionCulling(bool enable){
|
||||||
|
if (ourCamera) {
|
||||||
|
if (enable) {
|
||||||
|
if (disabledOcclusionCulling) {
|
||||||
|
ourCamera.useOcclusionCulling = true;
|
||||||
|
disabledOcclusionCulling = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ourCamera.useOcclusionCulling) {
|
||||||
|
disabledOcclusionCulling = true;
|
||||||
|
ourCamera.useOcclusionCulling = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void SetCameraPositionInput(Vector3 pos)
|
static void SetCameraPositionInput(Vector3 pos)
|
||||||
{
|
{
|
||||||
if (!ourCamera || lastSetCameraPosition == pos)
|
if (!ourCamera || lastSetCameraPosition == pos)
|
||||||
@@ -1077,7 +1096,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Behaviour GetComponentByName(GameObject obj, string componentsName)
|
public static Behaviour GetComponentByName(GameObject obj, string componentsName)
|
||||||
{
|
{
|
||||||
if (obj)
|
if (obj)
|
||||||
{
|
{
|
||||||
@@ -1216,6 +1235,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
private Vector3 cachedPosition;
|
private Vector3 cachedPosition;
|
||||||
private Quaternion cachedRotation;
|
private Quaternion cachedRotation;
|
||||||
private CamPaths cachedCamPathsPanel;
|
private CamPaths cachedCamPathsPanel;
|
||||||
|
private bool? hasHDRPComponent = null;
|
||||||
|
|
||||||
internal void Update()
|
internal void Update()
|
||||||
{
|
{
|
||||||
@@ -1714,11 +1734,20 @@ namespace UnityExplorer.UI.Panels
|
|||||||
// HDRP matrix override ignores us moving the camera unfortunately, so we try to copy over the position of the camera matrix overrider.
|
// HDRP matrix override ignores us moving the camera unfortunately, so we try to copy over the position of the camera matrix overrider.
|
||||||
protected void UpdateRealCamera() {
|
protected void UpdateRealCamera() {
|
||||||
if (FreeCamPanel.cameraMatrixOverrider != null) {
|
if (FreeCamPanel.cameraMatrixOverrider != null) {
|
||||||
cachedPosition = FreeCamPanel.ourCamera.transform.position;
|
if (!hasHDRPComponent.HasValue)
|
||||||
FreeCamPanel.ourCamera.transform.position = FreeCamPanel.cameraMatrixOverrider.transform.position;
|
{
|
||||||
// We also try to update the rotation in case there are game shaders that use the real camera rotation
|
var hdrpComponent = FreeCamPanel.GetComponentByName(FreeCamPanel.ourCamera.gameObject, "UnityEngine.Rendering.HighDefinition.HDAdditionalCameraData");
|
||||||
cachedRotation = FreeCamPanel.ourCamera.transform.rotation;
|
hasHDRPComponent = hdrpComponent != null;
|
||||||
FreeCamPanel.ourCamera.transform.rotation = FreeCamPanel.cameraMatrixOverrider.transform.rotation;
|
}
|
||||||
|
|
||||||
|
if (hasHDRPComponent == true)
|
||||||
|
{
|
||||||
|
cachedPosition = FreeCamPanel.ourCamera.transform.position;
|
||||||
|
FreeCamPanel.ourCamera.transform.position = FreeCamPanel.cameraMatrixOverrider.transform.position;
|
||||||
|
// We also try to update the rotation in case there are game shaders that use the real camera rotation
|
||||||
|
cachedRotation = FreeCamPanel.ourCamera.transform.rotation;
|
||||||
|
FreeCamPanel.ourCamera.transform.rotation = FreeCamPanel.cameraMatrixOverrider.transform.rotation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user