Aetherius draws bars like I want on its HUD, by drawing each 1-pixel-wide sliver of the bar with a separate draw call. This is very slow. I'd like to help with that by skewing them with a shader instead, which should be much faster.
But I've got a problem. Currently, an ordinary texture can be drawn on the status bar, a shader can be attached to it via GLDEFS, and it can skew the texture just fine—but the horizontal skew is proportional to the scaled width of the texture, not the height! The result is like the bottom bar in the above demonstration.
This is my shader:
Code: Select all
const mat2 shearMatrix = mat2(1, 20./220., 0, 1);
const vec4 trans = vec4(0., 0., 0., 0.);
vec4 Process(vec4 color) {
vec2 xy = gl_TexCoord[0].st;
xy -= .5;
xy.x *= 1. + (20. / 220.);
xy *= shearMatrix;
xy += .5;
if (xy.x < 0. || xy.x > 1.)
return trans * color;
else
return getTexel(xy) * color;
}
Code: Select all
SetSize(0, 1440, 1080);
int value = CPlayer.Health;
int MaxValue = CPlayer.mo.GetMaxHealth(true);
int MaxFillWidth = 200;
TextureID Fill = TexMan.CheckForTexture("HPBFILNV", TexMan.Type_Any);
Vector2 Pos = (250, -175);
int DrawFlags = DI_ITEM_LEFT_TOP | DI_SCREEN_LEFT_BOTTOM;
double scale = double(value) / double(MaxValue);
double underScale = min(scale, 1.0) * MaxFillWidth;
DrawTexture(Fill, Pos, DrawFlags, scale: (underScale, 1));
Does anyone have any idea how to make it skew like I want? Is it possible, under the current constraints of GZDoom custom texture shaders?