Skip to content

Instantly share code, notes, and snippets.

@fauxnik
Created August 15, 2020 10:06
Show Gist options
  • Save fauxnik/aad9d3f10244cb4370c7600c75426fdc to your computer and use it in GitHub Desktop.
Save fauxnik/aad9d3f10244cb4370c7600c75426fdc to your computer and use it in GitHub Desktop.
stereo separation manual counteraction not working
diff --git a/Constraints.cs b/Constraints.cs
index 3c65282..1f751aa 100644
--- a/Constraints.cs
+++ b/Constraints.cs
@@ -13,11 +13,15 @@ namespace ProceduralSkyMod
{
public Camera main;
public Camera sky;
+ public Camera skyRight;
public Camera clear;
void OnPreCull()
{
- clear.transform.rotation = sky.transform.rotation = main.transform.rotation;
+ clear.transform.rotation = skyRight.transform.rotation = sky.transform.rotation = main.transform.rotation;
+ skyRight.transform.position = sky.transform.position - sky.stereoSeparation * sky.transform.right;
+ //skyRight.transform.position = sky.transform.position + 10f * sky.transform.right;
+ //Debug.Log($"left eye {sky.transform.position * 10} right eye {skyRight.transform.position * 10} separation {sky.stereoSeparation * 10}");
clear.transform.position = main.transform.position;
clear.fieldOfView = sky.fieldOfView = main.fieldOfView;
}
diff --git a/ProceduralSkyInitializer.cs b/ProceduralSkyInitializer.cs
index 23a0875..295f171 100644
--- a/ProceduralSkyInitializer.cs
+++ b/ProceduralSkyInitializer.cs
@@ -95,6 +95,10 @@ namespace ProceduralSkyMod
skyCam.fieldOfView = mainCam.fieldOfView;
skyCam.nearClipPlane = mainCam.nearClipPlane;
skyCam.farClipPlane = 100;
+ skyCam.stereoTargetEye = StereoTargetEyeMask.Left;
+ skyCam.gameObject.AddComponent<PositionConstraintOnPreCull>().source = psMaster.transform;
+ Camera skyCamRight = GameObject.Instantiate(skyCam);
+ skyCamRight.stereoTargetEye = StereoTargetEyeMask.Right;
// clear cam
Camera clearCam = new GameObject() { name = "ClearCam" }.AddComponent<Camera>();
@@ -106,11 +110,9 @@ namespace ProceduralSkyMod
SkyCamConstraint constraint = skyCam.gameObject.AddComponent<SkyCamConstraint>();
constraint.main = mainCam;
constraint.sky = skyCam;
+ constraint.skyRight = skyCamRight;
constraint.clear = clearCam;
- PositionConstraintOnPreCull overrideHMD = skyCam.gameObject.AddComponent<PositionConstraintOnPreCull>();
- overrideHMD.source = psMaster.transform;
-
// cloud render texture cam
Camera cloudRendTexCam = new GameObject() { name = "CloudRendTexCam" }.AddComponent<Camera>();
cloudRendTexCam.transform.SetParent(psMaster.transform);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment