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

Commit af66bd0

Browse files
committed
Merge branch 'v2' into ssr
2 parents 77f30bd + ec0c9ee commit af66bd0

9 files changed

Lines changed: 19 additions & 53 deletions

File tree

PostProcessing/Editor/PostProcessLayerEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace UnityEditor.Rendering.PostProcessing
1111
using SerializedBundleRef = PostProcessLayer.SerializedBundleRef;
1212
using EXRFlags = Texture2D.EXRFlags;
1313

14-
[CustomEditor(typeof(PostProcessLayer))]
14+
[CanEditMultipleObjects, CustomEditor(typeof(PostProcessLayer))]
1515
public sealed class PostProcessLayerEditor : BaseEditor<PostProcessLayer>
1616
{
1717
SerializedProperty m_StopNaNPropagation;

PostProcessing/Editor/PostProcessProfileEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace UnityEditor.Rendering.PostProcessing
44
{
5-
[CustomEditor(typeof(PostProcessProfile))]
5+
[CanEditMultipleObjects, CustomEditor(typeof(PostProcessProfile))]
66
sealed class PostProcessProfileEditor : Editor
77
{
88
EffectListEditor m_EffectList;

PostProcessing/Editor/PostProcessVolumeEditor.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
using System.IO;
21
using UnityEngine;
32
using UnityEngine.Rendering.PostProcessing;
43

54
namespace UnityEditor.Rendering.PostProcessing
65
{
7-
[CustomEditor(typeof(PostProcessVolume))]
6+
[CanEditMultipleObjects, CustomEditor(typeof(PostProcessVolume))]
87
public sealed class PostProcessVolumeEditor : BaseEditor<PostProcessVolume>
98
{
109
SerializedProperty m_Profile;

PostProcessing/Runtime/Effects/Fog.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,11 @@ internal void Render(PostProcessRenderContext context)
2828
{
2929
var sheet = context.propertySheets.Get(context.resources.shaders.deferredFog);
3030
sheet.ClearKeywords();
31+
3132
var fogColor = RuntimeUtilities.isLinearColorSpace ? RenderSettings.fogColor.linear : RenderSettings.fogColor;
3233
sheet.properties.SetVector(ShaderIDs.FogColor, fogColor);
3334
sheet.properties.SetVector(ShaderIDs.FogParams, new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance));
3435

35-
switch (RenderSettings.fogMode)
36-
{
37-
case FogMode.Linear:
38-
sheet.EnableKeyword("FOG_LINEAR");
39-
break;
40-
case FogMode.Exponential:
41-
sheet.EnableKeyword("FOG_EXP");
42-
break;
43-
case FogMode.ExponentialSquared:
44-
sheet.EnableKeyword("FOG_EXP2");
45-
break;
46-
}
47-
4836
var cmd = context.command;
4937
cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, excludeSkybox ? 1 : 0);
5038
}

PostProcessing/Runtime/Effects/MultiScaleVO.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@ void PushDownsampleCommands(PostProcessRenderContext context, CommandBuffer cmd)
339339
if (useDepthCopy)
340340
{
341341
m_DepthCopy.PushAllocationCommand(cmd);
342-
cmd.SetRenderTarget(m_DepthCopy.id);
343-
cmd.DrawProcedural(Matrix4x4.identity, m_PropertySheet.material, (int)Pass.DepthCopy, MeshTopology.Triangles, 3);
342+
cmd.BlitFullscreenTriangle(BuiltinRenderTextureType.None, m_DepthCopy.id, m_PropertySheet, (int)Pass.DepthCopy);
344343
}
345344

346345
// Temporary buffer allocations.
@@ -532,23 +531,11 @@ public void RenderAfterOpaque(PostProcessRenderContext context)
532531
// Not needed in Deferred.
533532
if (context.camera.actualRenderingPath == RenderingPath.Forward && RenderSettings.fog)
534533
{
534+
sheet.EnableKeyword("APPLY_FORWARD_FOG");
535535
sheet.properties.SetVector(
536536
ShaderIDs.FogParams,
537537
new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance)
538538
);
539-
540-
switch (RenderSettings.fogMode)
541-
{
542-
case FogMode.Linear:
543-
sheet.EnableKeyword("FOG_LINEAR");
544-
break;
545-
case FogMode.Exponential:
546-
sheet.EnableKeyword("FOG_EXP");
547-
break;
548-
case FogMode.ExponentialSquared:
549-
sheet.EnableKeyword("FOG_EXP2");
550-
break;
551-
}
552539
}
553540

554541
RebuildCommandBuffers(context);

PostProcessing/Runtime/Effects/ScalableAO.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,11 @@ void Render(PostProcessRenderContext context, CommandBuffer cmd, int occlusionSo
114114
// Not needed in Deferred.
115115
if (context.camera.actualRenderingPath == RenderingPath.Forward && RenderSettings.fog)
116116
{
117+
sheet.EnableKeyword("APPLY_FORWARD_FOG");
117118
sheet.properties.SetVector(
118119
ShaderIDs.FogParams,
119120
new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance)
120121
);
121-
122-
switch (RenderSettings.fogMode)
123-
{
124-
case FogMode.Linear:
125-
sheet.EnableKeyword("FOG_LINEAR");
126-
break;
127-
case FogMode.Exponential:
128-
sheet.EnableKeyword("FOG_EXP");
129-
break;
130-
case FogMode.ExponentialSquared:
131-
sheet.EnableKeyword("FOG_EXP2");
132-
break;
133-
}
134122
}
135123

136124
// Texture setup

PostProcessing/Shaders/Builtins/MultiScaleVO.shader

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
8080

8181
HLSLPROGRAM
8282

83+
#pragma multi_compile _ APPLY_FORWARD_FOG
8384
#pragma multi_compile _ FOG_LINEAR FOG_EXP FOG_EXP2
8485
#pragma vertex Vert
8586
#pragma fragment Frag
@@ -90,7 +91,7 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
9091
half ao = 1.0 - SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, texcoord).r;
9192

9293
// Apply fog when enabled (forward-only)
93-
#if (FOG_LINEAR || FOG_EXP || FOG_EXP2)
94+
#if (APPLY_FORWARD_FOG)
9495
float d = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, texcoord));
9596
d = ComputeFogDistance(d);
9697
ao *= ComputeFog(d);

