Skip to content

Commit

Permalink
Apply render view R/G/B multipliers only when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Nov 21, 2024
1 parent 22ee5ba commit 0df139b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 32 deletions.
5 changes: 4 additions & 1 deletion source_files/edge/r_colormap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,10 @@ class ColormapShader : public AbstractShader
{
RendererVertex *dest = glvert + v_idx;

dest->rgba_color[3] = alpha;
dest->rgba_color[0] *= render_view_red_multiplier;
dest->rgba_color[1] *= render_view_green_multiplier;
dest->rgba_color[2] *= render_view_blue_multiplier;
dest->rgba_color[3] = alpha;

HMM_Vec3 lit_pos;

Expand Down
18 changes: 9 additions & 9 deletions source_files/edge/r_shader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ class dynlight_shader_c : public AbstractShader

float ity = exp(-5.44 * dist * dist);

dest->rgba_color[0] = R * ity;
dest->rgba_color[1] = G * ity;
dest->rgba_color[2] = B * ity;
dest->rgba_color[0] = R * ity * render_view_red_multiplier;
dest->rgba_color[1] = G * ity * render_view_green_multiplier;
dest->rgba_color[2] = B * ity * render_view_blue_multiplier;
dest->rgba_color[3] = alpha;
}

Expand Down Expand Up @@ -540,9 +540,9 @@ class plane_glow_c : public AbstractShader

TexCoord(&dest->texture_coordinates[1], WhatRadius(DL), sec, &lit_pos, &dest->normal);

dest->rgba_color[0] = R;
dest->rgba_color[1] = G;
dest->rgba_color[2] = B;
dest->rgba_color[0] = R * render_view_red_multiplier;
dest->rgba_color[1] = G * render_view_green_multiplier;
dest->rgba_color[2] = B * render_view_blue_multiplier;
dest->rgba_color[3] = alpha;
}

Expand Down Expand Up @@ -707,9 +707,9 @@ class wall_glow_c : public AbstractShader

TexCoord(&dest->texture_coordinates[1], WhatRadius(DL), sec, &lit_pos, &dest->normal);

dest->rgba_color[0] = R;
dest->rgba_color[1] = G;
dest->rgba_color[2] = B;
dest->rgba_color[0] = R * render_view_red_multiplier;
dest->rgba_color[1] = G * render_view_green_multiplier;
dest->rgba_color[2] = B * render_view_blue_multiplier;
dest->rgba_color[3] = alpha;
}

Expand Down
24 changes: 12 additions & 12 deletions source_files/edge/r_things.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,19 +414,19 @@ static void RenderPSprite(PlayerSprite *psp, int which, Player *player, RegionPr
}
else if (!is_additive)
{
dest->rgba_color[0] = data.colors[v_idx].modulate_red_ / 255.0;
dest->rgba_color[1] = data.colors[v_idx].modulate_green_ / 255.0;
dest->rgba_color[2] = data.colors[v_idx].modulate_blue_ / 255.0;
dest->rgba_color[0] = data.colors[v_idx].modulate_red_ / 255.0 * render_view_red_multiplier;
dest->rgba_color[1] = data.colors[v_idx].modulate_green_ / 255.0 * render_view_green_multiplier;
dest->rgba_color[2] = data.colors[v_idx].modulate_blue_ / 255.0 * render_view_blue_multiplier;

data.colors[v_idx].modulate_red_ -= 256;
data.colors[v_idx].modulate_green_ -= 256;
data.colors[v_idx].modulate_blue_ -= 256;
}
else
{
dest->rgba_color[0] = data.colors[v_idx].add_red_ / 255.0;
dest->rgba_color[1] = data.colors[v_idx].add_green_ / 255.0;
dest->rgba_color[2] = data.colors[v_idx].add_blue_ / 255.0;
dest->rgba_color[0] = data.colors[v_idx].add_red_ / 255.0 * render_view_red_multiplier;
dest->rgba_color[1] = data.colors[v_idx].add_green_ / 255.0 * render_view_green_multiplier;
dest->rgba_color[2] = data.colors[v_idx].add_blue_ / 255.0 * render_view_blue_multiplier;
}

dest->rgba_color[3] = trans;
Expand Down Expand Up @@ -1357,19 +1357,19 @@ void RenderThing(DrawFloor *dfloor, DrawThing *dthing)
}
else if (!is_additive)
{
dest->rgba_color[0] = data.colors[v_idx].modulate_red_ / 255.0;
dest->rgba_color[1] = data.colors[v_idx].modulate_green_ / 255.0;
dest->rgba_color[2] = data.colors[v_idx].modulate_blue_ / 255.0;
dest->rgba_color[0] = data.colors[v_idx].modulate_red_ / 255.0 * render_view_red_multiplier;
dest->rgba_color[1] = data.colors[v_idx].modulate_green_ / 255.0 * render_view_green_multiplier;
dest->rgba_color[2] = data.colors[v_idx].modulate_blue_ / 255.0 * render_view_blue_multiplier;

data.colors[v_idx].modulate_red_ -= 256;
data.colors[v_idx].modulate_green_ -= 256;
data.colors[v_idx].modulate_blue_ -= 256;
}
else
{
dest->rgba_color[0] = data.colors[v_idx].add_red_ / 255.0;
dest->rgba_color[1] = data.colors[v_idx].add_green_ / 255.0;
dest->rgba_color[2] = data.colors[v_idx].add_blue_ / 255.0;
dest->rgba_color[0] = data.colors[v_idx].add_red_ / 255.0 * render_view_red_multiplier;
dest->rgba_color[1] = data.colors[v_idx].add_green_ / 255.0 * render_view_green_multiplier;
dest->rgba_color[2] = data.colors[v_idx].add_blue_ / 255.0 * render_view_blue_multiplier;
}

dest->rgba_color[3] = trans;
Expand Down
10 changes: 0 additions & 10 deletions source_files/edge/r_units.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,6 @@ void EndRenderUnit(int actual_vert)

unit->count = actual_vert;

// adjust colors (for special effects)
for (int i = 0; i < actual_vert; i++)
{
RendererVertex *v = &local_verts[current_render_vert + i];

v->rgba_color[0] *= render_view_red_multiplier;
v->rgba_color[1] *= render_view_green_multiplier;
v->rgba_color[2] *= render_view_blue_multiplier;
}

current_render_vert += actual_vert;
current_render_unit++;

Expand Down

0 comments on commit 0df139b

Please sign in to comment.