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

Commit e0aac40

Browse files
committed
Merge remote-tracking branch 'origin/v2' into xr_taa
2 parents 14f65f5 + 3be7883 commit e0aac40

14 files changed

Lines changed: 52 additions & 59 deletions

PostProcessing/Editor/PostProcessLayerEditor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public sealed class PostProcessLayerEditor : BaseEditor<PostProcessLayer>
2020

2121
SerializedProperty m_AntialiasingMode;
2222
SerializedProperty m_TaaJitterSpread;
23-
SerializedProperty m_TaaSharpen;
23+
SerializedProperty m_TaaSharpness;
2424
SerializedProperty m_TaaStationaryBlending;
2525
SerializedProperty m_TaaMotionBlending;
2626
SerializedProperty m_FxaaMobileOptimized;
@@ -76,7 +76,7 @@ void OnEnable()
7676

7777
m_AntialiasingMode = FindProperty(x => x.antialiasingMode);
7878
m_TaaJitterSpread = FindProperty(x => x.temporalAntialiasing.jitterSpread);
79-
m_TaaSharpen = FindProperty(x => x.temporalAntialiasing.sharpen);
79+
m_TaaSharpness = FindProperty(x => x.temporalAntialiasing.sharpness);
8080
m_TaaStationaryBlending = FindProperty(x => x.temporalAntialiasing.stationaryBlending);
8181
m_TaaMotionBlending = FindProperty(x => x.temporalAntialiasing.motionBlending);
8282
m_FxaaMobileOptimized = FindProperty(x => x.fastApproximateAntialiasing.mobileOptimized);
@@ -211,7 +211,7 @@ void DoAntialiasing()
211211
EditorGUILayout.PropertyField(m_TaaJitterSpread);
212212
EditorGUILayout.PropertyField(m_TaaStationaryBlending);
213213
EditorGUILayout.PropertyField(m_TaaMotionBlending);
214-
EditorGUILayout.PropertyField(m_TaaSharpen);
214+
EditorGUILayout.PropertyField(m_TaaSharpness);
215215
}
216216
else if (m_AntialiasingMode.intValue == (int)PostProcessLayer.Antialiasing.SubpixelMorphologicalAntialiasing)
217217
{

PostProcessing/Runtime/Effects/TemporalAntialiasing.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ public sealed class TemporalAntialiasing
1010
[Range(0.1f, 1f)]
1111
public float jitterSpread = 0.75f;
1212

13-
[Tooltip("Controls the amount of sharpening applied to the color buffer.")]
13+
[Tooltip("Controls the amount of sharpening applied to the color buffer. High values may introduce dark-border artifacts.")]
1414
[Range(0f, 3f)]
15-
public float sharpen = 0.25f;
15+
public float sharpness = 0.25f;
1616

1717
[Tooltip("The blend coefficient for a stationary fragment. Controls the percentage of history sample blended into the final color.")]
1818
[Range(0f, 0.99f)]
@@ -195,7 +195,7 @@ internal void Render(PostProcessRenderContext context)
195195

196196
const float kMotionAmplification = 100f * 60f;
197197
sheet.properties.SetVector(ShaderIDs.Jitter, jitter);
198-
sheet.properties.SetFloat(ShaderIDs.SharpenParameters, sharpen);
198+
sheet.properties.SetFloat(ShaderIDs.Sharpness, sharpness);
199199
sheet.properties.SetVector(ShaderIDs.FinalBlendParameters, new Vector4(stationaryBlending, motionBlending, kMotionAmplification, 0f));
200200
sheet.properties.SetTexture(ShaderIDs.HistoryTex, historyRead);
201201

PostProcessing/Runtime/PostProcessDebug.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void OnDisable()
3535
#endif
3636

3737
if (m_CurrentCamera != null)
38-
m_CurrentCamera.RemoveCommandBuffer(CameraEvent.AfterEverything, m_CmdAfterEverything);
38+
m_CurrentCamera.RemoveCommandBuffer(CameraEvent.AfterImageEffects, m_CmdAfterEverything);
3939

4040
m_CurrentCamera = null;
4141
m_PreviousPostProcessLayer = null;
@@ -60,7 +60,7 @@ void UpdateStates()
6060
// Remove cmdbuffer from previously set camera
6161
if (m_CurrentCamera != null)
6262
{
63-
m_CurrentCamera.RemoveCommandBuffer(CameraEvent.AfterEverything, m_CmdAfterEverything);
63+
m_CurrentCamera.RemoveCommandBuffer(CameraEvent.AfterImageEffects, m_CmdAfterEverything);
6464
m_CurrentCamera = null;
6565
}
6666

@@ -70,7 +70,7 @@ void UpdateStates()
7070
if (postProcessLayer != null)
7171
{
7272
m_CurrentCamera = postProcessLayer.GetComponent<Camera>();
73-
m_CurrentCamera.AddCommandBuffer(CameraEvent.AfterEverything, m_CmdAfterEverything);
73+
m_CurrentCamera.AddCommandBuffer(CameraEvent.AfterImageEffects, m_CmdAfterEverything);
7474
}
7575
}
7676

