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

Commit 30a10b6

Browse files
committed
Renamed Uniforms to ShaderIDs
1 parent 5b1e206 commit 30a10b6

20 files changed

+211
-210
lines changed

PostProcessing/Runtime/Effects/AmbientOcclusion.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ PropertySheet PreRender(PostProcessRenderContext context, int occlusionSource)
8585

8686
var sheet = context.propertySheets.Get(context.resources.shaders.ambientOcclusion);
8787
sheet.ClearKeywords();
88-
sheet.properties.SetVector(Uniforms._AOParams, new Vector4(px, py, pz, pw));
88+
sheet.properties.SetVector(ShaderIDs.AOParams, new Vector4(px, py, pz, pw));
8989

9090
// In forward fog is applied at the object level in the grometry pass so we need to
9191
// apply it to AO as well or it'll drawn on top of the fog effect.
9292
// Not needed in Deferred.
9393
if (context.camera.actualRenderingPath == RenderingPath.Forward && RenderSettings.fog)
9494
{
95-
sheet.properties.SetVector(Uniforms._FogParams, new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance));
95+
sheet.properties.SetVector(ShaderIDs.FogParams, new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance));
9696

9797
switch (RenderSettings.fogMode)
9898
{
@@ -117,22 +117,22 @@ PropertySheet PreRender(PostProcessRenderContext context, int occlusionSource)
117117
const FilterMode kFilter = FilterMode.Bilinear;
118118

119119
// AO buffer
120-
var rtMask = Uniforms._OcclusionTexture1;
120+
var rtMask = ShaderIDs.OcclusionTexture1;
121121
cmd.GetTemporaryRT(rtMask, tw / ts, th / ts, 0, kFilter, kFormat, kRWMode);
122122

123123
// AO estimation
124124
cmd.BlitFullscreenTriangle(BuiltinRenderTextureType.None, rtMask, sheet, (int)Pass.OcclusionEstimationForward + occlusionSource);
125125

126126
// Blur buffer
127-
var rtBlur = Uniforms._OcclusionTexture2;
127+
var rtBlur = ShaderIDs.OcclusionTexture2;
128128

129129
// Separable blur (horizontal pass)
130130
cmd.GetTemporaryRT(rtBlur, tw, th, 0, kFilter, kFormat, kRWMode);
131131
cmd.BlitFullscreenTriangle(rtMask, rtBlur, sheet, (int)Pass.HorizontalBlurForward + occlusionSource);
132132
cmd.ReleaseTemporaryRT(rtMask);
133133

134134
// Separable blur (vertical pass)
135-
rtMask = Uniforms._OcclusionTexture;
135+
rtMask = ShaderIDs.OcclusionTexture;
136136
cmd.GetTemporaryRT(rtMask, tw, th, 0, kFilter, kFormat, kRWMode);
137137
cmd.BlitFullscreenTriangle(rtBlur, rtMask, sheet, (int)Pass.VerticalBlur);
138138
cmd.ReleaseTemporaryRT(rtBlur);

PostProcessing/Runtime/Effects/AutoExposure.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ public override void Render(PostProcessRenderContext context)
8181
lowPercent = Mathf.Clamp(lowPercent, 1f, highPercent - kMinDelta);
8282

8383
// Compute auto exposure
84-
sheet.properties.SetBuffer(Uniforms._HistogramBuffer, context.logHistogram.data);
85-
sheet.properties.SetVector(Uniforms._Params, new Vector4(lowPercent * 0.01f, highPercent * 0.01f, RuntimeUtilities.Exp2(settings.minLuminance.value), RuntimeUtilities.Exp2(settings.maxLuminance.value)));
86-
sheet.properties.SetVector(Uniforms._Speed, new Vector2(settings.speedDown.value, settings.speedUp.value));
87-
sheet.properties.SetVector(Uniforms._ScaleOffsetRes, context.logHistogram.GetHistogramScaleOffsetRes(context));
88-
sheet.properties.SetFloat(Uniforms._ExposureCompensation, settings.keyValue.value);
84+
sheet.properties.SetBuffer(ShaderIDs.HistogramBuffer, context.logHistogram.data);
85+
sheet.properties.SetVector(ShaderIDs.Params, new Vector4(lowPercent * 0.01f, highPercent * 0.01f, RuntimeUtilities.Exp2(settings.minLuminance.value), RuntimeUtilities.Exp2(settings.maxLuminance.value)));
86+
sheet.properties.SetVector(ShaderIDs.Speed, new Vector2(settings.speedDown.value, settings.speedUp.value));
87+
sheet.properties.SetVector(ShaderIDs.ScaleOffsetRes, context.logHistogram.GetHistogramScaleOffsetRes(context));
88+
sheet.properties.SetFloat(ShaderIDs.ExposureCompensation, settings.keyValue.value);
8989

9090
if (m_FirstFrame || !Application.isPlaying)
9191
{

PostProcessing/Runtime/Effects/Bloom.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ public override void Render(PostProcessRenderContext context)
8585
var sheet = context.propertySheets.Get(context.resources.shaders.bloom);
8686

8787
// Apply auto exposure adjustment in the prefiltering pass
88-
sheet.properties.SetTexture(Uniforms._AutoExposureTex, context.autoExposureTexture);
88+
sheet.properties.SetTexture(ShaderIDs.AutoExposureTex, context.autoExposureTexture);
8989

9090
// Determine the iteration count
9191
float logh = Mathf.Log(context.height, 2f) + settings.diffusion.value - 10f;
9292
int logh_i = Mathf.FloorToInt(logh);
9393
int iterations = Mathf.Clamp(logh_i, 1, k_MaxPyramidSize);
9494
float sampleScale = 0.5f + logh - logh_i;
95-
sheet.properties.SetFloat(Uniforms._SampleScale, sampleScale);
95+
sheet.properties.SetFloat(ShaderIDs.SampleScale, sampleScale);
9696

9797
// Do bloom on a half-res buffer, full-res doesn't bring much and kills performances on
9898
// fillrate limited platforms
@@ -103,7 +103,7 @@ public override void Render(PostProcessRenderContext context)
103103
float lthresh = Mathf.GammaToLinearSpace(settings.threshold.value);
104104
float knee = lthresh * settings.softKnee.value + 1e-5f;
105105
var threshold = new Vector4(lthresh, lthresh - knee, knee * 2f, 0.25f / knee);
106-
sheet.properties.SetVector(Uniforms._Threshold, threshold);
106+
sheet.properties.SetVector(ShaderIDs.Threshold, threshold);
107107

108108
int qualityOffset = settings.mobileOptimized ? 1 : 0;
109109

@@ -131,7 +131,7 @@ public override void Render(PostProcessRenderContext context)
131131
{
132132
int mipDown = m_Pyramid[i].down;
133133
int mipUp = m_Pyramid[i].up;
134-
cmd.SetGlobalTexture(Uniforms._BloomTex, mipDown);
134+
cmd.SetGlobalTexture(ShaderIDs.BloomTex, mipDown);
135135
cmd.BlitFullscreenTriangle(last, mipUp, sheet, (int)Pass.UpsampleTent + qualityOffset);
136136
last = mipUp;
137137
}
@@ -149,10 +149,10 @@ public override void Render(PostProcessRenderContext context)
149149

150150
var uberSheet = context.uberSheet;
151151
uberSheet.EnableKeyword("BLOOM");
152-
uberSheet.properties.SetVector(Uniforms._Bloom_Settings, shaderSettings);
153-
uberSheet.properties.SetColor(Uniforms._Bloom_Color, settings.color.value.linear);
154-
uberSheet.properties.SetTexture(Uniforms._Bloom_DirtTex, dirtTexture);
155-
cmd.SetGlobalTexture(Uniforms._BloomTex, m_Pyramid[0].up);
152+
uberSheet.properties.SetVector(ShaderIDs.Bloom_Settings, shaderSettings);
153+
uberSheet.properties.SetColor(ShaderIDs.Bloom_Color, settings.color.value.linear);
154+
uberSheet.properties.SetTexture(ShaderIDs.Bloom_DirtTex, dirtTexture);
155+
cmd.SetGlobalTexture(ShaderIDs.BloomTex, m_Pyramid[0].up);
156156

157157
// Cleanup
158158
for (int i = 0; i < iterations; i++)

PostProcessing/Runtime/Effects/ChromaticAberration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public override void Render(PostProcessRenderContext context)
6161
? "CHROMATIC_ABERRATION_LOW"
6262
: "CHROMATIC_ABERRATION"
6363
);
64-
sheet.properties.SetFloat(Uniforms._ChromaticAberration_Amount, settings.intensity * 0.05f);
65-
sheet.properties.SetTexture(Uniforms._ChromaticAberration_SpectralLut, spectralLut);
64+
sheet.properties.SetFloat(ShaderIDs.ChromaticAberration_Amount, settings.intensity * 0.05f);
65+
sheet.properties.SetTexture(ShaderIDs.ChromaticAberration_SpectralLut, spectralLut);
6666
}
6767

