Skip to content

Commit 9773f10

Browse files
committed
NUKE alphaAddOne bit in color modulate
There are no differences in my screenshot test suite as a result of removing this. This alpha := 1 thing only existed in the `generic` shader; its absence in lightMapping is further evidence suggesting it is not needed.
1 parent 5bb6b8b commit 9773f10

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

src/engine/renderer/gl_shader.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,6 @@ struct colorModulation_t {
27382738
float alphaGen = 0.0f;
27392739
float lightFactor = 1.0f;
27402740
bool useVertexLightFactor = false;
2741-
bool alphaAddOne = true;
27422741
};
27432742

27442743
static colorModulation_t ColorModulateColorGen(
@@ -2752,8 +2751,6 @@ static colorModulation_t ColorModulateColorGen(
27522751
switch ( colorGen )
27532752
{
27542753
case colorGen_t::CGEN_VERTEX:
2755-
colorModulation.alphaAddOne = false;
2756-
27572754
if ( vertexOverbright )
27582755
{
27592756
// vertexOverbright is only needed for non-lightmapped cases. When there is a
@@ -2768,7 +2765,6 @@ static colorModulation_t ColorModulateColorGen(
27682765
break;
27692766

27702767
case colorGen_t::CGEN_ONE_MINUS_VERTEX:
2771-
colorModulation.alphaAddOne = false;
27722768
colorModulation.colorGen = -1.0f;
27732769
break;
27742770

@@ -2785,12 +2781,10 @@ static colorModulation_t ColorModulateColorGen(
27852781
switch ( alphaGen )
27862782
{
27872783
case alphaGen_t::AGEN_VERTEX:
2788-
colorModulation.alphaAddOne = false;;
27892784
colorModulation.alphaGen = 1.0f;
27902785
break;
27912786

27922787
case alphaGen_t::AGEN_ONE_MINUS_VERTEX:
2793-
colorModulation.alphaAddOne = false;;
27942788
colorModulation.alphaGen = -1.0f;
27952789
break;
27962790

@@ -2827,7 +2821,7 @@ class u_ColorModulateColorGen_Float :
28272821
colorModulate_Float[ 0 ] = colorModulation.colorGen;
28282822
colorModulate_Float[ 1 ] = colorModulation.lightFactor;
28292823
colorModulate_Float[ 1 ] *= colorModulation.useVertexLightFactor ? -1.0f : 1.0f;
2830-
colorModulate_Float[ 2 ] = colorModulation.alphaAddOne;
2824+
colorModulate_Float[ 2 ] = {};
28312825
colorModulate_Float[ 3 ] = colorModulation.alphaGen;
28322826

28332827
this->SetValue( colorModulate_Float );
@@ -2859,7 +2853,6 @@ class u_ColorModulateColorGen_Uint :
28592853
COLOR_MINUS_ONE = 1,
28602854
ALPHA_ONE = 2,
28612855
ALPHA_MINUS_ONE = 3,
2862-
ALPHA_ADD_ONE = 4,
28632856
// <-- Insert new bits there.
28642857
IS_LIGHT_STYLE = 27,
28652858
LIGHTFACTOR_BIT0 = 28,
@@ -2879,8 +2872,6 @@ class u_ColorModulateColorGen_Uint :
28792872
<< Util::ordinal( ColorModulate_Bit::ALPHA_ONE );
28802873
colorModulate_Uint |= ( colorModulation.alphaGen == -1.0f )
28812874
<< Util::ordinal( ColorModulate_Bit::ALPHA_MINUS_ONE );
2882-
colorModulate_Uint |= colorModulation.alphaAddOne
2883-
<< Util::ordinal( ColorModulate_Bit::ALPHA_ADD_ONE );
28842875
colorModulate_Uint |= colorModulation.useVertexLightFactor
28852876
<< Util::ordinal( ColorModulate_Bit::IS_LIGHT_STYLE );
28862877
colorModulate_Uint |= uint32_t( colorModulation.lightFactor )

src/engine/renderer/glsl_source/common.glsl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ colorMod << 0: color * 1
6868
colorMod << 1: color * ( -1 )
6969
colorMod << 2: alpha * 1
7070
colorMod << 3: alpha * ( -1 )
71-
colorMod << 4: alpha = 1
72-
colorMod << 5-26: available for future usage
71+
colorMod << 4-26: available for future usage
7372
colorMod << 27: color += lightFactor
7473
colorMod << 28-31: lightFactor
7574
@@ -78,7 +77,6 @@ colorMod float format:
7877
colorMod[ 0 ]: color * f
7978
colorMod[ 1 ] absolute value: lightFactor
8079
colorMod[ 1 ] minus sign: color += lightFactor
81-
colorMod[ 2 ]: alpha = 1
8280
colorMod[ 3 ]: alpha * f */
8381

8482
vec4 ColorModulateToColor( const in colorModulatePack colorMod )
@@ -101,7 +99,6 @@ vec4 ColorModulateToColor( const in colorModulatePack colorMod )
10199

102100
struct ModBits_t
103101
{
104-
bool alphaAddOne;
105102
bool useVertexLightFactor;
106103
};
107104

@@ -110,10 +107,8 @@ ModBits_t ColorModulateToBits( const in colorModulatePack colorMod )
110107
ModBits_t modBits;
111108

112109
#if defined(HAVE_EXT_gpu_shader4)
113-
modBits.alphaAddOne = bool( ( colorMod >> 4u ) & 1u );
114110
modBits.useVertexLightFactor = bool( ( colorMod >> 27u ) & 1u );
115111
#else
116-
modBits.alphaAddOne = colorMod.b != 0;
117112
modBits.useVertexLightFactor = colorMod.g < 0;
118113
#endif
119114

@@ -159,9 +154,6 @@ void ColorModulateColor_lightFactor(
159154
ModBits_t modBits = ColorModulateToBits( colorMod );
160155
float lightFactor = ColorModulateToLightFactor( colorMod );
161156

162-
// This is used to skip vertex colours if the colorMod doesn't need them.
163-
color.a = modBits.alphaAddOne ? 1.0 : color.a;
164-
165157
colorModulation.rgb += vec3( modBits.useVertexLightFactor ? lightFactor : 0 );
166158

167159
vec4 unpackedColor = UnpackColor( packedColor );

0 commit comments

Comments
 (0)