62 lines
1.9 KiB
GLSL
62 lines
1.9 KiB
GLSL
/*@~@~@ |C|A|K|E|F|O|O|T| <presented by> 💫dank.game💫
|
|
|~)~)~)
|
|
|\~*~*| Licensed under the zlib and CC-BY licenses. Source is available at
|
|
|\\~*~|
|
|
,~|#\\~*|~, <https://open.shampoo.ooo/shampoo/cakefoot>
|
|
: \\@\\~| :
|
|
: \\#\\| : Created with open SPACE🪐BOX engine for cross-platform, PC, web and mobile games
|
|
: \\@\' :
|
|
: \\/ : <https://open.shampoo.ooo/shampoo/spacebox>
|
|
`~ ~ ~`~ ~'
|
|
|
|
The contents of this file must be appended to a file which forward declares a bg function and defines a main function.
|
|
See shaders/shader.frag.
|
|
|
|
This is a modification of "earthbound bg 3" by @thefox231 on ShaderToy:
|
|
|
|
https://www.shadertoy.com/view/wtXcR4
|
|
|
|
*/
|
|
|
|
bool equals(float a, float b) {
|
|
return mod(abs(a - b), 1.0) < bg_control_2;
|
|
}
|
|
|
|
vec4 bg() {
|
|
vec2 uv = gl_FragCoord.xy / resolution;
|
|
vec3 color= vec3(0);
|
|
|
|
// fix aspect ratio
|
|
float aspectRatio = resolution.x / resolution.y;
|
|
uv.x *= aspectRatio;
|
|
uv.x -= (aspectRatio - 1.) * .5;
|
|
|
|
// pixelate
|
|
uv = floor(uv * bg_control_1) / bg_control_1;
|
|
|
|
// interlacing .
|
|
if (mod(gl_FragCoord.y, 2.) < 1.) {
|
|
uv += .4 + sin(time * .5 + uv.y * 15.) * 0.1;
|
|
} else {
|
|
uv -= .4 + cos(time * .5 + uv.y * 15. + .5) * 0.1;
|
|
}
|
|
|
|
// weird plasma circles thing......
|
|
float circleDistance = 1.0 - length(vec2(.5, .5) - uv);
|
|
vec3 circleColor = bg_color_1.xyz * .8 + sin(time + uv.x * 6. + uv.y * 9. + sin(uv.x * 8.) + cos(time)) * .15;
|
|
|
|
if (equals(circleDistance, time * .1 + sin(uv.y * 3.) * (.6 + sin(time * .3) * .4))) {
|
|
color += circleColor;
|
|
} else {
|
|
float avg = (circleColor.r + circleColor.g + circleColor.b) / 3.;
|
|
color += vec3(avg) * .4 * circleDistance;
|
|
}
|
|
|
|
// color shortening
|
|
// gives it a kind of like snes-like palette
|
|
float shortAmt = 100.0;
|
|
color = ceil(color * shortAmt) / shortAmt;
|
|
|
|
return vec4(color, 1.);
|
|
}
|