@@ -6,6 +6,7 @@ uniform float _ToneIntensity;
6
6
uniform half4 _ColorValue;
7
7
uniform float _ColorIntensity;
8
8
uniform float _SamplingIntensity;
9
+ uniform float _SamplingScale;
9
10
uniform sampler2D _TransitionTex;
10
11
uniform float4 _TransitionTex_ST;
11
12
uniform float _TransitionRate;
@@ -41,6 +42,11 @@ uniform float _TargetSoftness;
41
42
* step (uvMask.x, uv.x) * step (uv.x, uvMask.z) \
42
43
* step (uvMask.y, uv.y) * step (uv.y, uvMask.w)
43
44
45
+ float2 texel_size ()
46
+ {
47
+ return _MainTex_TexelSize.xy * _SamplingScale;
48
+ }
49
+
44
50
float3 rgb_to_hsv (float3 c)
45
51
{
46
52
const float4 K = float4 (0.0 , -1.0 / 3.0 , 2.0 / 3.0 , -1.0 );
@@ -243,7 +249,7 @@ half4 apply_sampling_filter(float2 uv, const float4 uvMask, const float2 uvLocal
243
249
float4 o = 0 ;
244
250
float sum = 0 ;
245
251
float2 shift = 0 ;
246
- const half2 blur = _MainTex_TexelSize.xy * _SamplingIntensity * 2 ;
252
+ const half2 blur = texel_size () * _SamplingIntensity * 2 ;
247
253
for (int x = 0 ; x < KERNEL_SIZE; x++)
248
254
{
249
255
shift.x = blur.x * (float (x) - KERNEL_SIZE / 2 );
@@ -381,13 +387,13 @@ half4 uieffect(float2 uv, const float4 uvMask, const float2 uvLocal)
381
387
// Sampling.Pixelation
382
388
#if SAMPLING_PIXELATION
383
389
{
384
- const half2 pixelSize = max (2 , (1 - lerp (0.5 , 0.95 , _SamplingIntensity)) * _MainTex_TexelSize.zw );
390
+ const half2 pixelSize = max (2 , (1 - lerp (0.5 , 0.95 , _SamplingIntensity)) / texel_size () );
385
391
uv = round (uv * pixelSize) / pixelSize;
386
392
}
387
393
// Sampling.RgbShift
388
394
#elif SAMPLING_RGB_SHIFT
389
395
{
390
- const half2 offset = half2 (_SamplingIntensity * _MainTex_TexelSize .x * 20 , 0 );
396
+ const half2 offset = half2 (_SamplingIntensity * texel_size () .x * 20 , 0 );
391
397
const half2 r = uieffect_internal (uv + offset, uvMask, uvLocal).ra;
392
398
const half2 g = uieffect_internal (uv, uvMask, uvLocal).ga;
393
399
const half2 b = uieffect_internal (uv - offset, uvMask, uvLocal).ba;
@@ -397,8 +403,8 @@ half4 uieffect(float2 uv, const float4 uvMask, const float2 uvLocal)
397
403
#elif SAMPLING_EDGE_LUMINANCE || SAMPLING_EDGE_ALPHA
398
404
{
399
405
// Pixel size
400
- const float dx = _MainTex_TexelSize .x;
401
- const float dy = _MainTex_TexelSize .y;
406
+ const float dx = texel_size () .x;
407
+ const float dy = texel_size () .y;
402
408
403
409
// Pixel values around the current pixel (3x3, 8 neighbors)
404
410
const float2 uv00 = uv + half2 (-dx, -dy);
0 commit comments