Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 75e98cf

Browse files
committed
Fixed DoF focus changing with screen size
1 parent 1dc71f3 commit 75e98cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

PostProcessing/Runtime/Effects/DepthOfField.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@ public override void Render(PostProcessRenderContext context)
132132
#endif
133133

134134
// Material setup
135+
float scaledFilmHeight = k_FilmHeight * (context.height / 1080f);
135136
var f = settings.focalLength.value / 1000f;
136137
var s1 = Mathf.Max(settings.focusDistance.value, f);
137138
var aspect = (float)context.screenWidth / (float)context.screenHeight;
138-
var coeff = f * f / (settings.aperture.value * (s1 - f) * k_FilmHeight * 2);
139+
var coeff = f * f / (settings.aperture.value * (s1 - f) * scaledFilmHeight * 2f);
139140
var maxCoC = CalculateMaxCoCRadius(context.screenHeight);
140141

141142
var sheet = context.propertySheets.Get(context.resources.shaders.depthOfField);

0 commit comments

Comments
 (0)