@@ -807,6 +807,7 @@ static void ProjectDlightTexture( void ) {
807807 return ;
808808 }
809809#endif
810+ if ( !r_vertexLight -> integer )
810811 ProjectDlightTexture_scalar ();
811812}
812813
@@ -944,35 +945,10 @@ static void ComputeColors( shaderStage_t *pStage )
944945 }
945946 }
946947 break ;
947- case CGEN_VERTEX_LIT : // leilei - mixing vertex colors with lighting through a glorious light hack
948- { // should only be used for entity models, not map assets!
949- vec3_t dcolor , acolor ; // to save the color from actual light
950- vec3_t vcolor ;
951- int y ;
952-
953-
954- // Backup our colors
955- VectorCopy ( backEnd .currentEntity -> ambientLight , acolor );
956- VectorCopy ( backEnd .currentEntity -> directedLight , dcolor );
957- VectorCopy ( backEnd .currentEntity -> e .shaderRGBA , vcolor );
958-
959- // Make our vertex color take over
960-
961- for (y = 0 ;y < 3 ;y ++ ){
962- backEnd .currentEntity -> ambientLight [y ] *= (vcolor [y ] / 255 );
963-
964- if (backEnd .currentEntity -> ambientLight [y ] < 1 ) backEnd .currentEntity -> ambientLight [y ] = 1 ; // black!!!
965- if (backEnd .currentEntity -> ambientLight [y ] > 255 ) backEnd .currentEntity -> ambientLight [y ] = 255 ; // white!!!!!
966- // backEnd.currentEntity->ambientLight[y] *= (vcolor[y] / 255);
967- // backEnd.currentEntity->directedLight[y] *= (vcolor[y] / 255);
968- }
969-
970- // run it through our favorite preferred lighting calculation functions
971- RB_CalcDiffuseColor ( ( unsigned char * ) tess .svars .colors );
972-
973- // Restore light color for any other stage that doesn't do it
974- VectorCopy ( acolor , backEnd .currentEntity -> ambientLight );
975- VectorCopy ( dcolor , backEnd .currentEntity -> directedLight );
948+ case CGEN_VERTEX_LIT : // leilei - for world only
949+ {
950+ Com_Memcpy ( tess .svars .colors , tess .vertexColors , tess .numVertexes * sizeof ( tess .vertexColors [0 ] ) );
951+ RB_CalcVertLights ( ( unsigned char * ) tess .svars .colors );
976952 }
977953 break ;
978954 case CGEN_ONE_MINUS_VERTEX :
@@ -1031,42 +1007,14 @@ static void ComputeColors( shaderStage_t *pStage )
10311007 }
10321008 }
10331009 break ;
1034- }
1035-
1036- // leilei PowerVR Hack
1037-
1038- if (r_parseStageSimple -> integer )
1039- {
1040- float scale ;
1041- vec3_t normme ;
1042- if ((pStage -> isBlend == 1 ) || (pStage -> isBlend == 3 )){ // additive or subtracive
1043-
1044- for (i = 0 ; i < tess .numVertexes ; i ++ )
1045- {
1046- scale = LUMA (tess .svars .colors [i ][0 ], tess .svars .colors [i ][1 ], tess .svars .colors [i ][2 ]);
1047- tess .svars .colors [i ][3 ] = scale - tess .svars .colors [i ][3 ];
1048- if (tess .svars .colors [i ][3 ] > 255 ) tess .svars .colors [i ][3 ] = 255 ;
1049-
1050-
1051- normme [0 ] = tess .svars .colors [i ][0 ];
1052- normme [1 ] = tess .svars .colors [i ][1 ];
1053- normme [2 ] = tess .svars .colors [i ][2 ];
1054-
1055- // normme[0] *= (4 * tr.identityLight);
1056- // normme[1] *= (4 * tr.identityLight);
1057- // normme[2] *= (4 * tr.identityLight);
1058-
1059-
1060- VectorNormalize (normme );
1061-
1062-
1063- tess .svars .colors [i ][0 ] = normme [0 ]* 255 ;
1064- tess .svars .colors [i ][1 ] = normme [1 ]* 255 ;
1065- tess .svars .colors [i ][2 ] = normme [2 ]* 255 ;
1066- }
1010+ case CGEN_MATERIAL :
1011+ if (r_shownormals -> integer > 1 || (pStage -> isLeiShade )){
1012+ RB_CalcNormal ( ( unsigned char * ) tess .svars .colors ); // leilei - debug normals, or use the normals as a color for a lighting shader
1013+ break ;
10671014 }
1068-
1069- }
1015+ RB_CalcMaterials ( ( unsigned char * ) tess .svars .colors , pStage -> matAmb , pStage -> matDif , pStage -> matSpec , pStage -> matEmis , pStage -> matHard , pStage -> matAlpha );
1016+ break ;
1017+ }
10701018
10711019 //
10721020 // alphaGen
@@ -1153,6 +1101,34 @@ static void ComputeColors( shaderStage_t *pStage )
11531101 break ;
11541102 }
11551103
1104+ //
1105+ // rgbMod
1106+ //
1107+ switch ( pStage -> rgbMod )
1108+ {
1109+ case CMOD_GLOW :
1110+ RB_CalcGlowBlend ( ( unsigned char * ) tess .svars .colors , pStage -> rgbModCol , pStage -> rgbModMode );
1111+ break ;
1112+ case CMOD_UVCOL :
1113+ RB_CalcUVColor ( ( unsigned char * ) tess .svars .colors , pStage -> rgbModCol , pStage -> rgbModMode );
1114+ break ;
1115+ case CMOD_NORMALIZETOALPHA :
1116+ RB_CalcNormalizeToAlpha ( ( unsigned char * ) tess .svars .colors );
1117+ break ;
1118+ case CMOD_NORMALIZETOALPHAFAST : // TODO: use first vert
1119+ RB_CalcNormalizeToAlpha ( ( unsigned char * ) tess .svars .colors );
1120+ break ;
1121+ case CMOD_OPAQUE :
1122+ for ( i = 0 ; i < tess .numVertexes ; i ++ )
1123+ tess .svars .colors [i ][3 ] = 0xff ;
1124+ break ;
1125+ case CMOD_LIGHTING :
1126+ // TODO
1127+ break ;
1128+ case CMOD_BAD :
1129+ return ;
1130+ }
1131+
11561132 //
11571133 // fog adjustment for colors to fade out as fog increases
11581134 //
@@ -1198,6 +1174,43 @@ static void ComputeColors( shaderStage_t *pStage )
11981174 }
11991175}
12001176
1177+
1178+ /*
1179+ ===============
1180+ ComputeUVColors
1181+ ===============
1182+ */
1183+ static void ComputeUVColors ( shaderStage_t * pStage )
1184+ {
1185+ int i ;
1186+
1187+ //
1188+ // rgbMod
1189+ //
1190+ switch ( pStage -> rgbMod )
1191+ {
1192+ case CMOD_GLOW :
1193+ // we do this elsewhere
1194+ break ;
1195+ case CMOD_UVCOL :
1196+ RB_CalcUVColor ( ( unsigned char * ) tess .svars .colors , pStage -> rgbModCol , pStage -> rgbModMode );
1197+ break ;
1198+ case CMOD_NORMALIZETOALPHA :
1199+ break ;
1200+ case CMOD_NORMALIZETOALPHAFAST : // TODO: use first vert
1201+ break ;
1202+ case CMOD_OPAQUE :
1203+ break ;
1204+ case CMOD_LIGHTING :
1205+ break ;
1206+ case CMOD_BAD :
1207+ return ;
1208+ }
1209+
1210+
1211+ }
1212+
1213+
12011214/*
12021215===============
12031216ComputeTexCoords
0 commit comments