Low Poy Hair Transparency, Alpha and Alpha Sort

I am trying to make some low poly hair with planes for a game and always get flickering textures. The final result should be comparable to Final Fantasy XIII or XIII. Now I am not sure is this a general shading problem, a problem with game engine or a modeling problem. The textures have no flicker when using ‘alpha clip’ but look bad because of the missing antialiasing.
Using ‘alpha sort’ the textures show up in the wrong way and are vanishing and appearing instantly depending on the view angle. I noticed that the more intense the alpha is set the more flicker will happen. I 've made a demo file with using GLSL just press P to see what i mean.[ATTACH]293477[/ATTACH]

Is this a problem of the way the hair is made and are there better solutions or at least a solution?

Try this: combine all you hair meshes into a single object, set the alpha mode to alpha blend. Alpha sort is the slowest option and probably only of use with windows and such, when objects and polygons intersect or are close together blend works better.

(and don’t use subdivision modifiers in games they defeat the purpose of low poly models)

2048x2048 textures for hair?!

Try to aim for max 1024x1024 for textures, as they get bigger they will slow down loading scenes and drain the rasterizer a lot. 512x512 or 256x256 is better if you are having separate textures for each body part as you seem to want. 2048x2048 is not 8 times bigger than 256x256, it’s actually 64 times bigger!

It’s best to work with something similar to what you will eventually be using, as if you start with very high res textures and then have to scale them down to get them to work in game, you may be disappointed with the result. So maybe start with 256x256 and try and get something that looks nice with that.

Blender can do a lot of things but it will fall down if you try to do too much. As you add enemies, scenes, weapons, user interface, doors, special effects, vehicles etc… the game engine will ahve to work harder and harder to keep up a good framerate. It may seem to handle rendering the hair fine now, but what about when there are 4 or 10 characters ons creen at once, with all their gear and background and all the other stuff needed for a full game? You shouldn’t try to show every single hair unless your game is going to feature full face portraits of the characters for most of the time (for example if your characters are spending a lot of time talking in cut scenes and their faces take up like 80% of the screen). Blender render can do quite nice hair if that’s your thing, but for a blender game, perfect beautiful hair is a low priority.

I’ve experimented with alpha hair and trees and other things in the past. When using single texture it’s possible to use a script to better angle the normals to point outwards to get a nicer effect, but as far as I know that is already done with GLSL so you don’t have to /can’t do it, which is sad because sometimes you don’t want optimized normals, but you want them to do something else, but can’t because it’s kind of hard coded in. You also can’t do it with characters because they are rigged and rigged characters co-op some of the mesh code for animations making it impossible to do things like re-angle normals or scroll UVs.

Alpha clip does work, though it doesn’t look as beautiful as a next gen game with sorted anti-aliased alpha. You can try alpha clip with more clumpy hair, where most of the space between hairs is not invisible, but only at the tips of each clump is there invisibility.
Here’s some hair I did for my very low poly characters, it’s not that great looking (definitely not next genㅋㅋㅋ) but it does look OK in game as my characters are pretty small (about 5cm tall on screen at full zoom).

BTW the texture sheet that contains all these heads is 256x256 including hair, so while they might not look amazing, they do run well in the game engine.

Thank you for the quick reply.

About the high resolution: I sarted with smaller images, but for testing the look I increased until this size. However I really don’t see the difference between ‘blend alpha’ and ‘sort alpha’. The framerate does not matter right now. The main problem still is the ficker between the plains. It seems that with ‘alpha sort’ the closer faces sometimes are drawn behind too.

It would be nice if i could make the front and backface shading similar because backfaces show up very dark especially when near full opaque faces.

However it would be great if I could use alpha clip but before the final result is rendered an alpha blend value is added on the transparent parts to create an antialiasing effect (I would use nodes for that but i think because it is alrady declared in the material what kind of alpha is drawn that does not work) or maybe if I could add a reference object (like an empty) to make sure which object is rendered in front (or something like that).

I know other game engines may have the same problems, but: How they solve it?
If you still have some ideas about it let me know.

Edit: I’ ve tried the single mesh and blend thing. It seems to work better. Thank you!

When i have a two sided object I don’t usually turn off backface culling, instead i duplicate the faces I want to be double sided and flip their normals, it gives much better lighting. I think something similar is already in newer builds of Blender though.

After testing with a single mesh and ‘alpha blend’ i am pritty happy with the result, but it seems that opaque objects create something like an edge that alpha front faces don’t paint over.

In other words: The front faces are shown in the correct way only where the opaque object is, where the obect is not they become overlayed by the hair that is shown backface even if the alpha of the image is full opaque at that position. That looks a bit strange.

Edit: This problem seems to be solved with backface culling. The problem is: Backfaces are needed. A second mesh with inverted normals does not help. I wonder if it would be possible to use backface culling for the priority the alpha meshes are displayed instead of completely net rendering them. Is there a way of having acess using srcipt for this?

