Skip to content
Permalink
Browse files

optimize spell intro and outro shaders

  • Loading branch information...
Akaricchi committed Sep 14, 2019
1 parent 0890da1 commit cfbb35e874f580331a6fa68084b7c51c78bd854f
@@ -5,7 +5,6 @@

void main(void) {
vec2 pos = texCoordRaw;
vec4 clr = texture(tex, texCoord);
pos -= origin;
pos.y *= ratio;
float r = length(pos);
@@ -18,8 +17,12 @@ void main(void) {
// now make it grow with time.
rmax *= step(0, t) * t * 1.5;

if(r > rmax) {
discard;
}

vec4 clr = texture(tex, texCoord);

// at the rim, invert colors
fragColor = mix(clr, vec4(1) - vec4(clr.rgb, 0), step(rmax-0.1*sqrt(r),r));

fragColor *= step(r, rmax);
}
@@ -5,21 +5,24 @@

void main(void) {
vec2 pos = texCoordRaw;
vec4 clr = texture(tex, texCoord);
pos -= origin;
pos.y *= ratio;
float r = length(pos);
float phi = atan(pos.y,pos.x)+t/10.0;

// everything lesser than rmin is not drawn. The sine creates the
// spinning wavy border.
float rmin = (1 + 0.3 * sin(t * 20 + 10 * phi));

// now grow it
rmin *= step(0.,t) * t * t * 10;

if(r < rmin) {
discard;
}

vec4 clr = texture(tex, texCoord);

// at the rim, invert colors
fragColor = mix(clr, vec4(1.0) - vec4(clr.rgb,0.), step(r, rmin + t * (0.1 + 0.1 * sin(10 * r))));

fragColor *= step(rmin, r);
}

0 comments on commit cfbb35e

Please sign in to comment.
You can’t perform that action at this time.