diff --git a/code/weapon/weapons.cpp b/code/weapon/weapons.cpp index 771b2238d30..4d71f780f08 100644 --- a/code/weapon/weapons.cpp +++ b/code/weapon/weapons.cpp @@ -8819,6 +8819,8 @@ void weapon_render(object* obj, model_draw_list *scene) vm_vec_scale_add(&tailp, &obj->pos, &rotated_offset, laser_length); vm_vec_scale_add(&headp, &tailp, &obj->orient.vec.fvec, laser_length); + float main_bitmap_alpha_mult = 1.0; + if (wip->laser_bitmap.first_frame >= 0) { gr_set_color_fast(&wip->laser_color_1); @@ -8851,16 +8853,16 @@ void weapon_render(object* obj, model_draw_list *scene) float scaled_head_radius = model_render_get_diameter_clamped_to_min_pixel_size(&headp, wip->laser_head_radius * radius_mult, wip->laser_min_pixel_size); float scaled_tail_radius = model_render_get_diameter_clamped_to_min_pixel_size(&tailp, wip->laser_tail_radius * radius_mult, wip->laser_min_pixel_size); - int alpha = static_cast(alphaf * 255.0f); + int alpha = fl2i(alphaf * 255.0f); // render the head-on bitmap if appropriate and maybe adjust the main bitmap's alpha if (wip->laser_headon_bitmap.first_frame >= 0) { - float main_bitmap_alpha_mult = weapon_render_headon_bitmap(obj, &headp, &tailp, + main_bitmap_alpha_mult = weapon_render_headon_bitmap(obj, &headp, &tailp, wip->laser_headon_bitmap.first_frame + headon_framenum, scaled_head_radius, scaled_tail_radius, alpha, alpha, alpha); - alpha = static_cast(alphaf * main_bitmap_alpha_mult * 255.0); + alpha = fl2i(alphaf * main_bitmap_alpha_mult * 255.0); } batching_add_laser( @@ -8944,20 +8946,26 @@ void weapon_render(object* obj, model_draw_list *scene) float scaled_head_radius = model_render_get_diameter_clamped_to_min_pixel_size(&headp2, wip->laser_head_radius * radius_mult, wip->laser_min_pixel_size); float scaled_tail_radius = model_render_get_diameter_clamped_to_min_pixel_size(&tailp2, wip->laser_tail_radius * radius_mult, wip->laser_min_pixel_size); - int r = static_cast(static_cast(c.red) * alphaf); - int g = static_cast(static_cast(c.green) * alphaf); - int b = static_cast(static_cast(c.blue) * alphaf); + int r = fl2i(i2fl(c.red) * alphaf); + int g = fl2i(i2fl(c.green) * alphaf); + int b = fl2i(i2fl(c.blue) * alphaf); // render the head-on bitmap if appropriate and maybe adjust the main bitmap's alpha if (wip->laser_glow_headon_bitmap.first_frame >= 0) { - float main_bitmap_alpha_mult = weapon_render_headon_bitmap(obj, &headp2, &tailp2, + float head_alpha = 1.0 - main_bitmap_alpha_mult; + + r = (int)(r * head_alpha); g = (int)(g * head_alpha); b = (int)(b * head_alpha); + + batching_add_laser( wip->laser_glow_headon_bitmap.first_frame + headon_framenum, + &headp2, scaled_head_radius * wip->laser_glow_head_scale, + &tailp2, scaled_tail_radius * wip->laser_glow_tail_scale, r, g, b); - r = static_cast(static_cast(c.red) * alphaf * main_bitmap_alpha_mult); - g = static_cast(static_cast(c.green) * alphaf * main_bitmap_alpha_mult); - b = static_cast(static_cast(c.blue) * alphaf * main_bitmap_alpha_mult); + r = fl2i(i2fl(c.red) * alphaf * main_bitmap_alpha_mult); + g = fl2i(i2fl(c.green) * alphaf * main_bitmap_alpha_mult); + b = fl2i(i2fl(c.blue) * alphaf * main_bitmap_alpha_mult); } batching_add_laser(