@@ -758,20 +758,27 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t
758758 break ;
759759 }
760760
761- // FIXME: find some way to implement this.
762- #if 0
763- // if in greyscale rendering mode turn all color values into greyscale.
764- if (r_greyscale -> integer )
761+ if (pStage -> rgbGen == CGEN_CONST || pStage -> rgbGen == CGEN_FOG
762+ || pStage -> rgbGen == CGEN_ENTITY || pStage -> rgbGen == CGEN_ONE_MINUS_ENTITY )
765763 {
766- int scale ;
767-
768- for (i = 0 ; i < tess .numVertexes ; i ++ )
764+ // if in greyscale rendering mode turn all color values into greyscale.
765+ if (r_greyscale -> integer )
769766 {
770- scale = (tess .svars .colors [i ][0 ] + tess .svars .colors [i ][1 ] + tess .svars .colors [i ][2 ]) / 3 ;
771- tess .svars .colors [i ][0 ] = tess .svars .colors [i ][1 ] = tess .svars .colors [i ][2 ] = scale ;
767+ float scale ;
768+
769+ scale = LUMA (baseColor [0 ], baseColor [1 ], baseColor [2 ]);
770+ baseColor [0 ] = baseColor [1 ] = baseColor [2 ] = scale ;
771+ }
772+ else if (r_greyscale -> value )
773+ {
774+ float scale ;
775+
776+ scale = LUMA (baseColor [0 ], baseColor [1 ], baseColor [2 ]);
777+ baseColor [0 ] = LERP (baseColor [0 ], scale , r_greyscale -> value );
778+ baseColor [1 ] = LERP (baseColor [1 ], scale , r_greyscale -> value );
779+ baseColor [2 ] = LERP (baseColor [2 ], scale , r_greyscale -> value );
772780 }
773781 }
774- #endif
775782}
776783
777784
@@ -2008,6 +2015,36 @@ void RB_StageIteratorGeneric( void )
20082015
20092016 if (tess .useInternalVao )
20102017 {
2018+ if (vertexAttribs & ATTR_COLOR )
2019+ {
2020+ // if in greyscale rendering mode turn all color values into greyscale.
2021+ if (r_greyscale -> integer )
2022+ {
2023+ uint16_t * color = tess .color [0 ];
2024+ int i ;
2025+ int scale ;
2026+ for (i = 0 ; i < tess .numVertexes ; i ++ , color += 4 )
2027+ {
2028+ scale = LUMA (color [0 ], color [1 ], color [2 ]);
2029+ color [0 ] = color [1 ] = color [2 ] = scale ;
2030+ }
2031+ }
2032+ else if (r_greyscale -> value )
2033+ {
2034+ uint16_t * color = tess .color [0 ];
2035+ int i ;
2036+ float scale ;
2037+
2038+ for (i = 0 ; i < tess .numVertexes ; i ++ , color += 4 )
2039+ {
2040+ scale = LUMA (color [0 ], color [1 ], color [2 ]);
2041+ color [0 ] = LERP (color [0 ], scale , r_greyscale -> value );
2042+ color [1 ] = LERP (color [1 ], scale , r_greyscale -> value );
2043+ color [2 ] = LERP (color [2 ], scale , r_greyscale -> value );
2044+ }
2045+ }
2046+ }
2047+
20112048 RB_UpdateTessVao (vertexAttribs );
20122049 }
20132050 else
0 commit comments