I have a question: Are tangents like in the following pictures okay / typical?
I used a textured Sphere with Polar projection and then TangentBinormalGenerator.genTbnLines(mesh, 0.108f)
to make the tangents (red), binormals (green), normals (blue).
The normals and binormals seem to look okay (they are normalized, obviously).
But the tangents look strange… ( I think - but don’t really know if it’s okay how they look )
So, for this I used a factor of 1.0 to calculate U,V coords (basically the same like the code in Sphere.java):
Note:
This is not the usual Sphere, but my HemiSphere. As you’ve already guessed, it can use a variable factor for the U,V. And as the name suggests, it builds “half spheres” and other fractions of a Sphere.
Happily waiting for comments from experienced gfx people now,
I will try these two things then:
a) reproduce it with Sphere.java - it’s a bug then - either in Sphere or in tangent generator.
b) use a different TextureMode (there are 3 for Sphere, I think) and compare the results.
Tested all three TextureMode settings, tested different radii too.
Did use sphere.scaleTextureCoordinates(new Vector2f(tScale, tScale)); where needed, to get the same u,v factors. Using that line of code “shortens” the tangent, inverse to the texture scale factors. So it’s the same like in my two pictures: uvFactor=1 => long tangent, uvFactor=150 => short tangent.
Using a unit-Sphere (radius = 1) gives correct tangents, as long as there is no texture-scaling or model-scaling.
When texture-scaling is used => see above (shorter tangents when u,v factor is 150).
When model-scaling the unit-Sphere => scaled normals, example: scale (x,y,z) = 10,10,10 and texture factors (u,v) = 1,1 => gives normals, tangents, binormals with length 10 world units when viewed in 3D scene.
Problems now:
I’m using a fairly old version of jME (3.0.10).
The TangentBinormalGenerator is currently being worked on by @nehon.
How to continue:
Will just ignore that for now.
Will do some more tests with other mesh types later.
Will look for an updated version of the tangent generator for jME 3.0 later and use that.
(If anyone knows a good update for the jME 3.0 tangent generator - please say so).
And another thought:
Might also be that TangentBinormalGenerator.genTbnLines does not work correctly?
(in that case, only my visual debugging tool is defect).
Note: 3.1 alpha 2 is up in the repos and we’re just waiting for jcenter to properly list some of the artifacts… but effectively 3.1 alpha 2 is ‘released’.
It’s probably a good idea to check this with a jME 3.1 version first.
Maybe I can backport the TangentBinormalGenerator in an easy way too.
But first, should really check if problem exists in all jME versions.
I guess I’m confused about why you would want to backport it. Maybe I’ve misunderstood why you are holding onto 3.0 so hard… I thought it was to have a common stable baseline for writing your tutorials but then a custom fork doesn’t make any sense at all.