Re: R: [Plib-users] Transparent texture
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2000-06-16 19:01:01
|
Paolo Leoncini" <p.l...@ci...> wrote: > The easy explanation could be that all works ok, and I'm doing something > wrong... That's what I'm going with right now! > but the fact is that I don't set anything special for getting > trasparent textures, other than to supply the alpha-equipped [2/4 > compoments] texture. > The little step forward, that anyway doesn't solve the general problem, is > to set > > materials[...]->setAlphaClamp(0.5f) > > into the 3DS loader. This actually rises the threshold of the transparent > part with respect to the opaque, but I'm still in trouble with the full > [0:255] alpha range support in rgba/inta textures. I don't know offhand what the 3DS loader is doing with that field...however, transparency *certainly* works in SSG - I use it constantly in all sorts of applications. Here is the code I use to set up an ssgSimpleState in my latest project: /* Declare it... */ *gst = new ssgSimpleState ; /* I allocate a simple integer index to every State to make it easier for my collision detection code to tell me what kind of material we collided with. */ (*gst) -> setExternalPropertyIndex ( index ) ; /* Load up the texture...or not. */ if ( texture_map [ 0 ] != '\0' ) { (*gst) -> setTexture ( texture_map, !(clamp_tex & UCLAMP), !(clamp_tex & VCLAMP) ) ; (*gst) -> enable ( GL_TEXTURE_2D ) ; } else (*gst) -> disable ( GL_TEXTURE_2D ) ; /* Turn on lighting...or not */ if ( lighting ) (*gst) -> enable ( GL_LIGHTING ) ; else (*gst) -> disable ( GL_LIGHTING ) ; /* Set up some other things I use a lot */ (*gst) -> setShadeModel ( GL_SMOOTH ) ; (*gst) -> enable ( GL_COLOR_MATERIAL ) ; (*gst) -> enable ( GL_CULL_FACE ) ; (*gst) -> setColourMaterial ( GL_AMBIENT_AND_DIFFUSE ) ; (*gst) -> setMaterial ( GL_EMISSION, 0, 0, 0, 1 ) ; (*gst) -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ; (*gst) -> setShininess ( 0 ) ; /* Set up transparency...or not */ if ( transparency ) { (*gst) -> setTranslucent () ; (*gst) -> enable ( GL_ALPHA_TEST ) ; (*gst) -> setAlphaClamp ( alpha_ref ) ; /* 0..1 */ (*gst) -> enable ( GL_BLEND ) ; } else { (*gst) -> setOpaque () ; (*gst) -> disable ( GL_BLEND ) ; } I have noticed that my GeForce-256 card (running the nVidia OpenGL-for-Linux driver) seems to misbehave a little with some values of AlphaClamp. > Does anybody work with full alpha'ed textures for special effects in > plib/ssg-based games? Yes. > I read 3DS files for tests, so if anyone does it with > (secene data) in a different format, it could lead to understand that there > is some bad setting in the 3DS reader, so we could modify it... Well, I find that modellers in general do a very poor job of giving me the exact 'material' parameters that I need - so my applications generally load a table of material properties that I create by hand (either as a parsed ASCII file - or hard-coded into the application). As the model is loaded, I match up the texture map that was applied to the model to the texture map name in my application's material property table. The 'ssgSetAppStateCallback(getAppState)' callback does this. Hence, I don't care what the loader does with material properties...so there could easily be a bug. > Sorry for insisting on it, but I'm very disappointed (still loving plib, > anyway!) - Well, don't worry too much - it *does* work in the core of SSG - so either you are not setting it up right or the 3DS loader is broken. From your description, it seems like you probably don't have... ssgstate -> enable ( GL_BLEND ) ; ...set. If you don't have that then OpenGL will still compute alpha values - but it won't BLEND the new polygon into the background - it'll either be on or off - opaque or *nothing*. So, check that out - and if you are still getting nowhere, *someone* will need to take a look into the ssgState stuff in the 3DS loader. -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |