|
@@ -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);
|