forked from przemyslawzaworski/Unity3D-CG-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgabor.shader
183 lines (177 loc) · 8.38 KB
/
gabor.shader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//reference: https://mzucker.github.io/2016/08/01/gabor-2.html
Shader "Gabor"
{
Subshader
{
Pass
{
CGPROGRAM
#pragma vertex vertex_shader
#pragma fragment pixel_shader
#pragma target 4.0
struct custom_type
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};
static const float4 scl = float4(0.00391389432485, 0.0122958616579, 0.00782778864971, 0.00391389432485);
float gabor(float2 p, float4 q)
{
float4 q0 = floor(q*0.001953125)*scl;
float4 q1 = fmod(q, 512.0)*scl;
float cr = cos(q0.y);
float sr = sin(q0.y);
float2 st = float2(q0.w, q1.z);
p = mul((p - float2(q0.x, q1.x)),float2x2(cr, -sr, sr, cr));
return q1.w * exp(dot(float2(-0.5,-0.5), p*p/(st*st))) * cos(p.x*6.2831853/q0.z+q1.y);
}
custom_type vertex_shader (float4 vertex:POSITION, float2 uv:TEXCOORD0)
{
custom_type vs;
vs.vertex = UnityObjectToClipPos (vertex);
vs.uv = uv;
return vs;
}
float4 pixel_shader (custom_type ps) : COLOR
{
float2 p = 0.6*(2.0*ps.uv.xy-1.0);
p.y = -p.y;
p += 1.0;
float k = 0.0;
k += gabor(p, float4(138752.,150667.,261821.,93447.));
k += gabor(p, float4(226145.,131739.,77399.,33587.));
k += gabor(p, float4(63748.,240999.,76311.,23447.));
k += gabor(p, float4(150173.,43128.,50197.,22225.));
k += gabor(p, float4(116939.,73605.,57898.,7679.));
k += gabor(p, float4(51.,227699.,261732.,68280.));
k += gabor(p, float4(50687.,129029.,38508.,17512.));
k += gabor(p, float4(117913.,117281.,32319.,32324.));
k += gabor(p, float4(96910.,174542.,26669.,26719.));
k += gabor(p, float4(117600.,70656.,17940.,16010.));
k += gabor(p, float4(108871.,58049.,51302.,47654.));
k += gabor(p, float4(167609.,91829.,28204.,28213.));
k += gabor(p, float4(90467.,245116.,36375.,7167.));
k += gabor(p, float4(82369.,164365.,30329.,30267.));
k += gabor(p, float4(225089.,129997.,6684.,4095.));
k += gabor(p, float4(205005.,127709.,12815.,12982.));
k += gabor(p, float4(175993.,130600.,23563.,11978.));
k += gabor(p, float4(30069.,10115.,23055.,2559.));
k += gabor(p, float4(137435.,215947.,14350.,14446.));
k += gabor(p, float4(226165.,115949.,47659.,18501.));
k += gabor(p, float4(71368.,123529.,23052.,12515.));
k += gabor(p, float4(102042.,215281.,7176.,2857.));
k += gabor(p, float4(68218.,214988.,25632.,25694.));
k += gabor(p, float4(115954.,5782.,40979.,2930.));
k += gabor(p, float4(123338.,133796.,77334.,23039.));
k += gabor(p, float4(203913.,117.,38944.,33329.));
k += gabor(p, float4(227964.,132231.,189988.,12174.));
k += gabor(p, float4(63649.,26205.,10763.,10940.));
k += gabor(p, float4(97912.,45398.,12810.,1739.));
k += gabor(p, float4(106690.,166508.,16387.,2559.));
k += gabor(p, float4(54873.,146884.,58426.,58402.));
k += gabor(p, float4(178346.,81559.,14341.,2559.));
k += gabor(p, float4(185649.,144747.,16391.,1535.));
k += gabor(p, float4(120084.,199932.,10249.,4361.));
k += gabor(p, float4(100115.,63452.,18981.,18968.));
k += gabor(p, float4(180941.,96255.,18962.,18500.));
k += gabor(p, float4(63718.,126911.,34827.,11485.));
k += gabor(p, float4(61203.,92616.,23582.,18498.));
k += gabor(p, float4(172754.,196259.,16390.,6559.));
k += gabor(p, float4(177015.,230484.,25173.,24616.));
k += gabor(p, float4(157875.,57828.,4618.,4837.));
k += gabor(p, float4(105263.,51711.,17997.,17939.));
k += gabor(p, float4(167049.,203925.,24612.,15906.));
k += gabor(p, float4(144087.,67302.,14874.,14931.));
k += gabor(p, float4(150391.,43665.,53778.,4032.));
k += gabor(p, float4(207569.,22528.,15906.,8795.));
k += gabor(p, float4(137039.,173193.,27653.,2559.));
k += gabor(p, float4(206047.,207878.,18958.,7797.));
k += gabor(p, float4(228200.,131090.,5678.,5799.));
k += gabor(p, float4(113976.,64789.,7689.,6396.));
k += gabor(p, float4(83114.,62975.,15903.,13894.));
k += gabor(p, float4(117517.,132261.,12814.,11335.));
k += gabor(p, float4(149162.,180114.,75786.,4971.));
k += gabor(p, float4(219290.,259568.,7701.,3469.));
k += gabor(p, float4(9233.,249362.,21102.,14898.));
k += gabor(p, float4(12348.,105446.,15436.,10340.));
k += gabor(p, float4(147344.,213862.,14917.,14877.));
k += gabor(p, float4(205125.,182142.,82962.,5368.));
k += gabor(p, float4(161978.,187391.,5644.,5760.));
k += gabor(p, float4(88210.,61601.,16388.,2047.));
k += gabor(p, float4(78650.,114304.,15885.,2047.));
k += gabor(p, float4(115065.,71687.,15886.,7819.));
k += gabor(p, float4(93059.,235007.,12814.,10350.));
k += gabor(p, float4(196884.,27136.,12303.,5338.));
k += gabor(p, float4(171860.,258580.,24079.,15418.));
k += gabor(p, float4(183655.,243097.,21510.,2559.));
k += gabor(p, float4(191277.,128656.,12293.,3583.));
k += gabor(p, float4(157553.,43644.,22026.,2014.));
k += gabor(p, float4(76369.,27135.,14370.,10903.));
k += gabor(p, float4(194876.,76800.,7683.,3357.));
k += gabor(p, float4(150218.,45734.,3076.,2201.));
k += gabor(p, float4(230711.,259797.,3613.,3813.));
k += gabor(p, float4(143536.,47519.,32771.,2435.));
k += gabor(p, float4(73356.,64451.,16409.,6741.));
k += gabor(p, float4(228480.,129023.,2581.,2683.));
k += gabor(p, float4(193434.,117680.,17930.,4095.));
k += gabor(p, float4(71419.,126168.,4112.,2190.));
k += gabor(p, float4(94887.,188293.,41993.,4095.));
k += gabor(p, float4(221843.,258986.,4634.,4788.));
k += gabor(p, float4(254463.,215580.,25241.,24612.));
k += gabor(p, float4(36217.,144383.,23056.,9348.));
k += gabor(p, float4(110799.,84416.,10835.,10767.));
k += gabor(p, float4(92864.,216574.,22019.,2047.));
k += gabor(p, float4(21781.,110203.,209421.,13785.));
k += gabor(p, float4(42162.,246368.,12299.,11902.));
k += gabor(p, float4(178010.,28532.,27661.,2559.));
k += gabor(p, float4(75445.,144528.,29199.,3583.));
k += gabor(p, float4(66694.,194418.,24581.,5119.));
k += gabor(p, float4(230325.,1590.,13360.,7865.));
k += gabor(p, float4(92351.,97505.,5635.,2956.));
k += gabor(p, float4(75010.,124415.,12335.,7234.));
k += gabor(p, float4(97906.,169101.,54817.,5119.));
k += gabor(p, float4(106161.,83324.,3589.,2713.));
k += gabor(p, float4(113835.,235844.,9225.,3708.));
k += gabor(p, float4(208627.,241050.,10768.,10482.));
k += gabor(p, float4(168661.,177062.,8706.,2559.));
k += gabor(p, float4(181467.,127455.,17938.,7786.));
k += gabor(p, float4(197869.,146292.,28173.,2559.));
k += gabor(p, float4(117558.,187903.,9736.,3285.));
k += gabor(p, float4(222982.,25466.,20483.,3071.));
k += gabor(p, float4(235759.,128791.,8256.,8275.));
k += gabor(p, float4(29057.,162597.,13888.,8215.));
k += gabor(p, float4(190357.,256223.,13345.,4260.));
k += gabor(p, float4(119069.,231138.,8715.,6737.));
k += gabor(p, float4(170876.,121183.,16906.,10329.));
k += gabor(p, float4(154320.,242687.,6147.,3239.));
k += gabor(p, float4(115981.,136703.,12808.,6807.));
k += gabor(p, float4(120081.,193574.,9734.,2257.));
k += gabor(p, float4(134533.,188242.,26635.,1665.));
k += gabor(p, float4(138043.,77525.,7686.,2271.));
k += gabor(p, float4(130835.,198313.,5122.,1988.));
k += gabor(p, float4(102193.,56831.,6148.,1687.));
k += gabor(p, float4(111902.,152880.,20531.,7206.));
k += gabor(p, float4(174288.,78489.,3075.,3151.));
k += gabor(p, float4(96671.,127941.,6669.,4272.));
k += gabor(p, float4(210122.,17650.,13840.,13455.));
k += gabor(p, float4(203063.,194037.,33825.,33307.));
k += gabor(p, float4(149725.,95402.,11796.,11817.));
k += gabor(p, float4(66297.,11373.,17922.,2559.));
k += gabor(p, float4(179440.,110836.,5633.,1319.));
k += gabor(p, float4(43681.,262028.,25090.,3071.));
k += gabor(p, float4(101192.,233983.,8200.,8304.));
k += gabor(p, float4(202536.,155036.,12293.,2559.));
k += gabor(p, float4(197017.,107008.,8719.,2338.));
k += gabor(p, float4(163006.,200413.,3076.,2203.));
k += gabor(p, float4(122700.,196047.,6149.,5280.));
k += gabor(p, float4(138048.,193231.,17925.,1322.));
k += gabor(p, float4(205566.,243712.,10761.,9529.));
p = frac(p * float2(443.8975,397.2973));
p += dot(p.xy, p.yx+19.19);
k += 0.12 * (frac(p.x * p.y)*2.0 - 1.0);
return float4(0.5*k + 0.5,0.5*k + 0.5,0.5*k + 0.5,1);
}
ENDCG
}
}
}