Proper method for hair with alpha transparency?

Started by
6 comments, last by JoeJ 3 years, 1 month ago

I am trying to achieve hair like this, in Unity. It is just a plane with a texture, and has alpha blending. It's pretty common in PS2 games.

However, if I attempt to use alpha blending in Unity or Blender, the result is always something like this. There is a problem with sorting, and the texture erases itself, or displays in the wrong order, etc. (this is not a matter of backface culling, or double sided, either.)

When asking about this, the response is always that this is a “common problem in 3d”, and yet no answer is really given on how it's actually solved. Yet, given how common it was in PS2 games, surely it is a problem that has been solved multiple times.

So, what modeling practices do I need to adopt in order to make the effect work, and what do I need to do in engine? How is this problem normally solved?

Advertisement

Kiiryu said:
There is a problem with sorting, and the texture erases itself, or displays in the wrong order, etc.

Try to render opaque geometry in first pass, then turn z-write off but keep depth testing on, render sorted alpha geometry in 2nd pass.

Still artifacts, but that's the way you look for i guess.

@JoeJ What kind of artifacts?

Works well for convex shapes, but if geometry has multiple overlaps (curly hair), sorting can become too inaccurate.

For example if the bangs had a fold:

The hair mesh has to be cut onto multiple pieces, so every ‘depth layer’ becomes its own mesh. Likely 3 parts in that example.

But if you view the model from the side or certain angles, it still can fail again.

It's no big problem in practice. Because the z write is off the artifact goes mostly unnoticed. Pretty sure the PS2 games you have in mind did just that. The artists are aware and cut stuff accordingly.

IDK how to do this in Unity. If it really is necessary to generate multiple meshes, or multiple materials, just tags per triangle, etc.
And i hope i remember all this correctly.

Oh, i remember it also makes sense to set sorting order manually in some cases. If there are 2 layers of hair - an inner and an outer layer, you want to render the inner layer first. Likely the manual order causes less failures than sorting, but both can be combined as well.

After you figure out how to render it, it becomes clear and intuitive to fix pretty quickly with some trial and error.

@JoeJ I don't know that it would be possible this way, since if there are a lot of blades of hair, they are overlapping all over the place.

they are overlapping all over the place.

It's usually fine as long as they don't cross each other.

Creating a hairstyle layout is the same time-consuming process as creating a real hairstyle. I've been a hairdresser for years and I know a lot about hair. If you read the article on the https://lovehairstyles.com/how-to-curl-short-hair/, you will learn 7 ways to curl short hair. I think girls will be interested in this information.

Никто

This topic is closed to new replies.

Advertisement