Inside3D!
     

Color 255 for transparency on models and brush entities?

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming
View previous topic :: View next topic  
Author Message
MDave



Joined: 17 Dec 2007
Posts: 75

PostPosted: Wed Jun 11, 2008 6:09 pm    Post subject: Color 255 for transparency on models and brush entities? Reply with quote

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 Smile

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 Smile
Back to top
View user's profile Send private message
scar3crow
Inside3D Staff


Joined: 18 Jan 2005
Posts: 837
Location: Las Vegas, NV

PostPosted: Wed Jun 11, 2008 6:11 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
mh



Joined: 12 Jan 2008
Posts: 910

PostPosted: Wed Jun 11, 2008 8:43 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
MDave



Joined: 17 Dec 2007
Posts: 75

PostPosted: Wed Jun 11, 2008 10:05 pm    Post subject: Reply with quote

Thanks for the tips! However, its still not working Sad

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
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 910

PostPosted: Wed Jun 11, 2008 10:21 pm    Post subject: Reply with quote

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:
Code:
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).
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
MDave



Joined: 17 Dec 2007
Posts: 75

PostPosted: Wed Jun 11, 2008 11:07 pm    Post subject: Reply with quote

Thanks, that did it!

Here's my result Smile



Now I'll do what you suggested, use glBlendFunc to make the muzzle flash (and possibly the edges of the palm tree leaves) smoother Smile
Back to top
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 910

PostPosted: Thu Jun 12, 2008 10:06 pm    Post subject: Reply with quote

Looking good! Very Happy
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Fri Jun 13, 2008 7:34 am    Post subject: Reply with quote

Cool to see the result after getting help in action, I'd like to see more of that on these forums Smile
_________________
Look out for Twigboy
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group