Color 255 for transparency on models and brush entities?
Moderator: InsideQC Admins
8 posts
• Page 1 of 1
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
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
-

MDave - Posts: 76
- Joined: Mon Dec 17, 2007 7:08 pm
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:
Otherwise you'll have pink fringes around your opaque parts, which is just plain silly.
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: Select all
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.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
Thanks for the tips! However, its still not working
Am I setting it in the right place, in R_DrawAliasModel?
Am I setting it in the right place, in R_DrawAliasModel?
- Code: Select all
glEnable (GL_ALPHA_TEST);
R_SetupAliasFrame (currententity->frame, paliashdr);
glDisable (GL_ALPHA_TEST);
-

MDave - Posts: 76
- Joined: Mon Dec 17, 2007 7:08 pm
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:
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).
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: Select all
samples = alpha ? gl_alpha_format : gl_solid_format;
to this:
- Code: Select all
samples = GL_RGBA;
(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).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest

