Implement DrawGraph.BlendAMapBright

This commit is contained in:
Nunuhara Cabbage
2022-05-02 17:01:23 -07:00
parent 6d745054a4
commit 2f573803c4
4 changed files with 55 additions and 9 deletions
+2 -1
View File
@@ -116,8 +116,9 @@ void gfx_blend_add_satur(Texture *dst, int dx, int dy, Texture *src, int sx, int
void gfx_blend_amap(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h);
void gfx_blend_amap_src_only(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h);
void gfx_blend_amap_color(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h, int r, int g, int b);
void gfx_blend_amap_alpha(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h, int a);
void gfx_blend_amap_color_alpha(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int r, int g, int b, int a);
void gfx_blend_amap_alpha(struct texture *dst, int dx, int dy, struct texture *src, int sx, int sy, int w, int h, int a);
void gfx_blend_amap_bright(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int rate);
void gfx_fill(struct texture *dst, int x, int y, int w, int h, int r, int g, int b);
void gfx_fill_alpha_color(struct texture *dst, int x, int y, int w, int h, int r, int g, int b, int a);
void gfx_fill_amap(struct texture *dst, int x, int y, int w, int h, int a);
+26
View File
@@ -0,0 +1,26 @@
/* Copyright (C) 2019 Nunuhara Cabbage <nunuhara@haniwa.technology>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://gnu.org/licenses/>.
*/
uniform sampler2D tex;
uniform float threshold;
in vec2 tex_coord;
out vec4 frag_color;
void main() {
vec4 texel = texture(tex, tex_coord);
frag_color = vec4(texel.rgb * threshold, texel.a);
}
+21 -6
View File
@@ -64,6 +64,7 @@ static struct copy_shader copy_use_amap_under_shader;
static struct copy_shader copy_use_amap_border_shader;
static struct copy_shader blend_amap_color_shader;
static struct copy_shader blend_amap_alpha_shader;
static struct copy_shader blend_amap_bright_shader;
static struct copy_shader fill_shader;
static struct copy_shader fill_amap_over_border_shader;
static struct copy_shader fill_amap_under_border_shader;
@@ -119,6 +120,9 @@ void gfx_draw_init(void)
// copy shader that multiples the source alpha by a constant
load_copy_shader(&blend_amap_alpha_shader, "shaders/render.v.glsl", "shaders/blend_amap_alpha.f.glsl");
// copy shader that multiples the source color by a constant
load_copy_shader(&blend_amap_bright_shader, "shaders/render.v.glsl", "shaders/blend_amap_bright.f.glsl");
// basic fill shader
load_copy_shader(&fill_shader, "shaders/render.v.glsl", "shaders/fill.f.glsl");
@@ -369,6 +373,20 @@ void gfx_blend_amap_color(Texture *dst, int dx, int dy, Texture *src, int sx, in
restore_blend_mode();
}
void gfx_blend_amap_color_alpha(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int r, int g, int b, int a)
{
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
struct copy_data data = COPY_DATA(dx, dy, sx, sy, w, h);
data.r = r / 255.0;
data.g = g / 255.0;
data.b = b / 255.0;
data.a = a / 255.0;
run_copy_shader(&blend_amap_color_shader.s, dst, src, &data);
restore_blend_mode();
}
void gfx_blend_amap_alpha(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int a)
{
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -380,16 +398,13 @@ void gfx_blend_amap_alpha(Texture *dst, int dx, int dy, Texture *src, int sx, in
restore_blend_mode();
}
void gfx_blend_amap_color_alpha(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int r, int g, int b, int a)
void gfx_blend_amap_bright(Texture *dst, int dx, int dy, Texture *src, int sx, int sy, int w, int h, int rate)
{
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
struct copy_data data = COPY_DATA(dx, dy, sx, sy, w, h);
data.r = r / 255.0;
data.g = g / 255.0;
data.b = b / 255.0;
data.a = a / 255.0;
run_copy_shader(&blend_amap_color_shader.s, dst, src, &data);
data.threshold = rate / 255.0;
run_copy_shader(&blend_amap_bright_shader.s, dst, src, &data);
restore_blend_mode();
}
+6 -2
View File
@@ -121,7 +121,11 @@ static void DrawGraph_BlendAMapAlpha(int dst, int dx, int dy, int src, int sx, i
gfx_blend_amap_alpha(DTEX(dst), dx, dy, STEX(src), sx, sy, w, h, alpha);
}
//void DrawGraph_BlendAMapBright(int dst, int dx, int dy, int src, int sx, int sy, int w, int h, int rate);
static void DrawGraph_BlendAMapBright(int dst, int dx, int dy, int src, int sx, int sy, int w, int h, int rate)
{
gfx_blend_amap_bright(DTEX(dst), dx, dy, STEX(src), sx, sy, w, h, rate);
}
//void DrawGraph_BlendAMapAlphaSrcBright(int dst, int dx, int dy, int src, int sx, int sy, int w, int h, int alpha, int rate);
//void DrawGraph_BlendUseAMapColor(int dst, int dx, int dy, int alpha, int ax, int ay, int w, int h, int r, int g, int b, int rate);
//void DrawGraph_BlendScreen(int dst, int dx, int dy, int src, int sx, int sy, int w, int h);
@@ -371,7 +375,7 @@ HLL_LIBRARY(DrawGraph,
HLL_EXPORT(BlendAMapColor, DrawGraph_BlendAMapColor),
HLL_EXPORT(BlendAMapColorAlpha, DrawGraph_BlendAMapColorAlpha),
HLL_EXPORT(BlendAMapAlpha, DrawGraph_BlendAMapAlpha),
//HLL_EXPORT(BlendAMapBright, DrawGraph_BlendAMapBright),
HLL_EXPORT(BlendAMapBright, DrawGraph_BlendAMapBright),
//HLL_EXPORT(BlendAMapAlphaSrcBright, DrawGraph_BlendAMapAlphaSrcBright),
//HLL_EXPORT(BlendUseAMapColor, DrawGraph_BlendUseAMapColor),
//HLL_EXPORT(BlendScreen, DrawGraph_BlendScreen),