Terrain Engine Query: Built-in Grass vertex normals

Been mucking around with the built-in terrain engine and found this comment about appdata_full for grass quads:

// Grass: appdata_full usage
// color - .xyz = color, .w = wave scale
// normal - normal
// tangent.xy - billboard extrusion
// texcoord - UV coords
// texcoord1 - 2nd UV coords

Though it says normal = normal, unfortunately this normal is not the normal of the grass quad, it is the normal of the terrain! This is neat, but not terribly useful for me. Is there any way that you guys can give the quad the proper normal vector (perpendicular to the quad’s face) so that I can determine the orientation of the quad within the shader and have normal-mapped grass?

This would also help me create a great bending affect (I want to twist the top vertices of the grass before bending them, so they bend perpendicular to the view direction). I just need some information about the orientation of the quad!

Thank you.

Well, the normals being the same as the terrain normals is the only way you can have them lit properly. If you had the normals of the actual quad, you would get some very different light per quad, depending on the direction they are facing. But… you could do some stuff to be able to normal map the quads. Normally the binormal (which is used to make the rotation matrix for getting vectors into tangent space) is contructed by the cross product of the normal and the tangent. If you want the actual normal of the quad, just take the cross product of the tangent and this “wrong” normal, and flip it. Though I have no idea if the tangent is “special” as well.

But you would need to change the normal way of reading normal maps to fit this different approach. And it would still take some special implementing magic to make it look good and nice across quads pointing all these different directions. Something where the basic light is still calculated using the terrain normal, and then some additional lightning is added on top for normal mapped details.

You’re absolutely right about how the light application would have to go, but sadly the tangent is “special” as well I believe it’s just empty zeroes… does that still count as special? Seems more like useless, to me.)

Would love to hear about this from the Unity devs and find out how to change the quad itself.