6868
public override void Release()

PostProcessing/Runtime/Effects/ColorGrading.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ void RenderExternalPipeline(PostProcessRenderContext context)
189189

190190
var uberSheet = context.uberSheet;
191191
uberSheet.EnableKeyword("COLOR_GRADING_HDR");
192-
uberSheet.properties.SetTexture(Uniforms._Lut3D, lut);
193-
uberSheet.properties.SetVector(Uniforms._Lut3D_Params, new Vector2(1f / lut.width, lut.width - 1f));
194-
uberSheet.properties.SetFloat(Uniforms._PostExposure, RuntimeUtilities.Exp2(settings.postExposure.value));
192+
uberSheet.properties.SetTexture(ShaderIDs.Lut3D, lut);
193+
uberSheet.properties.SetVector(ShaderIDs.Lut3D_Params, new Vector2(1f / lut.width, lut.width - 1f));
194+
uberSheet.properties.SetFloat(ShaderIDs.PostExposure, RuntimeUtilities.Exp2(settings.postExposure.value));
195195
context.logLut = lut;
196196
}
197197

@@ -294,9 +294,9 @@ void RenderHDRPipeline(PostProcessRenderContext context)
294294
var lut = m_InternalLogLut;
295295
var uberSheet = context.uberSheet;
296296
uberSheet.EnableKeyword("COLOR_GRADING_HDR");
297-
uberSheet.properties.SetTexture(Uniforms._Lut3D, lut);
298-
uberSheet.properties.SetVector(Uniforms._Lut3D_Params, new Vector2(1f / lut.width, lut.width - 1f));
299-
uberSheet.properties.SetFloat(Uniforms._PostExposure, RuntimeUtilities.Exp2(settings.postExposure.value));
297+
uberSheet.properties.SetTexture(ShaderIDs.Lut3D, lut);
298+
uberSheet.properties.SetVector(ShaderIDs.Lut3D_Params, new Vector2(1f / lut.width, lut.width - 1f));
299+
uberSheet.properties.SetFloat(ShaderIDs.PostExposure, RuntimeUtilities.Exp2(settings.postExposure.value));
300300

