Ioncannon
Ioncannon

Reputation: 951

OpenGl, Alpha blending on the same mesh

I am currently writing a model viewer for the game Final Fantasy XIV. I've run into an issue that I am trying to currently solve.

The hair models are all stored as a single mesh. Various layers are placed on top of each other to create a more realistic effect. Then an alpha is applied for the fine threads.

Now the issue I am running into is when I apply the alpha, it turns out like this:

Model

What's happening is instead of replacing/blending the fragment with the layer below, it is doing it with the clear color probably because there is nothing in the buffer at the time (it's a single mesh remember). How would I go about fixing this issue? Rendering it twice?

Upvotes: 1

Views: 911

Answers (1)

RollingShark
RollingShark

Reputation: 41

There are many thing that you can do, but not knowing the requirements I will just list a few:

  • OIT: order independent transparency, it requires a bit of setup and it's not easy to do and it has some costs http://en.wikipedia.org/wiki/Order-independent_transparency
  • don't use blending: I know that you probably thought of this, but what if instead of using blending you use alpha testing? Is the aliasing that bad? it's still and option
  • a little bit of both, alpha testing and blending. I would recommend this one and I'll quickly explain it below

What I would suggest is based on the AMD Hair Rendering paper available at:

http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Scheuermann_HairRendering.pdf

The paper explains the lighting model first, but then explains the technique used to render hair with alpha blending.

Upvotes: 1

Related Questions