Skip to content

Commit

Permalink
fix: Fixed shader to apply alpha correctly (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
mflerackers authored and lajbel committed Jan 15, 2025
1 parent e9402d8 commit 4949f64
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// some default charsets for loading bitmap fonts
export const ASCII_CHARS =
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
export const DEF_ANCHOR = "topleft";
export const BG_GRID_SIZE = 64;
export const DEF_FONT = "monospace";
Expand All @@ -19,9 +19,9 @@ export const DEF_FONT_FILTER = "linear";
export const LOG_MAX = 8;
export const LOG_TIME = 4;
export const VERTEX_FORMAT = [
{ name: "a_pos", size: 2 },
{ name: "a_uv", size: 2 },
{ name: "a_color", size: 4 },
{ name: "a_pos", size: 2 },
{ name: "a_uv", size: 2 },
{ name: "a_color", size: 4 },
];
const STRIDE = VERTEX_FORMAT.reduce((sum, f) => sum + f.size, 0);
const MAX_BATCHED_QUAD = 2048;
Expand Down Expand Up @@ -62,7 +62,8 @@ varying vec4 v_color;
uniform sampler2D u_tex;
vec4 def_frag() {
return v_color * texture2D(u_tex, v_uv);
vec4 texColor = texture2D(u_tex, v_uv);
return vec4((v_color.rgb * texColor.rgb), texColor.a) * v_color.a;
}
{{user}}
Expand All @@ -88,13 +89,13 @@ vec4 frag(vec2 pos, vec2 uv, vec4 color, sampler2D tex) {
`;
export const COMP_DESC = new Set(["id", "require"]);
export const COMP_EVENTS = new Set([
"add",
"fixedUpdate",
"update",
"draw",
"destroy",
"inspect",
"drawInspect",
"add",
"fixedUpdate",
"update",
"draw",
"destroy",
"inspect",
"drawInspect",
]);
export const DEF_OFFSCREEN_DIS = 200;
// maximum y velocity with body()
Expand Down

0 comments on commit 4949f64

Please sign in to comment.