301301
context.logLut = lut;
302302
}
@@ -312,33 +312,33 @@ void RenderLDRPipeline(PostProcessRenderContext context)
312312
var lutSheet = context.propertySheets.Get(context.resources.shaders.lut2DBaker);
313313
lutSheet.ClearKeywords();
314314

315-
lutSheet.properties.SetVector(Uniforms._Lut2D_Params, new Vector4(k_Lut2DSize, 0.5f / (k_Lut2DSize * k_Lut2DSize), 0.5f / k_Lut2DSize, k_Lut2DSize / (k_Lut2DSize - 1f)));
315+
lutSheet.properties.SetVector(ShaderIDs.Lut2D_Params, new Vector4(k_Lut2DSize, 0.5f / (k_Lut2DSize * k_Lut2DSize), 0.5f / k_Lut2DSize, k_Lut2DSize / (k_Lut2DSize - 1f)));
316316

317317
var colorBalance = ColorUtilities.ComputeColorBalance(settings.temperature.value, settings.tint.value);
318-
lutSheet.properties.SetVector(Uniforms._ColorBalance, colorBalance);
319-
lutSheet.properties.SetVector(Uniforms._ColorFilter, settings.colorFilter.value);
318+
lutSheet.properties.SetVector(ShaderIDs.ColorBalance, colorBalance);
319+
lutSheet.properties.SetVector(ShaderIDs.ColorFilter, settings.colorFilter.value);
320320