Its been some time while developing my game. Still I am getting porblems with the hair shading. I come to the conclusion that the way alpha textures are shadedand displayed are bugged. It looks like shaded areas become displayed more opaque than the faces that are in front of them getting full light. With alpha blend (and all other display methodes climp excluded) however lighted areas never seem to get full opaque so the bals head underneath is always visible. Now i wonder is there a way to get help on that? Will there ever be some change or developtment on it. I would like to script it myself if needet too, but unfortunately I am just a bit in python and i guess this wont help. Well at least it would be a help if there was a totorial site how to develope on blenders game engine, I think I’ll find a way to learn C++ if needed. However it may be OpenGL code… in this case. What is needed to develope this then.

Hello. I’d like to chime in my thoughts on this.

I think in most games, they paint on a base layer of hair on the mesh underneath the actual strands, so no matter what, the character looks like they have hair. They might also go with a “shell” that’s underneath all of the strands, but over the character’s head.

I don’t think they usually make the entire hairstyle up out of planes like this, though they do in some level. Also, if you look at characters like Lightning from FFXIII, which you referenced, her hair is a lot more opaque than the strands that you have (which are somewhat opaque, but also have gaps in them. Also, your strands have a very high color contrast). In FFXIII, the hair strands seem to get transparent toward the “bottom” of the strand, but the actual body of the hair is pretty opaque and single-colored, with some light differences in the coloring of the hair textures.

According to Eurogamer’s tech analysis, there’s four levels of detail for Lightning’s model, and two of them actually look like they’re using Clip Alpha for the strands (in-game and realtime cutscene). You can see it when it comes to the really pixelly and ugly edges of the strands themselves; I’m guessing it doesn’t show up in-game that much because you never get that close (except for cutscenes), the textures are large enough resolution to not be a big deal, and your character’s moving fast anyway, so it’s harder to notice. The transparent look appears in the pre-rendered and wholly CG cutscenes.

There’s also other hair modeling looks that look pretty good. For example, in this guy’s model (warning, loud music and slow pan up for some reason), the hair itself is pretty opaque, and just the trailing edges are alpha-enabled. This gives a solid look to it that seems much harder to implement going with pure plane layers. If you added plane layers to the hair of that model, you would end up with what I think games like FFXIII come up with - a base hairstyle that’s pretty much opaque, and then strands that are partially transparent over it.

These are just some thoughts, though - not much to do with your actual last issue.

As for the issue you propose, I haven’t personally noticed it, and I don’t see it in your example - it seems like the dark and light parts of the hair are evenly opaque or transparent, according to the texture. To my knowledge Alpha Blend mode works completely correctly in terms of displaying partially transparent textures.

If you do choose to looking into it, you’d have to use / learn some C++ and possibly some OpenGL. Check out #bgecoders and #blendercoders on freenode if you want some help or ask questions.

EDIT: Although, I think making a good case example that shows the issue might be a good idea, and making a finished character with obviously messed up hair might be a better idea. No use spending time trying to fix an issue that might not even be there or is easily passable.

EDIT 2: Oh, and are you sure that your texture’s fully opaque where it should be? It’s not like the texture’s alpha channel is set to 95% max or anything like that, right?

First: Thank you for your quick answer and knowledge. (it is no sarcasm i really like the answer)

I was testing a lot of other hairstyles and settings, though some looked quite ok for a game where character walk around not in direct close up. But still I see the problem. Wall clipping works well and there would be no problem if 100% opaque pixels would be drawn that way, yes actually i am sure. Actually I remember changes of the render when restating the game engine not even changing something.

Standalone Player results are often different too. Not only when using Alpha, but when using bones or animations (seems like animation data is not updating the same way like in the blender some things just need to be re-updated on every frame with pulse trigger in standalone that don’t need to in blender internal)

Actually it is no commercial project, at least right now. But I think I’ll give it a try to improve those things. If the render is supposed to be like it is it should result in a new option for blending, however I still think that there is something wrong with the alpha calculation. It seems like the alpha channel is used like a standard color with the same shading or shadow calculation instead of weighting it with the drawn opaqueness of the the image pixel. This only seems to happen with multiple layers though, maybe the drawn alpha is added not clamped or something like that. I just want to give a solution if possible. Maybe i can fix at least something else, well it may be possible that i can’t do anything too because i am too stupid for that :frowning: I’ll just give it a try. If someone else finds a solution or wants to do I still would encourage that person, because I don’t know if there will be an outcome if I do. But again I’ll try.

I still hope that the game engine or whatever it becomes next will be developed more. Blender for android, some improvements for light sources in blender game engine and maybe some sound creation making abilities like psycles would be really cool too. There is so much stuff that blender could do, it is the only program I know that could become a real multifunction all all in one developing tool, in some way it already is. In my opinion this is one of the biggest advantages of blender. I hope that this interaction mode will be something like an game engine. But I don’t find any real hints about it. Well I am getting a bit off topic now.

Well thank you again I’ll have look on it.

Alpha has been pretty much untouched in Blender for some time now. Alpha sort doesn’t seem to have an effect on alpha aside from introducing artifacts, and add mode broke somewhere along the line. For things like hair I’ve learned to just use very high resolution textures with clip alpha, it eats texture memory but it’s the only way to have alpha in the BGE without severe artifacts (particularly that weird draw-through-underlying-surfaces effect that alpha sometimes causes) and sorting issues.

Of course if I can’t be bothered to learn programming and try to fix it myself, I can hardly expect anyone else to do that.