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

Commit 37bf8f1

Browse files
committed
Merge remote-tracking branch 'refs/remotes/Unity-Technologies/master'
2 parents e549f26 + 13d70bb commit 37bf8f1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

PostProcessing/Resources/Shaders/Uber.shader

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ Shader "Hidden/Post FX/Uber Shader"
114114
#endif
115115

116116
half3 color = (0.0).xxx;
117+
#if DEPTH_OF_FIELD && CHROMATIC_ABERRATION
118+
half4 dof = (0.0).xxxx;
119+
#endif
117120

118121
//
119122
// HDR effects
@@ -134,6 +137,17 @@ Shader "Hidden/Post FX/Uber Shader"
134137
float2 pos = uv;
135138
half3 sum = (0.0).xxx, filterSum = (0.0).xxx;
136139

140+
#if DEPTH_OF_FIELD
141+
float2 dofDelta = delta;
142+
float2 dofPos = pos;
143+
if (_MainTex_TexelSize.y < 0.0)
144+
{
145+
dofDelta.y = -dofDelta.y;
146+
dofPos.y = 1.0 - dofPos.y;
147+
}
148+
half4 dofSum = (0.0).xxxx;
149+
#endif
150+
137151
for (int i = 0; i < samples; i++)
138152
{
139153
half t = (i + 0.5) / samples;
@@ -143,9 +157,18 @@ Shader "Hidden/Post FX/Uber Shader"
143157
sum += s * filter;
144158
filterSum += filter;
145159
pos += delta;
160+
161+
#if DEPTH_OF_FIELD
162+
half4 sdof = tex2Dlod(_DepthOfFieldTex, float4(UnityStereoScreenSpaceUVAdjust(dofPos, _MainTex_ST), 0, 0)).rgba;
163+
dofSum += sdof * half4(filter, 1);
164+
dofPos += dofDelta;
165+
#endif
146166
}
147167

148168
color = sum / filterSum;
169+
#if DEPTH_OF_FIELD
170+
dof = dofSum / half4(filterSum, samples);
171+
#endif
149172
}
150173
#else
151174
{
@@ -166,7 +189,9 @@ Shader "Hidden/Post FX/Uber Shader"
166189
// Depth of field
167190
#if DEPTH_OF_FIELD
168191
{
192+
#if !CHROMATIC_ABERRATION
169193
half4 dof = tex2D(_DepthOfFieldTex, i.uvFlippedSPR);
194+
#endif
170195
color = color * dof.a + dof.rgb * autoExposure;
171196
}
172197
#elif DEPTH_OF_FIELD_COC_VIEW

0 commit comments

Comments
 (0)