321321
float hue = settings.hueShift.value / 360f; // Remap to [-0.5;0.5]
322322
float sat = settings.saturation.value / 100f + 1f; // Remap to [0;2]
323323
float con = settings.contrast.value / 100f + 1f; // Remap to [0;2]
324-
lutSheet.properties.SetVector(Uniforms._HueSatCon, new Vector3(hue, sat, con));
324+
lutSheet.properties.SetVector(ShaderIDs.HueSatCon, new Vector3(hue, sat, con));
325325

326326
var channelMixerR = new Vector3(settings.mixerRedOutRedIn, settings.mixerRedOutGreenIn, settings.mixerRedOutBlueIn);
327327
var channelMixerG = new Vector3(settings.mixerGreenOutRedIn, settings.mixerGreenOutGreenIn, settings.mixerGreenOutBlueIn);
328328
var channelMixerB = new Vector3(settings.mixerBlueOutRedIn, settings.mixerBlueOutGreenIn, settings.mixerBlueOutBlueIn);
329-
lutSheet.properties.SetVector(Uniforms._ChannelMixerRed, channelMixerR / 100f); // Remap to [-2;2]
330-
lutSheet.properties.SetVector(Uniforms._ChannelMixerGreen, channelMixerG / 100f);
331-
lutSheet.properties.SetVector(Uniforms._ChannelMixerBlue, channelMixerB / 100f);
329+
lutSheet.properties.SetVector(ShaderIDs.ChannelMixerRed, channelMixerR / 100f); // Remap to [-2;2]
330+
lutSheet.properties.SetVector(ShaderIDs.ChannelMixerGreen, channelMixerG / 100f);
331+
lutSheet.properties.SetVector(ShaderIDs.ChannelMixerBlue, channelMixerB / 100f);
332332

333333
var lift = ColorUtilities.ColorToLift(settings.lift.value);
334334
var gain = ColorUtilities.ColorToGain(settings.gain.value);
335335
var invgamma = ColorUtilities.ColorToInverseGamma(settings.gamma.value);
336-
lutSheet.properties.SetVector(Uniforms._Lift, lift);
337-
lutSheet.properties.SetVector(Uniforms._InvGamma, invgamma);
338-
lutSheet.properties.SetVector(Uniforms._Gain, gain);
336+
lutSheet.properties.SetVector(ShaderIDs.Lift, lift);
337+
lutSheet.properties.SetVector(ShaderIDs.InvGamma, invgamma);
338+
lutSheet.properties.SetVector(ShaderIDs.Gain, gain);
339339

340-
lutSheet.properties.SetFloat(Uniforms._Brightness, (settings.brightness.value + 100f) / 100f);
341-
lutSheet.properties.SetTexture(Uniforms._Curves, GetCurveTexture(false));
340+
lutSheet.properties.SetFloat(ShaderIDs.Brightness, (settings.brightness.value + 100f) / 100f);
341+
lutSheet.properties.SetTexture(ShaderIDs.Curves, GetCurveTexture(false));
342342

