Okay, I want to return to tangent space normal mapping but
I'll leave out the mathematics.
Many thanks to Re Berengario I and Suraknar for pointing out
tutorials on this and data cube normalization. Caliban has told
us that the 3 0 0 0 mystery block is vertex normals, 10 0 0 0
is tangents, and 11 0 0 0 are binormals. The vertex normals
are computed by averaging over the face normals by iterating
over the triangles, the tangents are computed by conditioning
the face tangents by the uv coords according to the formulas
in the refs in the previous posts, and the binormals can be obtained
from the cross products. The confusing part is mapping to RGB
values. Basically you take all the normalized vectors, add 1.0
and divide by 2.0 to map the components onto a [0,1] RGB float
space. You then multiply by 255 and truncate to map to a
byte-valued RGB space on [0,255]. This is called cube normalization
(learned at lunch time). This is the format of the mystery
data's block 1, 2, and 3 (along with a fourth byte that looks
like an unused albedo value).
Anyway, if you do this you can get the following .mesh to .ms3d
and .ms3d to .mesh conversion for the feudal_knights_lod0.mesh.
(I'm repeating bits of post #160 and I'll use thumbnails this time,
still learning the fine points here.)
First step: Convert mesh to ms3d and modify in Milkshape:
All I've done is broken the lances.

First try, zero out the mystery data:

Okay, you can see the Milkshape mod has shown up in the game but
the shadows on the lod0 rendered knights shows the mystery data isn't
being applied.
Finally, use the data cube normalization along with the vertex normals,
tangents, and binormals to compute the mystery data out of the
data pulled from the .ms3d file and put into the .mesh format to get

and there you have a forward and backward mesh conversion.
Slight but solvable problem: People might notice the lighting looks wrong.
That's because there's still an unresolved coordinate system problem.
Here's the vertex normals (in tangent space normal mapping) from
the original feudal_knights_lod0.mesh
(first ten of them anyway)
Code:
189 238 116 0
253 127 106 0
5 95 110 0
136 3 100 0
251 116 98 0
193 236 129 0
209 31 108 0
139 1 115 0
50 25 118 0
2 108 115 0
and here's my computed ones:
Code:
116 238 190 0
107 128 253 0
111 95 5 0
103 5 100 0
99 116 251 0
130 236 194 0
109 36 215 0
114 29 208 0
119 26 51 0
116 108 2 0
You can see that the x and z coords are reversed and that they
don't exactly match. Too tired to work this out tonight, I'll hit
it later. Must be a coordinate system thing.
Anyway, the mechanics of this are getting really clear now.
More stuff tomorrow.
Bookmarks