gpu: draw full screen widgets on gpu
This adjusts the draw callbacks api to take in the color of the full screen overlay the client would have rendered. This is primarily used in godwars, underwater, darkmeyer, etc. Having them rasterized on the cpu is slow, especially with gpu on since we additionally have to compute the alpha per-pixel.
This commit is contained in:
@@ -34,6 +34,7 @@ uniform int samplingMode;
|
||||
uniform ivec2 sourceDimensions;
|
||||
uniform ivec2 targetDimensions;
|
||||
uniform int colorBlindMode;
|
||||
uniform vec4 alphaOverlay;
|
||||
|
||||
#include scale/bicubic.glsl
|
||||
#include scale/xbr_lv2_frag.glsl
|
||||
@@ -44,6 +45,13 @@ in XBRTable xbrTable;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 alphaBlend(vec4 src, vec4 dst) {
|
||||
return vec4(
|
||||
src.rgb + dst.rgb * (1.0f - src.a),
|
||||
src.a + dst.a * (1.0f - src.a)
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 c;
|
||||
|
||||
@@ -51,14 +59,17 @@ void main() {
|
||||
case SAMPLING_CATROM:
|
||||
case SAMPLING_MITCHELL:
|
||||
c = textureCubic(tex, TexCoord, samplingMode);
|
||||
c = alphaBlend(c, alphaOverlay);
|
||||
c.rgb = colorblind(colorBlindMode, c.rgb);
|
||||
break;
|
||||
case SAMPLING_XBR:
|
||||
c = textureXBR(tex, TexCoord, xbrTable, ceil(1.0 * targetDimensions.x / sourceDimensions.x));
|
||||
c = alphaBlend(c, alphaOverlay);
|
||||
c.rgb = colorblind(colorBlindMode, c.rgb);
|
||||
break;
|
||||
default: // NEAREST or LINEAR, which uses GL_TEXTURE_MIN_FILTER/GL_TEXTURE_MAG_FILTER to affect sampling
|
||||
c = texture(tex, TexCoord);
|
||||
c = alphaBlend(c, alphaOverlay);
|
||||
c.rgb = colorblind(colorBlindMode, c.rgb);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user