View previous topic :: View next topic |
Author |
Message |
MDave

Joined: 17 Dec 2007 Posts: 75
|
Posted: Wed Jun 11, 2008 6:09 pm Post subject: Color 255 for transparency on models and brush entities? |
|
|
Is this possible? Reason why is so I can use effects like fences and ladders without using an obscene amount of triangles and verts. Also nice hair / muzzle flash effects
I've tried using glEnable (GL_ALPHA_TEST) and glDisable (GL_ALPHA_TEST) before and after rendering a model respectfully, but there is no change. Is there anything I'm forgetting?
Oh, I'm not using a super duper engine with support for all the formats that can use alpha transparency. Just looking for a simple method of doing it in good old glquake. Reason is so I can learn how the engine works easier  |
|
Back to top |
|
 |
scar3crow Inside3D Staff

Joined: 18 Jan 2005 Posts: 837 Location: Las Vegas, NV
|
Posted: Wed Jun 11, 2008 6:11 pm Post subject: |
|
|
Quote: | Also nice hair / muzzle flash effects |
What the hell kinda weapon you makin?!
All aside, no clue, I just wanted to say that. |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 910
|
Posted: Wed Jun 11, 2008 8:43 pm Post subject: |
|
|
Alpha test should do it... it's what's done for sprites, and the principle is the same... you might also need a glDepthMask before and after, though...
Couple of points to note, however:
* Alpha test will give you a hard edge, you might want to experiment with GL_BLEND for hair and muzzleflashes
* You'll probably also want to set colour 255 to 0 in VID_SetPalette; like so:
Code: | void VID_SetPalette (unsigned char *palette)
{
byte *pal;
unsigned r,g,b;
unsigned v;
unsigned short i;
unsigned *table;
// 8 8 8 encoding
pal = palette;
table = d_8to24table;
for (i = 0; i < 256; i++)
{
r = pal[0];
g = pal[1];
b = pal[2];
pal += 3;
v = (255 << 24) + (r << 0) + (g << 8) + (b << 16);
*table++ = v;
}
// 255 is transparent
d_8to24table[255] = 0;
} |
Otherwise you'll have pink fringes around your opaque parts, which is just plain silly. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
MDave

Joined: 17 Dec 2007 Posts: 75
|
Posted: Wed Jun 11, 2008 10:05 pm Post subject: |
|
|
Thanks for the tips! However, its still not working
Am I setting it in the right place, in R_DrawAliasModel?
Code: |
glEnable (GL_ALPHA_TEST);
R_SetupAliasFrame (currententity->frame, paliashdr);
glDisable (GL_ALPHA_TEST);
|
|
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 910
|
Posted: Wed Jun 11, 2008 10:21 pm Post subject: |
|
|
That looks correct, and I've just tested it out and got it working. The only additional code was setting some 255 texels in the skin.
I suspect your skins are being uploaded as GL_RGB, whereas you need to upload them as GL_RGBA. Look in GL_Upload32 and change this line:
Code: | samples = alpha ? gl_alpha_format : gl_solid_format; |
to this:
(There's no real advantage to uploading as GL_RGB on a modern card so you may as well get rid of the "samples" variable and hard-code GL_RGBA instead). _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
MDave

Joined: 17 Dec 2007 Posts: 75
|
Posted: Wed Jun 11, 2008 11:07 pm Post subject: |
|
|
Thanks, that did it!
Here's my result
Now I'll do what you suggested, use glBlendFunc to make the muzzle flash (and possibly the edges of the palm tree leaves) smoother  |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 910
|
|
Back to top |
|
 |
Urre

Joined: 05 Nov 2004 Posts: 1073 Location: Sweden
|
Posted: Fri Jun 13, 2008 7:34 am Post subject: |
|
|
Cool to see the result after getting help in action, I'd like to see more of that on these forums  _________________ Look out for Twigboy |
|
Back to top |
|
 |
|