From 29cafd177e52d859f3c00e57ac64fbd955fdc394 Mon Sep 17 00:00:00 2001 From: Alex Zhuohao He Date: Sun, 19 Jan 2025 19:28:05 -0500 Subject: [PATCH] reset world2d shader and render_entity to prepare creating a demo for shader command --- assets/shaders/world2d.frag.glsl | 35 +++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/assets/shaders/world2d.frag.glsl b/assets/shaders/world2d.frag.glsl index f9de0354ba..08fb548ef3 100644 --- a/assets/shaders/world2d.frag.glsl +++ b/assets/shaders/world2d.frag.glsl @@ -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; @@ -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; -} +} \ No newline at end of file