Browse Source

Lerping DoF kinda works

Marcel Zickler 3 years ago
parent
commit
fd2d4f0720

+ 2 - 2
Assets/Materials/Vignette.mat

@@ -58,10 +58,10 @@ Material:
     - _GlossMapScale: 0
     - _Glossiness: 0
     - _GlossyReflections: 0
-    - _IFOV: 0
+    - _IFOV: 0.94742805
     - _InnerRadius: 0.15
     - _Metallic: 0
-    - _OFOV: 0.299
+    - _OFOV: 0.99742806
     - _OcclusionStrength: 1
     - _QueueOffset: 0
     - _ReceiveShadows: 1

+ 5 - 5
Assets/Scenes/MainScene.unity

@@ -208567,8 +208567,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: aa2123de9a044612afdcd36b95b61a51, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  maxFactorRadiusCOC: 0.0175
-  refocusTimePerMeter: 0.0000017
+  maxFactorRadiusCOC: 0.22
+  refocusTimePerMeter: 0.00008
   maxFocusDistance: 30000
   playerCamera: {fileID: 82271104}
   postProcessProfile: {fileID: 11400000, guid: 0163074491301254a9c140b40401b296, type: 2}
@@ -454155,7 +454155,7 @@ PrefabInstance:
     - target: {fileID: 4988978072042319893, guid: 3b07d6594636ab04d9c1fac04c1cde7e,
         type: 3}
       propertyPath: m_Enabled
-      value: 1
+      value: 0
       objectReference: {fileID: 0}
     - target: {fileID: 4988978072042319893, guid: 3b07d6594636ab04d9c1fac04c1cde7e,
         type: 3}
@@ -454185,7 +454185,7 @@ PrefabInstance:
     - target: {fileID: 4988978072042319978, guid: 3b07d6594636ab04d9c1fac04c1cde7e,
         type: 3}
       propertyPath: m_Enabled
-      value: 0
+      value: 1
       objectReference: {fileID: 0}
     - target: {fileID: 4988978072042319979, guid: 3b07d6594636ab04d9c1fac04c1cde7e,
         type: 3}
@@ -454205,7 +454205,7 @@ PrefabInstance:
     - target: {fileID: 4988978072042319980, guid: 3b07d6594636ab04d9c1fac04c1cde7e,
         type: 3}
       propertyPath: m_Enabled
-      value: 0
+      value: 1
       objectReference: {fileID: 0}
     - target: {fileID: 4988978072042319980, guid: 3b07d6594636ab04d9c1fac04c1cde7e,
         type: 3}

+ 7 - 7
Assets/Scenes/MainScene/PP Volume.asset

@@ -35,18 +35,18 @@ MonoBehaviour:
     m_Value: 0
   focusDistance:
     m_OverrideState: 1
-    m_Value: 3.8978117
+    m_Value: 0.58
     min: -110000000
   aperture:
     m_OverrideState: 1
-    m_Value: 1
-    min: 1
-    max: 110000000
+    m_Value: 1.2687209e+38
+    min: 0
+    max: 3.4028235e+38
   focalLength:
     m_OverrideState: 1
-    m_Value: 1
-    min: -100000
-    max: 10000000
+    m_Value: 7.006394e+36
+    min: 0
+    max: 3.4028235e+38
   bladeCount:
     m_OverrideState: 0
     m_Value: 5

+ 7 - 2
Assets/Scripts/SicknessReduction/Visual/DoF/DynamicDoF.cs

@@ -26,12 +26,15 @@ namespace SicknessReduction.Visual.DoF
         private Transform cameraTransform;
         private DepthOfField doF;
         private bool doFAvailable;
+        private float maxCocRadius;
 
         private List<float> rayDistances = new List<float>(NUMBER_OF_RAYS);
 
         private void Start()
         {
             cameraTransform = playerCamera.transform;
+            //Debug.Log($"Screen Width = {playerCamera.pixelWidth}, scaled = {playerCamera.scaledPixelWidth}");
+            //maxCocRadius = maxFactorRadiusCOC * playerCamera.scaledPixelWidth; FIXME: waaaay to small
             doF = (DepthOfField) postProcessProfile.components.FirstOrDefault(c => c is DepthOfField);
             doFAvailable = doF != null;
             if (doFAvailable)
@@ -55,8 +58,8 @@ namespace SicknessReduction.Visual.DoF
             var focusDistance = CastRays();
             if (focusDistance < 0)
             {
-                doF.active = false;
-                return;
+                focusDistance = doF.focusDistance.value;
+                //return;
             }
 
             /*For real-time performance, we
@@ -68,7 +71,9 @@ translates to a linear interpolation between focal
 distances that takes ≈ 1.7*/
             doF.active = true;
             var timeNeededToRefocus = Mathf.Abs(focusDistance - doF.focusDistance.value) * refocusTimePerMeter;
+            Debug.Log($"Lerping focusDistance before = {focusDistance}, dof.focusDistance = {doF.focusDistance.value}, time for refocus = {timeNeededToRefocus}, delta = {Time.deltaTime}");
             focusDistance = Mathf.Lerp(doF.focusDistance.value, focusDistance, Time.deltaTime / timeNeededToRefocus);
+            Debug.Log($"Lerping focusDistance after = {focusDistance}");
             doF.focusDistance.value = focusDistance;
             doF.focalLength.value = 1;
             doF.aperture.value = ApertureForCocAndFocusDistance(maxFactorRadiusCOC, focusDistance);

BIN
obj/Debug/Assembly-CSharp.csprojAssemblyReference.cache