Skip to content

Commit d3cf6a9

Browse files
committed
update shaders
1 parent 259550c commit d3cf6a9

File tree

11 files changed

+303
-21
lines changed

11 files changed

+303
-21
lines changed

assets/shaders/astral.fs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ vec4 HSVtoRGB(vec4 hsv) {
164164

165165
float bitxor(float val1, float val2)
166166
{
167-
float outp = 0;
168-
for(int i = 1; i < 9; i++) outp += floor(mod(mod(floor(val1*pow(2,-i)),pow(2,i))+mod(floor(val2*pow(2,-i)),pow(2,i)),2))*pow(2,i);
169-
return outp/256;
167+
float outp = 0.;
168+
for(float i = 1.; i < 9.; i++) outp += floor(mod(mod(floor(val1*pow(2.,-i)),pow(2.,i))+mod(floor(val2*pow(2.,-i)),pow(2.,i)),2.))*pow(2.,i);
169+
return outp/256.;
170170
}
171171

172172
float mod2(float val1, float mod1)
@@ -183,7 +183,7 @@ float rand(vec2 c){
183183
}
184184

185185
float noise(vec2 p, float freq ){
186-
float unit = 1/freq;
186+
float unit = 1./freq;
187187
vec2 ij = floor(p/unit);
188188
vec2 xy = mod(p,unit)/unit;
189189
//xy = 3.*xy*xy-2.*xy*xy*xy;
@@ -249,8 +249,8 @@ vec4 effect( vec4 colour, Image texture, vec2 texture_coords, vec2 screen_coords
249249

250250
vec4 pixel = Texel(texture, texture_coords);
251251

252-
float cx = uv_scaled_centered.x * 1;
253-
float cy = uv_scaled_centered.y * 1;
252+
float cx = uv_scaled_centered.x * 1.;
253+
float cy = uv_scaled_centered.y * 1.;
254254

255255

256256

@@ -263,8 +263,8 @@ vec4 effect( vec4 colour, Image texture, vec2 texture_coords, vec2 screen_coords
263263

264264
vec2 mouse_offset = (screen_coords.xy - mouse_screen_pos.xy)/screen_scale;
265265

266-
float scaled_uvy = (uv.y +mouse_offset.y -0.5)*5*1.338;
267-
float scaled_uvx = (uv.x +mouse_offset.x -0.5)*5;
266+
float scaled_uvy = (uv.y +mouse_offset.y -0.5)*5.*1.338;
267+
float scaled_uvx = (uv.x +mouse_offset.x -0.5)*5.;
268268
float norm_uv = sqrt(scaled_uvx*scaled_uvx + scaled_uvy*scaled_uvy);
269269

270270
pixel = vec4(pixel.rgb * 0.0 + tex.rgb * tex.a, pixel.a);
@@ -273,17 +273,17 @@ vec4 effect( vec4 colour, Image texture, vec2 texture_coords, vec2 screen_coords
273273
vec4 textp = RGB(hsl);
274274
tex.rgb = textp.rgb;
275275

276-
float stars = ((pNoise(uv*10 + t/15.0, 10)*pNoise(uv*10 + t/15.0, 10)+1.5)/1+0.15 + ((pNoise(uv*12 + t/15.0, 10)+1.2)/1+0.3))/2.2+0.05 + 0.007*norm_uv * 1.1;
276+
float stars = ((pNoise(uv*10. + t/15.0, 10)*pNoise(uv*10. + t/15.0, 10)+1.5)/1.+0.15 + ((pNoise(uv*12. + t/15.0, 10)+1.2)/1.+0.3))/2.2+0.05 + 0.007*norm_uv * 1.1;
277277

278278
float clusters = (pNoise(uv*10.0-t/15.0, 10)+1.5)/1.5-0.25 + 0.007*norm_uv;
279279

280-
float super_clusters = (pNoise(uv/15.0, 10)+0.1)/2+0.3 - 0.008*norm_uv;
280+
float super_clusters = (pNoise(uv/15.0, 10)+0.1)/2.+0.3 - 0.008*norm_uv;
281281

282282
clusters *= clusters * clusters * clusters * 0.4;
283283
stars *= stars * stars;
284284
super_clusters *= super_clusters * super_clusters;
285285

286-
colour.rgb = vec3(0.6, 0.45, 1) * (((clusters + stars + super_clusters)+0.1)) * 0.285;
286+
colour.rgb = vec3(0.6, 0.45, 1.) * (((clusters + stars + super_clusters)+0.1)) * 0.285;
287287

288288
return dissolve_mask(tex*colour, texture_coords, uv);
289289
}
@@ -299,6 +299,6 @@ vec4 position( mat4 transform_projection, vec4 vertex_position )
299299
float scale = 0.2*(-0.03 - 0.3*max(0., 0.3-mid_dist))
300300
*hovering*(length(mouse_offset)*length(mouse_offset))/(2. -mid_dist);
301301

302-
return transform_projection * vertex_position + vec4(0,0,0,scale);
302+
return transform_projection * vertex_position + vec4(0.,0.,0.,scale);
303303
}
304304
#endif

assets/shaders/blur.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,6 @@ vec4 position( mat4 transform_projection, vec4 vertex_position )
179179
float scale = 0.2*(-0.03 - 0.3*max(0., 0.3-mid_dist))
180180
*hovering*(length(mouse_offset)*length(mouse_offset))/(2. -mid_dist);
181181

182-
return transform_projection * vertex_position + vec4(0,0,0,scale);
182+
return transform_projection * vertex_position + vec4(0.,0.,0.,scale);
183183
}
184184
#endif

assets/shaders/glass.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ vec4 position( mat4 transform_projection, vec4 vertex_position )
104104
float scale = 0.2*(-0.03 - 0.3*max(0., 0.3-mid_dist))
105105
*hovering*(length(mouse_offset)*length(mouse_offset))/(2. -mid_dist);
106106

107-
return transform_projection * vertex_position + vec4(0,0,0,scale);
107+
return transform_projection * vertex_position + vec4(0.,0.,0.,scale);
108108
}
109109
#endif

assets/shaders/glitched.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ vec4 position( mat4 transform_projection, vec4 vertex_position )
139139
float scale = 0.2*(-0.03 - 0.3*max(0., 0.3-mid_dist))
140140
*hovering*(length(mouse_offset)*length(mouse_offset))/(2. -mid_dist);
141141

142-
return transform_projection * vertex_position + vec4(0,0,0,scale);
142+
return transform_projection * vertex_position + vec4(0.,0.,0.,scale);
143143
}
144144
#endif

