diff options
| author | yum <yum.food.vr@gmail.com> | 2024-09-10 17:07:51 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-09-10 17:07:51 -0700 |
| commit | 2712f07c0d06a15e6624b3045207d301a1592886 (patch) | |
| tree | 1b8f1d3a8308473e8aae8025a040e6ab95895b1e /rorschach.cginc | |
| parent | 39283e531e865db09d527bdfa44df7f4376783a5 (diff) | |
Rework glitter
now it's voronoi
Diffstat (limited to 'rorschach.cginc')
| -rw-r--r-- | rorschach.cginc | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/rorschach.cginc b/rorschach.cginc deleted file mode 100644 index cc570b8..0000000 --- a/rorschach.cginc +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef __RORSCHACH_INC -#define __RORSCHACH_INC - -#if defined(_RORSCHACH) - -#include "globals.cginc" -#include "interpolators.cginc" -#include "iq_sdf.cginc" -#include "pema99.cginc" - -struct RorschachPBR { - float4 albedo; -}; - -float map_sdf(float3 p, float2 e, float3 period) -{ - float r = _Rorschach_Radius * min(period.x, min(period.y, period.z)); - float st = sin(_Time[1] * _Rorschach_Speed * e.y * e.y + e.x * 3.14159265 * 2); - r *= st; - float3 o = float3( - (e.x - 0.5) * period.x, - (e.y - 0.5) * period.y, - 0); - //o *= ((_SinTime[1] + 1) / 2) * 1.3; - o *= _Rorschach_Center_Randomization; - return distance_from_sphere(p + o, r); -} - -float map_dr( - float3 p, - float3 period, - float3 count, - out float3 which - ) -{ - which = round(p / period); - // Direction to nearest neighboring cell. - float3 min_d = p - period * which; - float3 o = sign(min_d); - - float d = 1E9; - float3 which_tmp = which; - for (int xi = -1; xi < 3; xi++) - for (int yi = -1; yi < 3; yi++) - { - float3 rid = which + float3(xi, yi, 0) * o; - float3 r = p - period * rid; - float2 e = float2( - rand3(rid), - rand3(rid + 1)); - float cur_d = map_sdf(r, e, period); - which_tmp = cur_d < d ? rid : which; - d = min(d, cur_d); - } - - which = which_tmp; - return d; -} - -RorschachPBR get_rorschach(v2f i) -{ - RorschachPBR result; - result.albedo = float4(0, 0, 0, 1); - - float3 ro = float3(i.uv0.x - 0.5, i.uv0.y - 0.5, 0); - float3 rd = float3(0, 0, 1); - - float3 which; - float3 period = float3(1 / (_Rorschach_Count_X+1), 1 / (_Rorschach_Count_Y+1), 1); - float3 count = float3(_Rorschach_Count_X, _Rorschach_Count_Y, 1); - float d = map_dr(ro, period, count, which); - - d *= max(_Rorschach_Count_X + 1, _Rorschach_Count_Y + 1); - - #if 0 - d -= map_dr(1 - ro, period, count, which) * 4; - - d = 1 - d; - d *= d; - d *= d; - d *= d; - d = 1 - d; - - d *= 3; - #endif - - d = 1 - d; - d = saturate(d); - - //d = rand3(which); - /* - if (_Rorschach_Quantization > 0) { - d = round(glsl_mod(d, _Rorschach_Quantization) / _Rorschach_Quantization); - } - */ - -#if defined(_RORSCHACH_MASK) - float mask = _Rorschach_Mask.SampleLevel(linear_repeat_s, i.uv0.xy, /*lod=*/0); - mask = _Rorschach_Mask_Invert ? 1 - mask : mask; - float mask_e = 0.1; - // map mask onto [mask_e, 1 - mask_e] - mask = clamp(mask, mask_e, 1.0 - mask_e); - // map mask onto [0, 1 - 2 * mask_e] - mask -= mask_e; - // map mask onto [0, 1] - mask /= (1 - 2 * mask_e); - d *= mask; -#endif - - // This also quantizes alpha. It isn't exactly intended, but it looks nice. - if (_Rorschach_Quantization > 0) { - d = round(d * _Rorschach_Quantization) / _Rorschach_Quantization; - } - - float4 col = _Rorschach_Color * d; - result.albedo = lerp(0, col, d > _Rorschach_Alpha_Cutoff); - - return result; -} - -#endif // _RORSCHACH -#endif // __RORSCHACH_INC - |
