Ah, that artefact is called “shadow acne”, I believe. I think that I’ve seen a recent thread that involved it–let me see…
All right, based on what I’m seeing, this might result from the fact that shadow-casting is intended to use reversed back-face culling, but the state that we’re applying is overwriting that setting with the default back-face culling.
However, I also stumbled upon a potential solution: just as one can set the “initial state”, one can get it.
So, what happens when you try to first get the extant state from your light, apply that to the temporary node, set the depth-writing state on the temporary node, and finally apply the temporary node’s state to the light as a new “initial state”?
Something like this:
extantState = sun.node().getInitialState()
# (If the above doesn't work, perhaps try just "getState()" instead.)
tempNP = NodePath(PandaNode("temporary NP"))
# NB This next line!
tempNP.setState(extantState)
tempNP.setDepthWrite(True, 1)
sun.node().setInitialState(tempNP.getState())
It’s my pleasure. ![]()