PostProcessing/Shaders/Builtins/ScalableAO.hlsl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ float4 FragAO(VaryingsDefault i) : SV_Target
247247
ao = PositivePow(ao * INTENSITY / SAMPLE_COUNT, kContrast);
248248

249249
// Apply fog when enabled (forward-only)
250-
#if (FOG_LINEAR || FOG_EXP || FOG_EXP2)
250+
#if (APPLY_FORWARD_FOG)
251251
float d = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(uv)));
252252
d = ComputeFogDistance(d);
253253
ao *= ComputeFog(d);
@@ -383,9 +383,10 @@ half BlurSmall(TEXTURE2D_ARGS(tex, samp), float2 uv, float2 delta)
383383
// Final composition shader
384384
float4 FragComposition(VaryingsDefault i) : SV_Target
385385
{
386-
float2 delta = _MainTex_TexelSize.xy / DOWNSAMPLE;
386+
float2 delta = _SAOcclusionTexture_TexelSize.xy / DOWNSAMPLE;
387387
half ao = BlurSmall(TEXTURE2D_PARAM(_SAOcclusionTexture, sampler_SAOcclusionTexture), i.texcoord, delta);
388-
return float4(EncodeAO(ao) * _AOColor, 0.0);
388+
ao = EncodeAO(ao);
389+
return float4(ao * _AOColor, ao);
389390
}
390391

391392
#if !SHADER_API_GLES // Excluding the MRT pass under GLES2

PostProcessing/Shaders/Builtins/ScalableAO.shader

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Shader "Hidden/PostProcessing/ScalableAO"
1818

1919
#pragma vertex VertDefault
2020
#pragma fragment FragAO
21+
#pragma multi_compile _ APPLY_FORWARD_FOG
2122
#pragma multi_compile _ FOG_LINEAR FOG_EXP FOG_EXP2
2223
#define SOURCE_DEPTH
2324
#include "ScalableAO.hlsl"
@@ -32,6 +33,7 @@ Shader "Hidden/PostProcessing/ScalableAO"
3233

3334
#pragma vertex VertDefault
3435
#pragma fragment FragAO
36+
#pragma multi_compile _ APPLY_FORWARD_FOG
3537
#pragma multi_compile _ FOG_LINEAR FOG_EXP FOG_EXP2
3638
#define SOURCE_GBUFFER
3739
#include "ScalableAO.hlsl"
@@ -54,7 +56,7 @@ Shader "Hidden/PostProcessing/ScalableAO"
5456
ENDHLSL
5557
}
5658

57-
// 4 - Separable blur (horizontal pass) with G-Buffer
59+
// 3 - Separable blur (horizontal pass) with G-Buffer
5860
Pass
5961
{
6062
HLSLPROGRAM
@@ -69,7 +71,7 @@ Shader "Hidden/PostProcessing/ScalableAO"
6971
ENDHLSL
7072
}
7173

72-
// 5 - Separable blur (vertical pass)
74+
// 4 - Separable blur (vertical pass)
7375
Pass
7476
{
7577
HLSLPROGRAM
@@ -82,7 +84,7 @@ Shader "Hidden/PostProcessing/ScalableAO"
8284
ENDHLSL
8385
}
8486

85-
// 6 - Final composition
87+
// 5 - Final composition
8688
Pass
8789
{
8890
Blend Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
@@ -96,7 +98,7 @@ Shader "Hidden/PostProcessing/ScalableAO"
9698
ENDHLSL
9799
}
98100

99-
// 7 - Final composition (ambient only mode)
101+
// 6 - Final composition (ambient only mode)
100102
Pass
101103
{
102104
Blend Zero OneMinusSrcColor, Zero OneMinusSrcAlpha

0 commit comments

Comments
 (0)