diff --git a/hueshift.glsl b/hueshift.glsl index b2ee5a6..a5bb4e9 100644 --- a/hueshift.glsl +++ b/hueshift.glsl @@ -14,6 +14,7 @@ uniform sampler2D iChannel0; uniform uniforms { int is_colorless; // if greater than zero, no color float target_hue; + float alpha; }; in vec2 texUV; out vec4 fragColor; @@ -47,17 +48,19 @@ vec3 hsv2rgb(vec3 c) void main() { vec4 outColor = texture2DAA(iChannel0, texUV); + outColor.a *= alpha; vec3 hsv = rgb2hsv(outColor.rgb); - - if(is_colorless > 0) - { - hsv.y = 0.0f; - } else { - float green_hue = 118.0f / 360.0f; - if(abs(hsv.r - green_hue) < 0.15) { - hsv.x = target_hue; + + float green_hue = 118.0f / 360.0f; + if(abs(hsv.r - green_hue) < 0.15) { + if(is_colorless > 0) + { + hsv.y = 0.0f; + } else { + hsv.x = target_hue; } } + fragColor = vec4(hsv2rgb(hsv), outColor.a); } @end diff --git a/loaded/flag_available.png b/loaded/flag_available.png index 3f7c77a..62d70ff 100644 Binary files a/loaded/flag_available.png and b/loaded/flag_available.png differ diff --git a/loaded/flag_ripped.png b/loaded/flag_ripped.png index 5d8a594..1b8a1e3 100644 Binary files a/loaded/flag_ripped.png and b/loaded/flag_ripped.png differ diff --git a/loaded/missile.png b/loaded/missile.png index 0b7781e..33953d9 100644 Binary files a/loaded/missile.png and b/loaded/missile.png differ diff --git a/loaded/missile_burning.png b/loaded/missile_burning.png index 0c56182..a147f6e 100644 Binary files a/loaded/missile_burning.png and b/loaded/missile_burning.png differ diff --git a/main.c b/main.c index 0365e3b..6a8a40f 100644 --- a/main.c +++ b/main.c @@ -736,9 +736,9 @@ static void draw_circle(cpVect point, double radius) double progress = (float)i / (float)POINTS; double next_progress = (float)(i + 1) / (float)POINTS; lines[i].a = V2point((cpVect){.x = cos(progress * 2.0 * PI) * radius, - .y = sin(progress * 2.0 * PI) * radius}); + .y = sin(progress * 2.0 * PI) * radius}); lines[i].b = V2point((cpVect){.x = cos(next_progress * 2.0 * PI) * radius, - .y = sin(next_progress * 2.0 * PI) * radius}); + .y = sin(next_progress * 2.0 * PI) * radius}); lines[i].a = V2point(cpvadd(pointV2(lines[i].a), point)); lines[i].b = V2point(cpvadd(pointV2(lines[i].b), point)); } @@ -761,6 +761,7 @@ static void setup_hueshift(enum Squad squad) hueshift_uniforms_t uniform = { .is_colorless = meta.is_colorless, .target_hue = (float)meta.hue, + .alpha = sgp_get_color().a, }; sgp_set_uniform(&uniform, sizeof(hueshift_uniforms_t)); } @@ -992,10 +993,10 @@ static void ui(bool draw, double dt, double width, double height) cpVect top_of_head = world_to_screen( width, height, cpvadd(entity_pos(inviting), - (cpVect){.y = player_scaling * PLAYER_SIZE.y / 2.0})); + (cpVect){.y = player_scaling * PLAYER_SIZE.y / 2.0})); cpVect pos = cpvadd(top_of_head, (cpVect){.y = -30.0}); cpVect to_mouse = cpvsub(mouse_pos, - world_to_screen(width, height, entity_pos(inviting))); + world_to_screen(width, height, entity_pos(inviting))); bool selecting_to_invite = cpvdot(cpvnormalize(to_mouse), (cpVect){0.0, -1.0}) > 0.5 && cpvlength(to_mouse) > 15.0; @@ -1142,6 +1143,7 @@ static void ui(bool draw, double dt, double width, double height) pipeline_scope(hueshift_pipeline) { + set_color(WHITE); setup_hueshift(this_squad); rotate_at(flag_rot[i], flag_pos[i].x, flag_pos[i].y); @@ -1940,23 +1942,6 @@ static void frame(void) } sgp_reset_image(0); - if (b->box_type == BoxMissileLauncher) - { - set_color(RED); - draw_circle(entity_pos(b), MISSILE_RANGE); - - // draw the charging missile - transform_scope - { - rotate_at(missile_launcher_target(&gs, b).facing_angle, entity_pos(b).x, entity_pos(b).y); - set_color_values(1.0, 1.0, 1.0, b->missile_construction_charge); - sgp_set_image(0, image_missile); - pipeline_scope(goodpixel_pipeline) - draw_texture_centered(entity_pos(b), BOX_SIZE); - sgp_reset_image(0); - } - } - if (b->box_type == BoxScanner) { sgp_set_image(0, image_scanner_head); @@ -2004,6 +1989,25 @@ static void frame(void) draw_line(entity_pos(b).x, entity_pos(b).y, to.x, to.y); } } + if (b->box_type == BoxMissileLauncher) + { + set_color(RED); + draw_circle(entity_pos(b), MISSILE_RANGE); + + // draw the charging missile + transform_scope + { + rotate_at(missile_launcher_target(&gs, b).facing_angle, entity_pos(b).x, entity_pos(b).y); + sgp_set_image(0, image_missile); + pipeline_scope(hueshift_pipeline) + { + set_color_values(1.0, 1.0, 1.0, b->missile_construction_charge); + setup_hueshift(b->owning_squad); + draw_texture_centered(entity_pos(b), BOX_SIZE); + } + sgp_reset_image(0); + } + } } } @@ -2024,8 +2028,13 @@ static void frame(void) sgp_set_image(0, image_missile); } - pipeline_scope(goodpixel_pipeline) - draw_texture_rectangle_centered(entity_pos(e), MISSILE_SPRITE_SIZE); + pipeline_scope(hueshift_pipeline) + { + setup_hueshift(e->owning_squad); + draw_texture_rectangle_centered(entity_pos(e), MISSILE_SPRITE_SIZE); + } + + sgp_reset_image(0); } }