PostProcessing/Runtime/Utils/RuntimeUtilities.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ public static bool isSinglePassStereoEnabled
230230
{
231231
#if UNITY_EDITOR
232232
return UnityEditor.PlayerSettings.virtualRealitySupported
233-
&& UnityEditor.PlayerSettings.stereoRenderingPath == UnityEditor.StereoRenderingPath.SinglePass;
233+
&& UnityEditor.PlayerSettings.stereoRenderingPath == UnityEditor.StereoRenderingPath.SinglePass
234+
&& Application.isPlaying;
234235
#else
235236
return false;
236237
#endif

PostProcessing/Runtime/Utils/ShaderIDs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ static class ShaderIDs
88
internal static readonly int MainTex = Shader.PropertyToID("_MainTex");
99

1010
internal static readonly int Jitter = Shader.PropertyToID("_Jitter");
11-
internal static readonly int SharpenParameters = Shader.PropertyToID("_SharpenParameters");
11+
internal static readonly int Sharpness = Shader.PropertyToID("_Sharpness");
1212
internal static readonly int FinalBlendParameters = Shader.PropertyToID("_FinalBlendParameters");
1313
internal static readonly int HistoryTex = Shader.PropertyToID("_HistoryTex");
1414

PostProcessing/Shaders/Builtins/DeferredFog.shader

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ Shader "Hidden/PostProcessing/DeferredFog"
1313

1414
float4 Frag(VaryingsDefault i) : SV_Target
1515
{
16-
float2 uv = UnityStereoTransformScreenSpaceTex(i.texcoord);
17-
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
16+
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
1817

19-
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv);
18+
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
2019
depth = Linear01Depth(depth);
2120
float dist = ComputeFogDistance(depth);
2221
half fog = 1.0 - ComputeFog(dist);
@@ -26,10 +25,9 @@ Shader "Hidden/PostProcessing/DeferredFog"
2625

2726
float4 FragExcludeSkybox(VaryingsDefault i) : SV_Target
2827
{
29-
float2 uv = UnityStereoTransformScreenSpaceTex(i.texcoord);
30-
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
28+
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
3129

32-
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv);
30+
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
3331
depth = Linear01Depth(depth);
3432
float skybox = depth < SKYBOX_THREASHOLD_VALUE;
3533
float dist = ComputeFogDistance(depth);

PostProcessing/Shaders/Builtins/DepthOfField.hlsl

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ half3 _TaaParams; // Jitter.x, Jitter.y, Blending
2727
// CoC calculation
2828
half4 FragCoC(VaryingsDefault i) : SV_Target
2929
{
30-
float depth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.texcoord)));
30+
float depth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo));
3131
half coc = (depth - _Distance) * _LensCoeff / max(depth, 1e-5);
3232
return saturate(coc * 0.5 * _RcpMaxCoC + 0.5);
3333
}
@@ -71,7 +71,7 @@ half4 FragTempFilter(VaryingsDefault i) : SV_Target
7171

