yum/3ner

A toon shader for Unity's BIRP.

git clone https://git.yummers.dev/yum/3ner

yumAdd derivatives, improve visualization5b213c2

master
1.4 KiB52 linesraw
1Shader "yum_food/fourier_water_display"
2{
3    Properties
4    {
5        _MainTex ("FFT output", 2D) = "black" {}
6        [IntRange] _Stage("Stage", Range(-1, 30)) = 0
7        [IntRange] _Num_Stages("Num stages", Range(1, 30)) = 0
8        [IntRange] _Direction("Direction", Range(0, 1)) = 0
9    }
10    SubShader
11    {
12        Tags { "RenderType" = "Opaque" }
13        Cull Off
14
15        Pass
16        {
17            CGPROGRAM
18            #pragma vertex vert
19            #pragma fragment frag
20            #include "UnityCG.cginc"
21
22            struct v2f
23            {
24                float4 pos : SV_POSITION;
25                float2 uv : TEXCOORD0;
26            };
27
28            sampler2D _MainTex;
29            float4 _MainTex_TexelSize;
30            int _Num_Stages;
31            int _Stage;
32            int _Direction;
33
34            v2f vert(appdata_img v)
35            {
36                v2f o;
37                o.pos = UnityObjectToClipPos(v.vertex);
38                o.uv = v.texcoord;
39                return o;
40            }
41
42            float4 frag(v2f i) : SV_Target
43            {
44                float4 c = tex2D(_MainTex, frac(i.uv + 0.5));
45                float total_stage = ((float) _Stage + _Direction * _Num_Stages) / (_Num_Stages * 2);
46                c *= lerp(_MainTex_TexelSize.z, 1, total_stage);
47                return float4(c.xyz, 1);
48            }
49            ENDCG
50        }
51    }
52}