Bad Hair

Hello All.

I’ve been working on some simple hair consisting of multiple layers of geometry with a texture map applied. The layered geomery is all part of the same object. It kind of works but I am still getting what looks to be sorting artifacts that I can’t seem to get rid of.

darksim.com/w/bad_hair.png

hair = loader.loadModel(ANDY_HAIR)
hair.setPos(0.0, 0.0, 0.0)
hair.setScale(*GLOBAL_SCALE)
hair.reparentTo(self.model_pivot)

I have set things up this way.

hair.setDepthWrite(False)
hair.setAttrib(DepthTestAttrib.make(DepthTestAttrib.MLessEqual))
hair.setTransparency(TransparencyAttrib.MAlpha)
hair.setBin(‘fixed’, 0)

And have also tried it this way.

#hair.setTransparency(True)
#hair.setBin(‘fixed’, 0)
#hair.setDepthTest(True)
#hair.setDepthWrite(False)

I have also tried including alpha { ms }
in the egg file.

I’m missing something, just not sure what. Any help would be much appreciated.

http://www.panda3d.org/manual/index.php/Transparency_and_Blending there is a long part about depth-sorting in there. multisample should be the best option available.

Yes, I read through that, but enabling multiple-sample in the egg file does not seem to help. ms mode seems to threshold my texture transparency so that an alpha above a certain value is fully opaque and below fully transparent.

Upon rereading that section, I wondered if ms mode was falling back to M_binary for some reason. I changed my config to multisamples 16 and that fixes the thresholding. I still have those artifacts, unfortunately.

One thing I don’t understand is that when I make it double-sided (setTwoSided(True)) it looks worse…large portions of the outer layer of hair become transparent as if the polygons are single sided and the normal is facing the wrong way.

OK, figured out what the problem was. The hair geometry was created in Maya as a bunch of layered “plates” which were then then combined into a single piece of geometry. Somebody else is doing the modelling on this project and I don’t really know my way around Maya very well but, when I started separating the geometry and testing pieces, it worked.

So, if I “separate” the hair geometry, select all, and then export it from Maya it works. Now I just have the expected multi-layer transparency issues to deal with :slight_smile: