Can you set your socks node not have z-fighting with the character foot node, always render “on top” of it? (note: the vertices are in the exact same pos, not slightly away).
I actually saw something like this in the API docs yesterday: http://www.panda3d.org/reference/devel/python/classpanda3d.core.DecalEffect.php
If you have two Geoms that are Z-fighting, and you know a priori that one of them belongs on top (like a road texture on the ground), you can set that one to a “Decal”. Haven’t used it myself - let me know if it works for you.
I’m not sure how that works: the node becomes a “decal” for what node? Any other node? What if you have 3 nodes and each one must always be rendered “in front” of the other?
There was something like that in the egg syntax doc. I think you can have a geom as a base for decal, but I think only one…but don’t quote me on that I’m writing from memory and never tested that.
You could toy with depth offset, but that works only from time to time and with one layer.
The realy best thing is to ‘push’ all the verts along the normals a bit away -in your model editor.
The DecalEffect won’t work here. It’s a kind of Z buffer voodoo that’s only fit for a specific purpose – avoiding z fighting of two coplanar planes. On any more complex models it will result in elements being visible through each other.
This, however, will work and is usually used for this kind of fixes: panda3d.org/reference/1.8.0/ … Attrib.php
IIRC, It will simply push the offset node’s triangles above the ones behind it in camera space. Even the smallest offset should do the trick.
Actually, my whole decal system is built around depth offset and I’ve never had any trouble with it, even if I stack multiple layers of offset nodes. You just need to remember to offset every subsequent layer a bit more than the previous one and that having too high offset will make stuff visible through other stuff when it’s not supposed to be so.
It might be a graphics card or driver thing, but AFAIK depth offset is very widely used in games these days.
While this could work, it’s not a magic bullet either. Viewing the models from far enough away you will eventually hit a spot where z fighting reappears. Z buffer’s non linearity will always result in artifacts once you’re far enough. And if you manually and statically offset it enough to make z fighting go away, the “push” itself will in turn become visible when up close.
Amazing. I had been offsetting my road mesh above the terrain to avoid Z-fighting, with predictable results - the gap was visible up close and you could still see Z-fighting at long distances. Now here I have the road mesh exactly coplanar with the terrain, but the road has a DepthOffsetAttribute applied like so:
road_node=render.attachNewNode(loadEggData(city.road_mesh)) road_node.setAttrib(DepthOffsetAttrib.make(1)) floor_node=render.attachNewNode(loadEggData(city.floor_mesh))
…and it never even twitches.
- Should I have values between 0 and 16? I want to set my leg to render behind the sock, so can I apply this attrib to it and set it to -1, and not apply one on any other node (including the sock)?
- The API ref says some drivers don’t support this very well. Can you guys give more info? What will happen if the user’s driver doesn’t support it. Will it simply not get applied, or can it make things look worse (screw up the render)?
You should rather set the depth offset on the sock. A value of 1 should suffice, but it’s always best to experiment.
I would think that only applies to older cards and such. As I said, depth offset is really widely used. Unity uses it, Unreal Engine 3 and Wolfire’s Overgrowth both base their decals on it. I really wouldn’t expect any problems, as long as you don’t target exotic or legacy hardware, and even if something won’t work, it’s really unlikely it would explode.
OK, not a problem, but what if you have all sorts of clothing, not just socks? Wouldn’t seem elegant to apply it on all of them, if you could just apply it on the body (base mesh).
If you have all kinds of clothing then you probably have layers. If you have layers, then you would need to offset each layer separately, or you will have z fighting between layers.
No. Each clothing egg is for a different region of the body. All I need to make sure is that the body doesn’t have z-fighting with anything else.
Ah, so maybe a value of -1 on the body will work. I’m just not sure if that’s supported, but it should be very easy to test.