optimize spell intro and outro shaders

This commit is contained in:
Andrei Alexeyev 2019-09-14 19:59:06 +03:00
parent 0890da1f0f
commit cfbb35e874
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
2 changed files with 13 additions and 7 deletions

View file

@ -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);
}

View file

@ -5,12 +5,11 @@
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));
@ -18,8 +17,12 @@ void main(void) {
// 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);
}