DecalEffect

Can anyone please give me a quick example of how to use the DecalEffect properly?

First, you need to understand what the DecalEffect provides: it allows you to render two coplanar surfaces without Z-fighting. It uses fixed-function rendering techniques. It has nothing to do with decalled textures or with shader techniques.

That being said, you would use it like this:

wall = loader.loadModel('wall.egg')
decalObject = loader.loadModel('decal.egg')
geomNode = wall.find('**/+GeomNode')
decalObject.reparentTo(geomNode)
geomNode.setEffect(DecalEffect.make())

which is to say, you must parent the geometry to be decalled directly to the GeomNode that represents the wall, then apply the DecalEffect to the parent GeomNode. You must ensure that the decal geometry is, in fact, coplanar with the wall, and does not extend beyond the wall anywhere; and also that the wall does not self-occlude anywhere (it must be totally convex).

David

I’m just curious - how is DecalEffect better than using a depth offset? The latter seems much easier to use, to me.

It is.

Not all graphics drivers support setDepthOffset(). Very old ones, in particular, do not support it; or support it poorly. DecalEffect was designed to work on all hardware.

It’s probably not relevant to most casual Panda3D users. You’d have to be really hardcore about supporting the very bottom of the barrel (like Disney is) to want to go out of your way to use DecalEffect.

David

Ah, I see. Thanks for the explanation. :slight_smile:

Thanks David.