7272
// Neighborhood clamping
7373
half cocMin = closest.z;
74-
half cocMax = max(max(max(max(coc0, coc1), coc2), coc3), coc4); // TODO: Switch to Max3
74+
half cocMax = Max3(Max3(coc0, coc1, coc2), coc3, coc4);
7575
cocHis = clamp(cocHis, cocMin, cocMax);
7676

7777
// Blend with the history
@@ -84,18 +84,17 @@ half4 FragPrefilter(VaryingsDefault i) : SV_Target
8484
#if UNITY_GATHER_SUPPORTED
8585

8686
// Sample source colors
87-
i.texcoord = UnityStereoTransformScreenSpaceTex(i.texcoord);
88-
half4 c_r = GATHER_RED_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
89-
half4 c_g = GATHER_GREEN_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
90-
half4 c_b = GATHER_BLUE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
87+
half4 c_r = GATHER_RED_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
88+
half4 c_g = GATHER_GREEN_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
89+
half4 c_b = GATHER_BLUE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
9190

9291
half3 c0 = half3(c_r.x, c_g.x, c_b.x);
9392
half3 c1 = half3(c_r.y, c_g.y, c_b.y);
9493
half3 c2 = half3(c_r.z, c_g.z, c_b.z);
9594
half3 c3 = half3(c_r.w, c_g.w, c_b.w);
9695

9796
// Sample CoCs
98-
half4 cocs = GATHER_TEXTURE2D(_CoCTex, sampler_CoCTex, i.texcoord) * 2.0 - 1.0;
97+
half4 cocs = GATHER_TEXTURE2D(_CoCTex, sampler_CoCTex, i.texcoordStereo) * 2.0 - 1.0;
9998
half coc0 = cocs.x;
10099
half coc1 = cocs.y;
101100
half coc2 = cocs.z;
@@ -151,7 +150,7 @@ half4 FragPrefilter(VaryingsDefault i) : SV_Target
151150
// Bokeh filter with disk-shaped kernels
152151
half4 FragBlur(VaryingsDefault i) : SV_Target
153152
{
154-
half4 samp0 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex(i.texcoord));
153+
half4 samp0 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
155154

156155
half4 bgAcc = 0.0; // Background: far field bokeh
157156
half4 fgAcc = 0.0; // Foreground: near field bokeh
@@ -218,15 +217,14 @@ half4 FragPostBlur(VaryingsDefault i) : SV_Target
218217
// Combine with source
219218
half4 FragCombine(VaryingsDefault i) : SV_Target
220219
{
221-
i.texcoord = UnityStereoTransformScreenSpaceTex(i.texcoord);
222-
half4 dof = SAMPLE_TEXTURE2D(_DepthOfFieldTex, sampler_DepthOfFieldTex, i.texcoord);
223-
half coc = SAMPLE_TEXTURE2D(_CoCTex, sampler_CoCTex, i.texcoord).r;
220+
half4 dof = SAMPLE_TEXTURE2D(_DepthOfFieldTex, sampler_DepthOfFieldTex, i.texcoordStereo);
221+
half coc = SAMPLE_TEXTURE2D(_CoCTex, sampler_CoCTex, i.texcoordStereo).r;
224222
coc = (coc - 0.5) * 2.0 * _MaxCoC;
225223

226224
// Convert CoC to far field alpha value.
227225
float ffa = smoothstep(_MainTex_TexelSize.y * 2.0, _MainTex_TexelSize.y * 4.0, coc);
228226

229-
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
227+
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
230228

231229
#if defined(UNITY_COLORSPACE_GAMMA)
232230
color = SRGBToLinear(color);
@@ -247,12 +245,11 @@ half4 FragCombine(VaryingsDefault i) : SV_Target
247245
// Debug overlay
248246
half4 FragDebugOverlay(VaryingsDefault i) : SV_Target
249247
{
250-
i.texcoord = UnityStereoTransformScreenSpaceTex(i.texcoord);
251-
half3 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord).rgb;
248+
half3 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo).rgb;
252249

253250
// Calculate the radiuses of CoC.
254-
half4 src = SAMPLE_TEXTURE2D(_DepthOfFieldTex, sampler_DepthOfFieldTex, i.texcoord);
255-
float depth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord));
251+
half4 src = SAMPLE_TEXTURE2D(_DepthOfFieldTex, sampler_DepthOfFieldTex, i.texcoordStereo);
252+
float depth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo));
256253
float coc = (depth - _Distance) * _LensCoeff / depth;
257254
coc *= 80;
258255

