I looked into it… and something is definitely wrong…
I’m not sure what though…
I never have any issues with my models but I guesd the simplest models helpf to reveal issues…
I’m going to dig into that and see what the problem is.
Sigh… I guess this Mikettspace tangent space looks like an option…
You know I’m not a math guy right? you know how much I suffer every time I dive into this crazy tangent generation thing …
well stop screwing it up =P
Nice to have you back James
Guys once I’m done translating this C code to Java… I’ll have to kill someone… for good mesure…
I’m more than happy to throw @erlend_sh under the bus for this one, he is always bitching about wanting to contribute more to the project …
Soooooooooo…
I’ve made some progress…somehow.
I translated the c code to java… and… after some tweaks, it runs without blowing up…
But it doesn’t work…
Left is the regular tangent generator, You can see some weird lighting effects on the sides facing left.
Right iss the MikkTSpaceGenerator…and you can see artifact pretty much everywhere…
Of course I must have messed up something, and I’m getting to the point that I’m going to try to understand what it does…
I’ll keep you updated.
Maybe it’s not the tangent generator but the normal map shader?
But that would be strange, wouldn’t it?
I can help little…as I see…there seemed to be regular Y channel flipped normal map problem (that is only one problem I see from my artists side sorry I cant help more but to give inverted normal map )
Maybe it will help, try to invert Y(G) channel
Isn’t something with the comment found in lighting.frag?
//Note the -2.0 and -1.0. **We invert the green channel of the normal map,**
//as it's complient with normal maps generated with blender.
//see http://hub.jmonkeyengine.org/forum/topic/parallax-mapping-fundamental-bug/#post-256898
//for more explanation.
Thanks guys but it’s not that issue. I tried both and It looks similar but it’s not that.
I made some progress… but I’m a bit confused. I created a C code that use the mikktspace.c as is, and I managed to generate the tangents in C.
The first thing I noticed is that the tangents values are VERY close to the ones generated by JME’s TangentBinormalGenerator.
Here are some screenshot :
Standard generator
MikkTSpace tangents:
As you can see the result is slightly better… but still obviously wrong…
There might be another issue…
EDIT : The standard Generator warns about the angle between some tangents that exceed seom threshold (defulat is 45 degres). Maybe I should duplicate those vertices.
Made some progress, The MikkTspace generator now works in its java version. But still generates not completely accurate tangents…
I tried to split the rotated tangents whit the current generator and it worst…
There must be something else…
Any chance to use your fix in 3.0?
I’m using TangentBinormalGenerator (a fixed one) but sometimes I have similar issues.
I’ll commit my change to master, there are 3 stand alone files, so you 'll be able to pick then and use them in a 3.0 project.
Though note that it won’t solve all issues as it is now. I’m still looking into it.
What do you mean by “a fixed one”? If you made some fixes on the generator I’d be glad to see them.
You made recently some changes into 3.1 TangentBinormalGenerator, I don’t remember when it was. I took the whole class and I use it in 3.0.
EDIT: I have a good memory: Fixed a big bug in TangentBinormalGenerator - #3 by nehon
oh alright. Yeah this bug was introduced by the previous change actually.
ok, so that will be pretty much the same process with the MikkTSpaceGenerator
By the way.
I’ve checked in blender, and Blender MikkTSpace seems to work exactly like your implementation
So this artefacts are “lesser of two evils”, and I believe this black strokes appear because hirez triangulation, look closer, I pointed with arrows.
Also, I recommend to use normal maps from Blender Internal, they seem to be more correct and clean. From far there is no real visual difference between BI and Hirez
If you need, here is BI normal maps:
- Blender internal old map
- Blender Internal new map (I did some spliting in hirez model, and issue with black strokes in front faces gone)
Cool thanks.
I want to try something else though… for now we approximate the bitangent (aka binormal) with a cross product of the normal and the computed tangent. But sometimes the real bitangent is not perpendicular to the tangent (though always perpendicular to the normal. usually this approx is ok, but I want to try tu use the bitangent computed by the mikktspace.
I’ll have to modify the shader though.
Some parts of the normal map have high frequency noise / ridges. Are those actually mapped in the mesh? If so, it could cause the artifacts you’re seeing.