Pages: [1]
  Print  
Author Topic: PowerVR PCX2 support (need shader pre-parsing help)  (Read 1118 times)
fromhell
Administrator
GET A LIFE!
**********

Cakes 12
Posts: 13802


WWW
« on: March 23, 2012, 08:40:34 am »

Here's a fun waste of time i've been having to get some obscure 1997 killed-by-3dfx card to work.  Grin

PCX1/2 have no blendFunc. It always blends everything as an alpha whether you like it or not.  To 'simulate' how a PCX2 behaves, just have this in GL_State
Code:
default:
dstFactor = GL_ONE; // to get warning to shut up
ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits\n" );
break;
}
                srcFactor = GL_SRC_ALPHA; dstFactor = GL_ONE_MINUS_SRC_ALPHA; } // for pvr debug only!

qglEnable( GL_BLEND );
qglBlendFunc( srcFactor, dstFactor );
}
else
{
qglDisable( GL_BLEND );
}
}

I'm currently hacking in a weird method to force control alpha channels on textures. However, this is difficult as shaders are read in sequence. Right now my current method is an 'alphahack' command like


Code:
thisisashader
{
     cull disable
        {
          //PCXHACK alphahack add // Generate alpha channel from averaging RGB
          map models/weapons2/thisisagun/bang.jpg
          blendFunc add
        }
}
         
For more compatibility i'd like to parse blendFunc add BEFORE THE TEXTURE GETS UPLOADED so I can tell the Upload32 function that this texture is used in a fashion where it is blended additively so it can generate an alpha channel for a card that doesn't support it. I actually already did the parts of generating/demoting alphas, etc by telling it with the alphahack command (where it would then be marked in a new field in texture_t, in the bundle, and be carried all the way to upload32). I just can't seem to do any shader pre-parsing to get a lot of the existing work cut out.

I'll post a diff later, as it's currently a mess. It also appears IoQ3 got rid of the whole GLHW_ detection and compatibility mode setting for some dumb reason, along with r_glDriver (which is necessary for pointing to minigl wrappers)


it's also possible that this work can lead to optimizing  the game for a "fast-and-dirty" software renderer, if there's anyone ever brave enough to make one. Doing these PCX2 hack fixes makes me want to do Mystique hack fixes (adjust alpha threshhold, GT0'ing everything) and Rage hack fixes (GT128ing everything, additiving a few alphas).

I have a lot of faith in getting this card to work good. I've compared performance of Angelyss's highest LOD (13fps) to OA3's Sorceress' highest LOD (31fps), at 1024x768x16 with r_drawworld 0 so the future is certainly looking bright for performance.
« Last Edit: March 23, 2012, 09:32:37 am by fromhell » Logged

The above post may not be approved by Gig therefore it must be completely disregarded.  "Design by committee" defines the status quo.
andrewj
Member


Cakes 23
Posts: 489



« Reply #1 on: March 23, 2012, 10:42:42 pm »

For more compatibility i'd like to parse blendFunc add BEFORE THE TEXTURE GETS UPLOADED

I think the easiest way to do that is : give ParseStage() an extra parameter 'load_images', and call ParseStage twice on the same text (first time with load_images as false, second time as true).

Then in ParseStage code, handle the "map" (etc) commands normally but don't call R_FindImageFile() unless load_images is true.  At that time you will know the blendfunc (due to previous call to ParseStage) and can pass extra info to R_FindImageFile.
Logged
fromhell
Administrator
GET A LIFE!
**********

Cakes 12
Posts: 13802


WWW
« Reply #2 on: March 27, 2012, 04:53:25 pm »

Did your suggestion but it seemed to have broke every shader instead. I couldn't read the console even.

I'll try doing it as a copy of the ParseStage function with the actual token parsing all replaced by SkipWholeLines until it hits Blendfunc then it can set the alphahack flag in that stage bundle
Logged

The above post may not be approved by Gig therefore it must be completely disregarded.  "Design by committee" defines the status quo.
Pages: [1]
  Print  
 
Jump to: