I’m having issues when in my graph where a root node has a
DepthOffsetAttrib to limit the Z output range and a child node has a
DepthOffsetAttrib with a depth offset:
if I set on the root node
DepthOffsetAttrib.make(0, 0.5, 1) and on the child node
DepthOffsetAttrib.make(1), the net depth offset seems to be indeed 1, but the Z output range has been reset to [0, 1]. (According to the code in
depthOffsetAttrib.cxx, the offset is accumulated, the Z output range is from the “closest” attrib)
If I set the priority of the
DepthOffsetAttrib on the root node to 1, the child node does seem to have the correct Z output range [0.5, 1] but it’s own offset is ignored as it is part of an attrib with a lower priority.
If I’m not wrong, the problem is that two separate concepts share the same attrib object and so conflict ? If is that so, is there a workaround to use ?
Sample code to play with :
from panda3d.core import CardMaker, DepthOffsetAttrib from direct.showbase.ShowBase import ShowBase base = ShowBase() root = base.render.attach_new_node('root') root.set_attrib(DepthOffsetAttrib.make(0, 0.5, 1), 1) cm = CardMaker('card') card1 = root.attach_new_node(cm.generate()) card1.set_pos(-0.5, 3, -0.5) card2= root.attach_new_node(cm.generate()) card2.set_pos(-0.5, 3, -0.5) tex1 = loader.load_texture('maps/smiley.rgb') card1.set_texture(tex1) tex2 = loader.load_texture('maps/noise.rgb') card2.set_texture(tex2) card2.set_attrib(DepthOffsetAttrib.make(1)) base.run()