Skip to content

Commit

Permalink
reset world2d shader and render_entity to prepare creating a demo for…
Browse files Browse the repository at this point in the history
… shader command
  • Loading branch information
ZzzhHe committed Jan 20, 2025
1 parent 3dc759f commit 29cafd1
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions assets/shaders/world2d.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

in vec2 vert_uv;

layout(location=0) out vec4 col;
layout(location=1) out uint id;
layout(location = 0) out vec4 col;
layout(location = 1) out uint id;

uniform sampler2D tex;
uniform uint u_id;
Expand All @@ -13,23 +13,30 @@ uniform vec4 tile_params;

vec2 uv = vec2(
vert_uv.x * tile_params.z + tile_params.x,
vert_uv.y * tile_params.w + tile_params.y
);
vert_uv.y *tile_params.w + tile_params.y);

void main() {
vec4 tex_val = texture(tex, uv);
int alpha = int(round(tex_val.a * 255));
switch (alpha) {
case 0:
col = tex_val;
discard;
case 0:
col = tex_val;
discard;

// do not save the ID
return;
//@INSERT_COMMANDS@
default:
col = tex_val;
break;
// do not save the ID
return;
case 254:
col = vec4(1.0f, 0.0f, 0.0f, 1.0f);
break;
case 252:
col = vec4(0.0f, 1.0f, 0.0f, 1.0f);
break;
case 250:
col = vec4(0.0f, 0.0f, 1.0f, 1.0f);
break;
default:
col = tex_val;
break;
}
id = u_id;
}
}

0 comments on commit 29cafd1

Please sign in to comment.