Lighting material question

In hello material tutorial its written,

[java]TangentBinormalGenerator.generate(rock); // for lighting effect[/java]

But how exactly this causes lightning effect?

& how does the shininess works(Lighting.j3md), when we are not using any spec map?

As far as I understand, this is for Normal Mapping. If you have a normal map texture, so this is very useful (calculate tangents, binormals).

doesn’t normal map itself holds surface normal information? why it would need to have an extra normal information?

This is not for a texture. This is for a mesh. It applies to a mesh/Spatial. For vertex/polygons tangents, binormals calculations.

If you want your normal map looks correctly in your scene, so it would be better to apply this TangentBinormalGenerator to your mesh.

If your mesh does not have a normal map, so the TangentBinormalGenerator does not need.

I thought normal map(the normal texture) is enough for that. Why we need to perform on mesh level? What exactly the TangentBinormalGenerator is doing on the mesh.

Coredevs know exacly.

You can use normalmapped mesh without the TangentBinormalGenerator , but lighting of Normal Map could be wrong.

You need information about the normals of the model, they are stored inside the mesh. The tangent generator also generates the tangent info on the mesh.

You need to understand how normal mapping works :

it’s a map that represent the normal for each pixel. the tricky part is…in what space those normal are represented.

You can store normal in worldSpace for example, but if you have a dynamic object (that move or that is deformed in your scene), you would have to recompute all the normals from the normal map since the object world transforms changed.

To avoid this, normal informations in normal maps are stored in the tangent space.

There is one tangent space for each vertex of a mesh. And the handy part is that this space is constant if you move or deform the mesh.

a picture is better than words :

the normal axis is obvious, the tangent axis goes along the Y axis of the normal map (or the V if you look at it like a UV map) and the binormal goes along the X axis of the normal map (or U).

the normal map contains the normal in this space, but to be able to render it properly, we have to compute this space for each vertex and store it in the mesh.

That’s what the TangentBinormalGenerator does.

I spare you the details of the calculation because it a math nightmare based on the UVs of the mesh etc…

From a user point of view…all you have to know is that your normal mapped models will look wrong if you don’t generate the tangents with the generator.

1 Like
nehon said:
From a user point of view...all you have to know is that your normal mapped models will look wrong if you don't generate the tangents with the generator.

And on Macs, when I didn't have tangents the textures would show up as flat shaded in many cases. So "look wrong" is pretty serious in some cases.