Hi all, did you know that one of the long awaited features on my wish list has finally been added?
Yes! Custom normals are now available in Blender.
Why is this good? Well now we can make good trees and alpha clipped hair in the blender game engine.
For my example I’m going to use a free low poly tree from this link:
There’s lots of trees there so why don’t you try them out yourself later. I have seen better trees elsewhere, but these are fine for our experiment.
Here’s a look at how the tree looks both before and after setting the custom normals:
There is a hemi light to the top right of the screen and a small red point light positioned between the trees. Notice how the corrected tree seems to be much more diffusely lit it looks like lots of individual leaves. While the original tree is obviously made up of flat planes of chunks of leaves.
How do you get this result?
You need to set Autosmoothing in the mesh tab of your object, and you will also require duplicate planes of the leaves, a single plane with backface culling unchecked won’t do the trick, you need one plane to show the front shading of the leaf group and one to show the back shading.
When you duplicate the planes, use cntrl F and “flip normals” This will flip the render normal of the face around so that it isn’t culled, this is different to the shading normal used for showing how light affects the plane.
Now you should add a modifier to the leaves object, it’s the new one : Normals edit.
Set it to radial. You can either use an empty to set the center of the sphere from which the normals will radiate, or you can recalculate the leaves object’s origin to match geometry. In any case, the normals should radiate outwards from the center of the leaves object.
You can apply the modifier, the changes are now permanent.
You can see a demo blend here:
better_tree.zip (570 KB)
What’s the purpose of this thread?
Firstly I want to bring to the community’s attention this great new feature. We need never suffer ugly trees or hair in the BGE again!
Secondly I want to see what kind of results others can get. Please post your own trees, or especially hair, I don’t have any good examples of alpha based hair on characters to show here.
An interesting thing about this feature is that it actually was possible in the BGE as far back as 2.49b (or earlier) but it required adding the object in blender and then running a script on it:
import bge cont = bge.logic.getCurrentController() own = cont.owner mesh = own.meshes length = mesh.getVertexArrayLength(0) for v in range( 0, length): vert = mesh.getVertex(0,v) norm = vert.getXYZ().copy() norm.normalize() vert.setNormal(norm)
Being able to set up the objects normals using a modifier makes things much easier, and also allows you to set custom normals on rigged characters or trees (though you can’t apply the modifier, it has to remain in the stack else normals will be reset to standard alignment when the game engine starts), something that wasn’t possible before (the script didn’t work at all on rigged meshes).