View Full Version : applying decals onto a surface
05-08-2002, 11:23 PM
A while back I posted asking for advice on
how to apply decals over a textured quad.
I was getting z buffer problems ( the decal was sometimes in front of the texture and sometimes behind it ). One solution I was offered, was to use the stencil buffer.
I tried this, but the games frame rate dropped drastically.
My program is a little odd, in that my meshes are all inside display lists. I want to draw the mesh first and then apply the decal afterwards. ( The decal shows the allegiance of a spaceship ).
Has anyone see a simple demo of how to do this?
05-09-2002, 01:18 AM
This should work if the implementation is to spec but you might have to try bigger values than this or vary the values from card to card. Some people have been delinquent on this issue causing recurring problems with this functionality.
Ultimately if it still doesn't work then you could try using frustum near and far plane adjustments (push them out a bit when drawing the decals) and draw all the decals last to fix this.
If this glPolygonOffset method doesn't work then it is indesputably the OpenGL implementation from the manufacturer that is at fault.
I think I suggested using the stencil buffer in your previous topic. How much of a performance drop are you experiencing ? Just out of curiousity, what hardware are you using ? On GeForce's and Radeon's it should be relatively cheap ( a lot of people think that stencil operations are expensive, probably due to it being used for shadow volumes ).
The options you have are, (1) polygon offset, (2) stencil buffer, (3) projective textures. There are possibly other methods.
For your particular case, projective textures is probably are good choice - you do have to render your geometry twice or use multitexture. Polygon offset is most likely the fastest of the three. If you really want it to work, then you could try the same values that Quake3 uses.
05-09-2002, 02:29 AM
The performance is dropping from 30 fps down about 2fps.
My hardware is an intel 82 series chipset,
onboard compaq one...( crap! )....
I would like the game to run decently on all machines...so stenciling may be out.
Projective textures sound interesting...
Out of curiosity...what values DOES quake 3 use for polygon offset?
Ok, it seems that your graphics card doesn't support stencil operations in hardware.
I don't remember the values that Quake3 uses ( they are specified using r_offsetfactor and r_offsetunits ). I did a search and it seems the default values are -1 and -2 respectively.
05-09-2002, 03:09 AM
Stencil on the newer cards is realtively a free operation. With shadow volumes the fill rate I found is almost the same. You end up writing to stencil instead of the framebuffer/zbuffer. It is a little bit faster but only if you card does really nice hardware stencil. My TNT2 Ultra has some slow downs because of its stencil support. But in my case I know the slow down is from the significant extra geometry from the shadow volumes. Lack of Hardware T&L kills me.
I really need to get a new card specifically for my Modelling needs. I figured on getting a geforce 4 but now I think I might wait out the extra 6 months for the new cards. It kills me since I don't want to spend the money but I would like a new card so I can keep on working on new effects. But at the same time the TNT2Ultra has no problem playing the current games. Quake3 and CounterStrike all run fine. Sure I'm not at 1280x1024 but I'm not at 640x480 either. 800x600 for q3 and 1024x768 for CS. And of course having a nice 19 inch Sony Trinitron means my desktop is 1600x1200 which looks great. I could get a new card but I really technically don't need a new one. My biggest problem, I need to build an entirely new dual processor workstation. So money is currently going towards that.
05-09-2002, 01:15 PM
One minor addition, the offset for polygon values can be positive or negative depending on whether you are pushing away the underlying surface or pulling the decal towards you.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.