R: R: [Plib-users] Transparent texture
Brought to you by:
sjbaker
From: Paolo L. <p.l...@ci...> - 2000-06-19 16:01:38
|
Thanks, Steve, for the useful suggestions - I finally saw those semi-translucent textures in my database. What I did? these simple three things: 1. glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) so to not actually need alpha planes still getting roughly good blending; 2. mat->enable( GL_BLEND ) and mat->setAplhaClamp(0.01) the latter to get the full [0:255] alpha range; 3. switch for tests to a AccellGraphics GMX2000-equipped NT box (!!!!) instead of my G200 on NT, which soon switch to software with as few as 2.5Mtexels loaded and doesn't want to know about alpha-ed textures (latest driver, of course). Since I would like to rely on (3DS) modeller's information as much as possible, a further little work will focus on automatically set those properties for transparent textures (only the image loader knows about the 2/4-components) - the AppStateCallback seems once again the final resource. Furthermore one has also to "isolate" translucent objects from the rest of the database for rendering with z-buffer disabled after all other objects, for best blending results. Thanks again - ---------------------------------------------------------------------------- - Paolo Leoncini phone: +39 (0823) 623134 Scientific Visualization Group fax: +39 (0823) 623126 CIRA - Italian Center for Aerospace Researches p.l...@ci... Via Maiorise - 81043 Capua (CE) Italy www.cira.it/research/vis > -----Messaggio originale----- > Da: pli...@li... > [mailto:pli...@li...]Per conto di Steve Baker > Inviato: venerdì 16 giugno 2000 21.02 > A: pli...@li... > Oggetto: Re: R: [Plib-users] Transparent texture > > > 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) > > _______________________________________________ > plib-users mailing list > pli...@li... > http://lists.sourceforge.net/mailman/listinfo/plib-users > |