[Shader] interactive sprite rotation
Posted: Fri Nov 18, 2016 10:28 am
This is a silly trick where the alpha channel of a sprite, texture, hudmessage-printed graphic or anything else is hijacked as an argument for rotation. This means you can make smoothly turning clocks, compasses, rolling cacodemons etc.
Credits: based on the static rotation shader found in a beta of WolfenDoom: Blade of Agony. Edit: No longer applies.
Note: Does not work in GZDoom's GL renderer.
GLDEFS:
arot.txt:
Credits: based on the static rotation shader found in a beta of WolfenDoom: Blade of Agony. Edit: No longer applies.
Note: Does not work in GZDoom's GL renderer.
GLDEFS:
Code: Select all
hardwareshader [texture/sprite/graphic] SomeTextureNameHere
{
shader arot.txt
}
Code: Select all
uniform float timer;
vec4 Process(vec4 color)
{
vec2 tex_coord = gl_TexCoord[0].st;
float angle = color.a*6.283; // turns to radians :^)
float x = tex_coord.x;
float y = tex_coord.y;
float output_x = cos(angle) * (x-0.5) - sin(angle) * (y-0.5) +0.5 ;
float output_y = sin(angle) * (x-0.5) + cos(angle) * (y-0.5) +0.5;
color.a = 1.0;
return getTexel(vec2(output_x, output_y)) * color;
}