PDA

View Full Version : Help with rendering hair? Alpha sorting?



KennyW
11-21-2013, 07:30 PM
1185

I want to render hair in my program, however the transparency of each hair strand is overlapping the others. I'm not sure on which kind blending/alpha testing technique to use. I currently using:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

but the result I get is above, the hair is 1 mesh containing many triangulated planes with a transparent texture. I've already tried some methods like transparency sorting shown in http://www.opengl.org/wiki/Transparency_Sorting

and also other parameters for glBlendFunc() didn't seem to yield any desired results.

How should I go about this?

Osbios
11-22-2013, 11:44 AM
To me it looks like you still have depth test on.

KennyW
11-22-2013, 02:35 PM
To me it looks like you still have depth test on.

It seemed to do the trick but I have a new problem. Since I have the actual head drawn before the hair and with depth testing ON, the hair will overlap the head since its drawn with depth testing OFF

1186

The hair will also be drawn over any of the other opaque objects too.

Osbios
11-22-2013, 03:05 PM
In that case you draw the non alpha blending geometry. Then only disable depth writing with glDepthMask and draw the alpha blending geometry.

KennyW
11-24-2013, 07:04 PM
awesome thanks