assets/shaders/glitched_b.fs

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
#if defined(VERTEX) || __VERSION__ > 100 || defined(GL_FRAGMENT_PRECISION_HIGH)
2+
#define MY_HIGHP_OR_MEDIUMP highp
3+
#else
4+
#define MY_HIGHP_OR_MEDIUMP mediump
5+
#endif
6+
7+
extern MY_HIGHP_OR_MEDIUMP vec2 glitched_b;
8+
extern MY_HIGHP_OR_MEDIUMP number dissolve;
9+
extern MY_HIGHP_OR_MEDIUMP number time;
10+
extern MY_HIGHP_OR_MEDIUMP vec4 texture_details;
11+
extern MY_HIGHP_OR_MEDIUMP vec2 image_details;
12+
extern bool shadow;
13+
extern MY_HIGHP_OR_MEDIUMP vec4 burn_colour_1;
14+
extern MY_HIGHP_OR_MEDIUMP vec4 burn_colour_2;
15+
16+
vec4 dissolve_mask(vec4 tex, vec2 texture_coords, vec2 uv)
17+
{
18+
if (dissolve < 0.001) {
19+
return vec4(shadow ? vec3(0.,0.,0.) : tex.xyz, shadow ? tex.a*0.3: tex.a);
20+
}
21+
22+
float adjusted_dissolve = (dissolve*dissolve*(3.-2.*dissolve))*1.02 - 0.01; //Adjusting 0.0-1.0 to fall to -0.1 - 1.1 scale so the mask does not pause at extreme values
23+
24+
float t = time * 10.0 + 2003.;
25+
vec2 floored_uv = (floor((uv*texture_details.ba)))/max(texture_details.b, texture_details.a);
26+
vec2 uv_scaled_centered = (floored_uv - 0.5) * 2.3 * max(texture_details.b, texture_details.a);
27+
28+
vec2 field_part1 = uv_scaled_centered + 50.*vec2(sin(-t / 143.6340), cos(-t / 99.4324));
29+
vec2 field_part2 = uv_scaled_centered + 50.*vec2(cos( t / 53.1532), cos( t / 61.4532));
30+
vec2 field_part3 = uv_scaled_centered + 50.*vec2(sin(-t / 87.53218), sin(-t / 49.0000));
31+
32+
float field = (1.+ (
33+
cos(length(field_part1) / 19.483) + sin(length(field_part2) / 33.155) * cos(field_part2.y / 15.73) +
34+
cos(length(field_part3) / 27.193) * sin(field_part3.x / 21.92) ))/2.;
35+
vec2 borders = vec2(0.2, 0.8);
36+
37+
float res = (.5 + .5* cos( (adjusted_dissolve) / 82.612 + ( field + -.5 ) *3.14))
38+
- (floored_uv.x > borders.y ? (floored_uv.x - borders.y)*(5. + 5.*dissolve) : 0.)*(dissolve)
39+
- (floored_uv.y > borders.y ? (floored_uv.y - borders.y)*(5. + 5.*dissolve) : 0.)*(dissolve)
40+
- (floored_uv.x < borders.x ? (borders.x - floored_uv.x)*(5. + 5.*dissolve) : 0.)*(dissolve)
41+
- (floored_uv.y < borders.x ? (borders.x - floored_uv.y)*(5. + 5.*dissolve) : 0.)*(dissolve);
42+
43+
if (tex.a > 0.01 && burn_colour_1.a > 0.01 && !shadow && res < adjusted_dissolve + 0.8*(0.5-abs(adjusted_dissolve-0.5)) && res > adjusted_dissolve) {
44+
if (!shadow && res < adjusted_dissolve + 0.5*(0.5-abs(adjusted_dissolve-0.5)) && res > adjusted_dissolve) {
45+
tex.rgba = burn_colour_1.rgba;
46+
} else if (burn_colour_2.a > 0.01) {
47+
tex.rgba = burn_colour_2.rgba;
48+
}
49+
}
50+
51+
return vec4(shadow ? vec3(0.,0.,0.) : tex.xyz, res > adjusted_dissolve ? (shadow ? tex.a*0.3: tex.a) : .0);
52+
}
53+
54+
number hue(number s, number t, number h)
55+
{
56+
number hs = mod(h, 1.)*6.;
57+
if (hs < 1.) return (t-s) * hs + s;
58+
if (hs < 3.) return t;
59+
if (hs < 4.) return (t-s) * (4.-hs) + s;
60+
return s;
61+
}
62+
63+
vec4 RGB(vec4 c)
64+
{
65+
if (c.y < 0.0001)
66+
return vec4(vec3(c.z), c.a);
67+
68+
number t = (c.z < .5) ? c.y*c.z + c.z : -c.y*c.z + (c.y+c.z);
69+
number s = 2.0 * c.z - t;
70+
return vec4(hue(s,t,c.x + 1./3.), hue(s,t,c.x), hue(s,t,c.x - 1./3.), c.w);
71+
}
72+
73+
vec4 HSL(vec4 c)
74+
{
75+
number low = min(c.r, min(c.g, c.b));
76+
number high = max(c.r, max(c.g, c.b));
77+
number delta = high - low;
78+
number sum = high+low;
79+
80+
vec4 hsl = vec4(.0, .0, .5 * sum, c.a);
81+
if (delta == .0)
82+
return hsl;
83+
84+
hsl.y = (hsl.z < .5) ? delta / sum : delta / (2.0 - sum);
85+
86+
if (high == c.r)
87+
hsl.x = (c.g - c.b) / delta;
88+
else if (high == c.g)
89+
hsl.x = (c.b - c.r) / delta + 2.0;
90+
else
91+
hsl.x = (c.r - c.g) / delta + 4.0;
92+
93+
hsl.x = mod(hsl.x / 6., 1.);
94+
return hsl;
95+
}
96+
97+
vec4 RGBtoHSV(vec4 rgb)
98+
{
99+
vec4 hsv;
100+
float minVal = min(min(rgb.r, rgb.g), rgb.b);
101+
float maxVal = max(max(rgb.r, rgb.g), rgb.b);
102+
float delta = maxVal - minVal;
103+
104+
// Value
105+
hsv.z = maxVal;
106+
107+
// Saturation
108+
if (maxVal != 0.0)
109+
hsv.y = delta / maxVal;
110+
else {
111+
// r = g = b = 0, s = 0, v is undefined
112+
hsv.y = 0.0;
113+
hsv.x = -1.0;
114+
return hsv;
115+
}
116+
117+
// Hue
118+
if (rgb.r == maxVal)
119+
hsv.x = (rgb.g - rgb.b) / delta; // between yellow & magenta
120+
else if (rgb.g == maxVal)
121+
hsv.x = 2.0 + (rgb.b - rgb.r) / delta; // between cyan & yellow
122+
else
123+
hsv.x = 4.0 + (rgb.r - rgb.g) / delta; // between magenta & cyan
124+
125+
hsv.x = hsv.x * (1.0 / 6.0);
126+
if (hsv.x < 0.0)
127+
hsv.x += 1.0;
128+
129+
// Alpha
130+
hsv.w = rgb.a;
131+
132+
return hsv;
133+
}
134+
135+
vec4 HSVtoRGB(vec4 hsv) {
136+
vec4 rgb;
137+
138+
float h = hsv.x * 6.0;
139+
float c = hsv.z * hsv.y;
140+
float x = c * (1.0 - abs(mod(h, 2.0) - 1.0));
141+
float m = hsv.z - c;
142+
143+
if (h < 1.0) {
144+
rgb = vec4(c, x, 0.0, hsv.a);
145+
} else if (h < 2.0) {
146+
rgb = vec4(x, c, 0.0, hsv.a);
147+
} else if (h < 3.0) {
148+
rgb = vec4(0.0, c, x, hsv.a);
149+
} else if (h < 4.0) {
150+
rgb = vec4(0.0, x, c, hsv.a);
151+
} else if (h < 5.0) {
152+
rgb = vec4(x, 0.0, c, hsv.a);
153+
} else {
154+
rgb = vec4(c, 0.0, x, hsv.a);
155+
}
156+
157+
rgb.rgb += m;
158+
159+
return rgb;
160+
}
161+
162+
float bitxor(float val1, float val2)
163+
{
164+
float outp = 0.;
165+
for(float i = 1.; i < 9.; i++) outp += floor(mod(mod(floor(val1*pow(2.,-i)),pow(2.,i))+mod(floor(val2*pow(2.,-i)),pow(2.,i)),2.))*pow(2.,i);
166+
return outp/256.;
167+
}
168+
169+
float mod2(float val1, float mod1)
170+
{
171+
val1 /= mod1;
172+
val1 -= floor(val1);
173+
return(mod1 * val1);
174+
}
175+
176+
177+
vec4 effect( vec4 colour, Image texture, vec2 texture_coords, vec2 screen_coords )
178+
{
179+
vec4 tex = Texel(texture, texture_coords);
180+
vec2 uv = (((texture_coords)*(image_details)) - texture_details.xy*texture_details.ba)/texture_details.ba;
181+
182+
// Dummy, doesn't do anything but at least it makes the shader useable
183+
if (uv.x > uv.x * 2.){
184+
uv = glitched_b;
185+
}
186+
187+
float mod = glitched_b.r * 1.0;
188+
189+
number low = min(tex.r, min(tex.g, tex.b));
190+
number high = max(tex.r, max(tex.g, tex.b));
191+
number delta = high - low;
192+
193+
//vec4 hsl = HSL(vec4(tex.r, tex.g, tex.b, tex.a));
194+
195+
float t = glitched_b.y*2.221 + time;
196+
vec2 floored_uv = (floor((uv*texture_details.ba)))/texture_details.ba;
197+
vec2 uv_scaled_centered = (floored_uv - 0.5) * 50.;
198+
199+
vec2 field_part1 = uv_scaled_centered + 50.*vec2(sin(-t / 143.6340), cos(-t / 99.4324));
200+
vec2 field_part2 = uv_scaled_centered + 50.*vec2(cos( t / 53.1532), cos( t / 61.4532));
201+
vec2 field_part3 = uv_scaled_centered + 50.*vec2(sin(-t / 87.53218), sin(-t / 49.0000));
202+
203+
float field = (1.+ (
204+
cos(length(field_part1) / 19.483) + sin(length(field_part2) / 33.155) * cos(field_part2.y / 15.73) +
205+
cos(length(field_part3) / 27.193) * sin(field_part3.x / 21.92) ))/2.;
206+
207+
208+
vec4 pixel = Texel(texture, texture_coords);
209+
210+
float cx = uv_scaled_centered.x * 1.;
211+
float cy = uv_scaled_centered.y * 1.;
212+
213+
float randnum = mod2(floor(4.*t), 256.)*mod2(floor(4.*t), 27.);
214+
randnum = mod2(bitxor(pow(randnum, 3.) - randnum + 3., 7. + floor(randnum/11.)), 256.);
215+
randnum = mod2(randnum*123.54,0.1)*10.;
216+
217+
218+
219+
vec4 hsl = HSL(vec4(tex.r, tex.g, tex.b, tex.a));
220+
221+
float xorscale = 10.;
222+
223+
// |y| = 50, |x| = 50
224+
225+
float mbx;
226+
float mby;
227+
float offx;
228+
float offy;
229+
float rmasksum = -1.;
230+
float rectmask = 1.;
231+
t = floor(t/4.);
232+
233+
for(float i = 0.; i < 5.; i++)
234+
{
235+
randnum = bitxor(255.*randnum + mod2(t,81.), pow(randnum*(16.-i), 2.));
236+
mbx = (cx - 25.*sin(100./randnum)) * (1. + 2.*(floor(cos(177./randnum + 1.))));
237+
mby = (cy - 25.*cos(113./randnum + 1.)) * (1. + 2.*(floor(sin(221./randnum))));
238+
offx = bitxor(255.*randnum, pow(255.*randnum,5.) - 255.*randnum);
239+
offy = bitxor(255.*randnum, pow(255.*randnum,5.) + 255.*randnum);
240+
offx /= 10.;
241+
offy /= 10.;
242+
rectmask = (-mbx + abs(abs(mbx) + offx) - offx) - (mby - abs(abs(mby) - offy) + offy);
243+
rmasksum *= -1. * min(0., max(-1., 5. - pow(rectmask, 2.)));
244+
}
245+
246+
float laddermask = pow(sin((23.-20.*randnum*randnum)*pow(sin(sin(cy*randnum) + pow(sin(cy*randnum),2.)),2.)),2.) * rmasksum;
247+
248+
249+
hsl.x += floor(randnum + 0.1) * rmasksum * 4. * randnum * (1. - laddermask);// * bitxor(cx * xorscale, cy * xorscale)/4;
250+
hsl.y += laddermask * (1. + 2. * rmasksum);
251+
hsl.z += floor(randnum + 0.2) * (1. + rmasksum) * (1. - 1.5*hsl.z) * 0.1;
252+
253+
tex.rgb = RGB(hsl).rgb;
254+
255+
pixel = vec4(pixel.rgb * 0.0 + tex.rgb * tex.a, pixel.a);
256+
257+
258+
259+
float res = (.5 + .5* cos( (glitched_b.x) * 2.612 + ( field + -.5 ) *3.14));
260+
vec4 textp = RGB(hsl);
261+
tex.rgb = textp.rgb;
262+
return dissolve_mask(tex*colour, texture_coords, uv);
263+
}
264+
265+
extern MY_HIGHP_OR_MEDIUMP vec2 mouse_screen_pos;
266+
extern MY_HIGHP_OR_MEDIUMP float hovering;
267+
extern MY_HIGHP_OR_MEDIUMP float screen_scale;
268+
269+
#ifdef VERTEX
270+
vec4 position( mat4 transform_projection, vec4 vertex_position )
271+
{
272+
if (hovering <= 0.){
273+
return transform_projection * vertex_position;
274+
}
275+
float mid_dist = length(vertex_position.xy - 0.5*love_ScreenSize.xy)/length(love_ScreenSize.xy);
276+
vec2 mouse_offset = (vertex_position.xy - mouse_screen_pos.xy)/screen_scale;
277+
float scale = 0.2*(-0.03 - 0.3*max(0., 0.3-mid_dist))
278+
*hovering*(length(mouse_offset)*length(mouse_offset))/(2. -mid_dist);
279+
280+
return transform_projection * vertex_position + vec4(0.,0.,0.,scale);
281+
}
282+
#endif

assets/shaders/gold.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ vec4 position( mat4 transform_projection, vec4 vertex_position )
109109
float scale = 0.2*(-0.03 - 0.3*max(0., 0.3-mid_dist))
110110
*hovering*(length(mouse_offset)*length(mouse_offset))/(2. -mid_dist);
111111

112-
return transform_projection * vertex_position + vec4(0,0,0,scale);
112+
return transform_projection * vertex_position + vec4(0.,0.,0.,scale);
113113
}
114114
#endif

0 commit comments

Comments
 (0)