343343
// Generate the lut
344344
context.command.BeginSample("LdrColorGradingLut");
@@ -353,8 +353,8 @@ void RenderLDRPipeline(PostProcessRenderContext context)
353353
var lut = m_InternalLdrLut;
354354
var uberSheet = context.uberSheet;
355355
uberSheet.EnableKeyword("COLOR_GRADING_LDR");
356-
uberSheet.properties.SetVector(Uniforms._Lut2D_Params, new Vector3(1f / lut.width, 1f / lut.height, lut.height - 1f));
357-
uberSheet.properties.SetTexture(Uniforms._Lut2D, lut);
356+
uberSheet.properties.SetVector(ShaderIDs.Lut2D_Params, new Vector3(1f / lut.width, 1f / lut.height, lut.height - 1f));
357+
uberSheet.properties.SetTexture(ShaderIDs.Lut2D, lut);
358358
}
359359

360360
void CheckInternalLogLut()

PostProcessing/Runtime/Effects/DepthOfField.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,18 @@ public override void Render(PostProcessRenderContext context)
126126

127127
var sheet = context.propertySheets.Get(context.resources.shaders.depthOfField);
128128
sheet.properties.Clear();
129-
sheet.properties.SetFloat(Uniforms._Distance, s1);
130-
sheet.properties.SetFloat(Uniforms._LensCoeff, coeff);
131-
sheet.properties.SetFloat(Uniforms._MaxCoC, maxCoC);
132-
sheet.properties.SetFloat(Uniforms._RcpMaxCoC, 1f / maxCoC);
133-
sheet.properties.SetFloat(Uniforms._RcpAspect, 1f / aspect);
129+
sheet.properties.SetFloat(ShaderIDs.Distance, s1);
130+
sheet.properties.SetFloat(ShaderIDs.LensCoeff, coeff);
131+
sheet.properties.SetFloat(ShaderIDs.MaxCoC, maxCoC);
132+
sheet.properties.SetFloat(ShaderIDs.RcpMaxCoC, 1f / maxCoC);
133+
sheet.properties.SetFloat(ShaderIDs.RcpAspect, 1f / aspect);
134134

135135
var cmd = context.command;
136136
cmd.BeginSample("DepthOfField");
137137

138138
// CoC calculation pass
139-
cmd.GetTemporaryRT(Uniforms._CoCTex, context.width, context.height, 0, FilterMode.Bilinear, cocFormat, RenderTextureReadWrite.Linear);
140-
cmd.BlitFullscreenTriangle(BuiltinRenderTextureType.None, Uniforms._CoCTex, sheet, (int)Pass.CoCCalculation);
139+
cmd.GetTemporaryRT(ShaderIDs.CoCTex, context.width, context.height, 0, FilterMode.Bilinear, cocFormat, RenderTextureReadWrite.Linear);
140+
cmd.BlitFullscreenTriangle(BuiltinRenderTextureType.None, ShaderIDs.CoCTex, sheet, (int)Pass.CoCCalculation);
141141

142142
// CoC temporal filter pass when TAA is enabled
143143
if (context.IsTemporalAntialiasingActive())
@@ -146,36 +146,36 @@ public override void Render(PostProcessRenderContext context)
146146
float blend = m_ResetHistory ? 0f : motionBlending; // Handles first frame blending
147147
var jitter = context.temporalAntialiasing.jitter;
148148

149-
sheet.properties.SetVector(Uniforms._TaaParams, new Vector3(jitter.x, jitter.y, blend));
149+
sheet.properties.SetVector(ShaderIDs.TaaParams, new Vector3(jitter.x, jitter.y, blend));
150150

151151
int pp = m_HistoryPingPong;
152152
var historyRead = CheckHistory(++pp % 2, context.width, context.height, cocFormat);
153153
var historyWrite = CheckHistory(++pp % 2, context.width, context.height, cocFormat);
154154
m_HistoryPingPong = ++pp % 2;
155155

