I didn't want to bitrot my powervr hacking attempts any further, so here's the changed code files for my hacked up methods. Can't make a diff right now.
There's probably even more crap leftover from other unrelated hacks such as a failure to implement tinysdgl, reimplementing tinyfont for the console in low resolution modes, and an attempt to not overbright rgbGen const.
This is all dirty and experimental and probably shouldn't be implemented in its current state. It adds these cvars (which may need to be cheat-protected)
r_mocksw - Mocks what a (theoretical) software renderer or Matrox Mystique could look like
r_mockrage - Mocks what a Rage Pro could look like (incomplete, but basically taking off modulation of any kind for alphas)
r_mockvr - Mocks what PowerVR PCX2 looks like (almost - the different sorting isn't mocked). This is useful for debugging shaders being developed for this card.
r_hackvr - Hacks some functions to enable it to be PowerVR friendly - like flares will start to alpha fade, dynamic light textures get alpha'd
The real guts of the hack is to add an alphahack check in Upload32, determining how to process from the alphahack command in the shader. This would process the texture in various ways like
// fromhell - the meat of the alpha hack
if (r_mockvr->integer){
if( alphahack == 1 ) // Additives
{
for ( i = 0; i < c; i++ )
{
byte alfa = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]);
scan[i*4 + 3] = alfa;
// stupid normalization hack
/* thecolor[0] = scan[i*4];
thecolor[1] = scan[i*4 + 1];
thecolor[2] = scan[i*4 + 2];
NormalizeColor( thecolor, thecolor);
scan[i*4] = thecolor[0];
scan[i*4 + 1] = thecolor[1];
scan[i*4 + 2] = thecolor[2]; */
}
}
if( alphahack == 3 ) // Subtractives
{
for ( i = 0; i < c; i++ )
{
byte alfa = LUMA(scan[i*4] * -1, scan[i*4 + 1] * -1, scan[i*4 + 2] * -1);
scan[i*4 + 3] = alfa;
}
}
if( alphahack == 4 ) // Multiplies
{
for ( i = 0; i < c; i++ )
{
byte alfa = LUMA(scan[i*4] + 127, scan[i*4 + 1] + 127, scan[i*4 + 2] + 127);
scan[i*4 + 3] = alfa;
}
}
if( alphahack == 2 ) // Demoting alphas (i.e. for shiny walls and some players)
{
for ( i = 0; i < c; i++ )
{
scan[i*4 + 3] = 255;
}
}
if( alphahack == 5 ) // Additives, special for rgbGens
{
for ( i = 0; i < c; i++ )
{
byte alfa = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]);
scan[i*4 + 3] = alfa;
scan[i*4] = 255;
scan[i*4 + 1] = 255;
scan[i*4 + 2] = 255;
}
}
What I really should do is start over using the modular renderer as a base.