CSQC polygon glitches

3D polygons drawn with R_BeginPolygon() R_PolygonVertex() R_EndPolygon() are partially or entirely too dark.

Musicgoat and Mario reported a way to reproduce it clearly with the vaporizer beam:
color "0 0" ; g_instagib 1 ; cl_vaporizerbeam_colorboost 0 ; g_shootfromeye 0 ; g_use_ammunition 0 ; map boil

Click to view screenshot xonotic_vaporizer_beam

It can also be seen on the arc beam.

Clues:

  • the appearance changes as the player moves around relative to the beam
  • mod_q3bsp_lightgrid_texture 0 changes how it looks
  • it's completely black on Q1BSP

It was likely introduced with 4a43205a but it's hard to test properly, with many commits back then the beam isn't drawn at all (until 3291222c), or the player can't join the match.

Edited by bones_was_here