PostProcessing/Shaders/Builtins/FinalPass.shader

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Shader "Hidden/PostProcessing/FinalPass"
4040
float4 Frag(VaryingsDefault i) : SV_Target
4141
{
4242
half4 color = 0.0;
43-
float2 uvSPR = UnityStereoTransformScreenSpaceTex(i.texcoord);
4443

4544
// Fast Approximate Anti-aliasing
4645
#if FXAA || FXAA_LOW
@@ -74,13 +73,13 @@ Shader "Hidden/PostProcessing/FinalPass"
7473

7574
#if FXAA_KEEP_ALPHA
7675
{
77-
color.a = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uvSPR).a;
76+
color.a = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo).a;
7877
}
7978
#endif
8079
}
8180
#else
8281
{
83-
color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uvSPR);
82+
color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
8483
}
8584
#endif
8685

PostProcessing/Shaders/Builtins/MultiScaleVO.shader

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
113113

114114
float4 Frag(VaryingsDefault i) : SV_Target
115115
{
116-
float2 texcoord = TransformStereoScreenSpaceTex(i.texcoord, 1);
117-
half ao = SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, texcoord).r;
116+
half ao = SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, i.texcoord).r;
118117
return float4(ao.rrr, 1.0);
119118
}
120119

PostProcessing/Shaders/Builtins/ScalableAO.hlsl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ float4 FragAO(VaryingsDefault i) : SV_Target
248248

249249
// Apply fog when enabled (forward-only)
250250
#if (APPLY_FORWARD_FOG)
251-
float d = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(uv)));
251+
float d = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo));
252252
d = ComputeFogDistance(d);
253253
ao *= ComputeFog(d);
254254
#endif
@@ -269,13 +269,11 @@ float4 FragBlur(VaryingsDefault i) : SV_Target
269269
float2 delta = float2(0.0, _MainTex_TexelSize.y / DOWNSAMPLE * 2.0);
270270
#endif
271271

272-
float2 uvSpr = UnityStereoTransformScreenSpaceTex(i.texcoord);
273-
274272
#if defined(BLUR_HIGH_QUALITY)
275273

276274
// High quality 7-tap Gaussian with adaptive sampling
277275

278-
half4 p0 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uvSpr);
276+
half4 p0 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
279277
half4 p1a = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex(i.texcoord - delta));
280278
half4 p1b = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex(i.texcoord + delta));
281279
half4 p2a = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex(i.texcoord - delta * 2.0));
@@ -284,7 +282,7 @@ float4 FragBlur(VaryingsDefault i) : SV_Target
284282
half4 p3b = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex(i.texcoord + delta * 3.2307692308));
285283

286284
#if defined(BLUR_SAMPLE_CENTER_NORMAL)
287-
half3 n0 = SampleNormal(uvSpr);
285+
half3 n0 = SampleNormal(i.texcoordStereo);
288286
#else
289287
half3 n0 = GetPackedNormal(p0);
290288
#endif
@@ -311,14 +309,14 @@ float4 FragBlur(VaryingsDefault i) : SV_Target
311309
#else
312310

313311
// Fater 5-tap Gaussian with linear sampling
314-
half4 p0 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uvSpr);
312+
half4 p0 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
315313
half4 p1a = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex(i.texcoord - delta * 1.3846153846));
316314
half4 p1b = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex(i.texcoord + delta * 1.3846153846));
317315
half4 p2a = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex(i.texcoord - delta * 3.2307692308));
318316
half4 p2b = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex(i.texcoord + delta * 3.2307692308));
319317

320318
#if defined(BLUR_SAMPLE_CENTER_NORMAL)
321-
half3 n0 = SampleNormal(uvSpr);
319+
half3 n0 = SampleNormal(i.texcoordStereo);
322320
#else
323321
half3 n0 = GetPackedNormal(p0);
324322
#endif

0 commit comments

Comments
 (0)