156156
cmd.BlitFullscreenTriangle(historyRead, historyWrite, sheet, (int)Pass.CoCTemporalFilter);
157-
cmd.ReleaseTemporaryRT(Uniforms._CoCTex);
158-
cmd.SetGlobalTexture(Uniforms._CoCTex, historyWrite);
157+
cmd.ReleaseTemporaryRT(ShaderIDs.CoCTex);
158+
cmd.SetGlobalTexture(ShaderIDs.CoCTex, historyWrite);
159159
}
160160

161161
// Downsampling and prefiltering pass
162-
cmd.GetTemporaryRT(Uniforms._DepthOfFieldTex, context.width / 2, context.height / 2, 0, FilterMode.Bilinear, colorFormat);
163-
cmd.BlitFullscreenTriangle(context.source, Uniforms._DepthOfFieldTex, sheet, (int)Pass.DownsampleAndPrefilter);
162+
cmd.GetTemporaryRT(ShaderIDs.DepthOfFieldTex, context.width / 2, context.height / 2, 0, FilterMode.Bilinear, colorFormat);
163+
cmd.BlitFullscreenTriangle(context.source, ShaderIDs.DepthOfFieldTex, sheet, (int)Pass.DownsampleAndPrefilter);
164164

165165
// Bokeh simulation pass
166-
cmd.GetTemporaryRT(Uniforms._DepthOfFieldTemp, context.width / 2, context.height / 2, 0, FilterMode.Bilinear, colorFormat);
167-
cmd.BlitFullscreenTriangle(Uniforms._DepthOfFieldTex, Uniforms._DepthOfFieldTemp, sheet, (int)Pass.BokehSmallKernel + (int)settings.kernelSize.value);
166+
cmd.GetTemporaryRT(ShaderIDs.DepthOfFieldTemp, context.width / 2, context.height / 2, 0, FilterMode.Bilinear, colorFormat);
167+
cmd.BlitFullscreenTriangle(ShaderIDs.DepthOfFieldTex, ShaderIDs.DepthOfFieldTemp, sheet, (int)Pass.BokehSmallKernel + (int)settings.kernelSize.value);
168168

169169
// Postfilter pass
170-
cmd.BlitFullscreenTriangle(Uniforms._DepthOfFieldTemp, Uniforms._DepthOfFieldTex, sheet, (int)Pass.PostFilter);
171-
cmd.ReleaseTemporaryRT(Uniforms._DepthOfFieldTemp);
170+
cmd.BlitFullscreenTriangle(ShaderIDs.DepthOfFieldTemp, ShaderIDs.DepthOfFieldTex, sheet, (int)Pass.PostFilter);
171+
cmd.ReleaseTemporaryRT(ShaderIDs.DepthOfFieldTemp);
172172

173173
// Combine pass
174174
cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, (int)Pass.Combine);
175-
cmd.ReleaseTemporaryRT(Uniforms._DepthOfFieldTex);
175+
cmd.ReleaseTemporaryRT(ShaderIDs.DepthOfFieldTex);
176176

177177
if (!context.IsTemporalAntialiasingActive())
178-
cmd.ReleaseTemporaryRT(Uniforms._CoCTex);
178+
cmd.ReleaseTemporaryRT(ShaderIDs.CoCTex);
179179

180180
cmd.EndSample("DepthOfField");
181181

PostProcessing/Runtime/Effects/Dithering.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ internal void Render(PostProcessRenderContext context)
2828
var noiseTex = blueNoise[m_NoiseTextureIndex];
2929
var uberSheet = context.uberSheet;
3030

31-
uberSheet.properties.SetTexture(Uniforms._DitheringTex, noiseTex);
32-
uberSheet.properties.SetVector(Uniforms._Dithering_Coords, new Vector4(
31+
uberSheet.properties.SetTexture(ShaderIDs.DitheringTex, noiseTex);
32+
uberSheet.properties.SetVector(ShaderIDs.Dithering_Coords, new Vector4(
3333
(float)context.width / (float)noiseTex.width,
3434
(float)context.height / (float)noiseTex.height,
3535
rndOffsetX,

0 commit comments

Comments
 (0)