9696 return 1.0f + w3(a) / (w2(a) + w3(a)) + 0.5f;
9797 }
9898
99- half4 tex2DFastBicubicSample(TEXTURE2D_PARAM(tex, sampler_tex ), float2 uv)
99+ half4 tex2DFastBicubicSample(TEXTURE2D_PARAM(tex, samplertex ), float2 uv)
100100 {
101101 #if !defined(PLAT_QUEST) && defined(BICUBIC_LIGHTMAP)
102102 half width;
122122 half h0y = h0(fy);
123123 half h1y = h1(fy);
124124
125- half4 r = g0(fy) * (g0x * SAMPLE_TEXTURE2D(tex, sampler_tex , (half2(px + h0x, py + h0y) * 1.0f / width)) +
126- g1x * SAMPLE_TEXTURE2D(tex, sampler_tex , (half2(px + h1x, py + h0y) * 1.0f / width))) +
127- g1(fy) * (g0x * SAMPLE_TEXTURE2D(tex, sampler_tex , (half2(px + h0x, py + h1y) * 1.0f / width)) +
128- g1x * SAMPLE_TEXTURE2D(tex, sampler_tex , (half2(px + h1x, py + h1y) * 1.0f / width)));
125+ half4 r = g0(fy) * (g0x * SAMPLE_TEXTURE2D(tex, samplertex , (half2(px + h0x, py + h0y) * 1.0f / width)) +
126+ g1x * SAMPLE_TEXTURE2D(tex, samplertex , (half2(px + h1x, py + h0y) * 1.0f / width))) +
127+ g1(fy) * (g0x * SAMPLE_TEXTURE2D(tex, samplertex , (half2(px + h0x, py + h1y) * 1.0f / width)) +
128+ g1x * SAMPLE_TEXTURE2D(tex, samplertex , (half2(px + h1x, py + h1y) * 1.0f / width)));
129129 return r;
130130 #else
131- return SAMPLE_TEXTURE2D(tex, sampler_tex , uv);
131+ return SAMPLE_TEXTURE2D(tex, samplertex , uv);
132132 #endif
133133 }
134134
135- float4 tex2DFastBicubicSampleNoChecks(TEXTURE2D_PARAM(tex, sampler_tex ), float2 uv)
135+ float4 tex2DFastBicubicSampleNoChecks(TEXTURE2D_PARAM(tex, samplertex ), float2 uv)
136136 {
137137 half width;
138138 half height;
157157 half h0y = h0(fy);
158158 half h1y = h1(fy);
159159
160- half4 r = g0(fy) * (g0x * SAMPLE_TEXTURE2D(tex, sampler_tex , (half2(px + h0x, py + h0y) * 1.0f / width)) +
161- g1x * SAMPLE_TEXTURE2D(tex, sampler_tex , (half2(px + h1x, py + h0y) * 1.0f / width))) +
162- g1(fy) * (g0x * SAMPLE_TEXTURE2D(tex, sampler_tex , (half2(px + h0x, py + h1y) * 1.0f / width)) +
163- g1x * SAMPLE_TEXTURE2D(tex, sampler_tex , (half2(px + h1x, py + h1y) * 1.0f / width)));
160+ half4 r = g0(fy) * (g0x * SAMPLE_TEXTURE2D(tex, samplertex , (half2(px + h0x, py + h0y) * 1.0f / width)) +
161+ g1x * SAMPLE_TEXTURE2D(tex, samplertex , (half2(px + h1x, py + h0y) * 1.0f / width))) +
162+ g1(fy) * (g0x * SAMPLE_TEXTURE2D(tex, samplertex , (half2(px + h0x, py + h1y) * 1.0f / width)) +
163+ g1x * SAMPLE_TEXTURE2D(tex, samplertex , (half2(px + h1x, py + h1y) * 1.0f / width)));
164164 return r;
165165 }
166166
167- half4 tex2DFastBicubicSampleLevel(TEXTURE2D_PARAM(tex, sampler_tex ), float2 uv, int level)
167+ half4 tex2DFastBicubicSampleLevel(TEXTURE2D_PARAM(tex, samplertex ), float2 uv, int level)
168168 {
169169 #if !defined(PLAT_QUEST) && defined(BICUBIC_LIGHTMAP)
170170 half width;
190190 half h0y = h0(fy);
191191 half h1y = h1(fy);
192192
193- half4 r = g0(fy) * (g0x * SAMPLE_TEXTURE2D_LOD(tex, sampler_tex , (half2(px + h0x, py + h0y) * 1.0f / width), level) +
194- g1x * SAMPLE_TEXTURE2D_LOD(tex, sampler_tex , (half2(px + h1x, py + h0y) * 1.0f / width), level)) +
195- g1(fy) * (g0x * SAMPLE_TEXTURE2D_LOD(tex, sampler_tex , (half2(px + h0x, py + h1y) * 1.0f / width), level) +
196- g1x * SAMPLE_TEXTURE2D_LOD(tex, sampler_tex , (half2(px + h1x, py + h1y) * 1.0f / width), level));
193+ half4 r = g0(fy) * (g0x * SAMPLE_TEXTURE2D_LOD(tex, samplertex , (half2(px + h0x, py + h0y) * 1.0f / width), level) +
194+ g1x * SAMPLE_TEXTURE2D_LOD(tex, samplertex , (half2(px + h1x, py + h0y) * 1.0f / width), level)) +
195+ g1(fy) * (g0x * SAMPLE_TEXTURE2D_LOD(tex, samplertex , (half2(px + h0x, py + h1y) * 1.0f / width), level) +
196+ g1x * SAMPLE_TEXTURE2D_LOD(tex, samplertex , (half2(px + h1x, py + h1y) * 1.0f / width), level));
197197 return r;
198198 #else
199- return SAMPLE_TEXTURE2D_LOD(tex, sampler_tex , uv, level);
199+ return SAMPLE_TEXTURE2D_LOD(tex, samplertex , uv, level);
200200 #endif
201201 }
202202
203- half getBakedNoise(TEXTURE2D_PARAM(noiseTex, sampler_noiseTex ), float3 p)
203+ half getBakedNoise(TEXTURE2D_PARAM(noiseTex, samplernoiseTex ), float3 p)
204204 {
205205 float3 i = floor(p); p -= i; p *= p * (3. - 2. * p);
206206 float2 uv = (p.xy + i.xy + float2(37, 17) * i.z + .5) / 256.;
207207 uv.y *= -1;
208- p.xy = SAMPLE_TEXTURE2D_LOD(noiseTex, sampler_noiseTex , uv, 0).yx;
208+ p.xy = SAMPLE_TEXTURE2D_LOD(noiseTex, samplernoiseTex , uv, 0).yx;
209209 return lerp(p.x, p.y, p.z);
210210 }
211211
212212 // Manual bilinear sampling to avoid 8 bit precision issues
213213 // Based on https://www.shadertoy.com/view/MllSzX
214- half getBakedNoiseBilinear(TEXTURE2D_PARAM(noiseTex, sampler_noiseTex ), float4 texSize, float3 p)
214+ half getBakedNoiseBilinear(TEXTURE2D_PARAM(noiseTex, samplernoiseTex ), float4 texSize, float3 p)
215215 {
216216 float3 i = floor(p); p -= i; p *= p * (3. - 2. * p);
217217 float2 uv = (p.xy + i.xy + float2(37, 17) * i.z + .5) / 256.;
218218 uv.y *= -1;
219-
219+
220220 float2 pixelUv = uv * texSize.zw + 0.5;
221221 float2 pixelUvFrac = frac(pixelUv);
222222
223223 pixelUv = (floor(pixelUv) / texSize.zw) - texSize.xy * 0.5;
224224
225- float4 sample0 = SAMPLE_TEXTURE2D_LOD(noiseTex, sampler_noiseTex , pixelUv, 0);
226- float4 sample1 = SAMPLE_TEXTURE2D_LOD(noiseTex, sampler_noiseTex , pixelUv + float2(texSize.x, 0), 0);
227- float4 sample2 = SAMPLE_TEXTURE2D_LOD(noiseTex, sampler_noiseTex , pixelUv + float2(0, texSize.y), 0);
228- float4 sample3 = SAMPLE_TEXTURE2D_LOD(noiseTex, sampler_noiseTex , pixelUv + float2(texSize.x, texSize.y), 0);
225+ float4 sample0 = SAMPLE_TEXTURE2D_LOD(noiseTex, samplernoiseTex , pixelUv, 0);
226+ float4 sample1 = SAMPLE_TEXTURE2D_LOD(noiseTex, samplernoiseTex , pixelUv + float2(texSize.x, 0), 0);
227+ float4 sample2 = SAMPLE_TEXTURE2D_LOD(noiseTex, samplernoiseTex , pixelUv + float2(0, texSize.y), 0);
228+ float4 sample3 = SAMPLE_TEXTURE2D_LOD(noiseTex, samplernoiseTex , pixelUv + float2(texSize.x, texSize.y), 0);
229229
230230 float4 filtered1 = lerp(sample0, sample1, pixelUvFrac.x);
231231 float4 filtered2 = lerp(sample2, sample3, pixelUvFrac.x);
232232 float4 filtered = lerp(filtered1, filtered2, pixelUvFrac.y);
233-
233+
234234 p.xy = filtered.yx;
235235 return lerp(p.x, p.y, p.z);
236236 }
237237
238- half getBakedNoiseBicubic(TEXTURE2D_PARAM(noiseTex, sampler_noiseTex ), float3 p)
238+ half getBakedNoiseBicubic(TEXTURE2D_PARAM(noiseTex, samplernoiseTex ), float3 p)
239239 {
240240 float3 i = floor(p); p -= i; p *= p * (3. - 2. * p);
241241 float2 uv = (p.xy + i.xy + float2(37, 17) * i.z + .5) / 256.;
242242 uv.y *= -1;
243- p.xy = tex2DFastBicubicSampleLevel(TEXTURE2D_ARGS(noiseTex, sampler_noiseTex ), uv, 0).yx;
243+ p.xy = tex2DFastBicubicSampleLevel(TEXTURE2D_ARGS(noiseTex, samplernoiseTex ), uv, 0).yx;
244244 return lerp(p.x, p.y, p.z);
245245 }
246246
249249 return b1 + (s - a1) * (b2 - b1) / (a2 - a1);
250250 }
251251
252- half3 ApplyLut2D(TEXTURE2D_PARAM(lut2d, sampler_lut2d ), half3 uvw)
252+ half3 ApplyLut2D(TEXTURE2D_PARAM(lut2d, samplerlut2d ), half3 uvw)
253253 {
254254 half3 scaleOffset = half3(1.0 / 1024.0, 1.0 / 32.0, 31.0);
255255 // Strip format where `height = sqrt(width)`
258258 uvw.xy = uvw.xy * scaleOffset.z * scaleOffset.xy + scaleOffset.xy * 0.5;
259259 uvw.x += shift * scaleOffset.y;
260260 uvw.xyz = lerp(
261- SAMPLE_TEXTURE2D(lut2d, sampler_lut2d , uvw.xy).rgb,
262- SAMPLE_TEXTURE2D(lut2d, sampler_lut2d , uvw.xy + half2(scaleOffset.y, 0.0)).rgb,
261+ SAMPLE_TEXTURE2D(lut2d, samplerlut2d , uvw.xy).rgb,
262+ SAMPLE_TEXTURE2D(lut2d, samplerlut2d , uvw.xy + half2(scaleOffset.y, 0.0)).rgb,
263263 uvw.z - shift
264264 );
265265 return uvw;
266266 }
267267
268268 half3 HSV2RGB(half3 hsv)
269- {
269+ {
270270 return hsv.z + hsv.z * hsv.y * (clamp(abs(fmod(hsv.x * 6.0 + half3(0,4,2), 6.0) - 3.0) - 1.0,0.0,1.0) - 1.0);
271271 }
272272
521521 return source;
522522 }
523523
524-
524+
525525 float GLSLMod(float x, float y)
526526 {
527527 return (((x)-(y)*floor((x)/(y))));
554554 float D = 0.20;
555555 float E = 0.02;
556556 float F = 0.30;
557-
557+
558558 return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
559559 }
560560
597597 return gamma_applied_linear_rgb;
598598 }
599599
600-
600+
601601 // https://github.com/MochiesCode/Mochies-Unity-Shaders/
602602 // MIT License
603603
651651 {
652652 return length(p) - r;
653653 }
654- }
654+ }
0 commit comments