I’m editing the PreNormalPass to show normal include normalmap.
Technique PreNormalPass {
VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert
FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag
WorldParameters {
WorldViewProjectionMatrix
WorldViewMatrix
NormalMatrix
ViewProjectionMatrix
ViewMatrix
WorldMatrixInverseTranspose
}
Defines {
DIFFUSEMAP_ALPHA : DiffuseMap
HAS_NORMALMAP : NormalMap
NUM_BONES : NumberOfBones
INSTANCING : UseInstancing
}
}
Now I have a tangent space normal map. How to convert it to world space or view space?
Tangent Space <-> Model Space <-> World Space <-> View Space <-> Clip Space
I’ve read any article. How can I get TBN Matrix in jme?
http://www.txutxi.com/?p=316#
Look at JME’s lighting shader and you will see how it gets the TBN from the normal and tangent vertex attributes.
I found this. I’ll try it, thx!
Tangent.glsllib
mat3 Tangent_GetBasis(){
vec3 wvBinormal = cross(wvNormal, wvTangent);
return mat3(wvTangent, wvBinormal, wvNormal);
}
why do you have a tangent space normal map ?
nehon
June 8, 2016, 5:55pm
6
Most often that’s the case. The blueuish normal maps are in tangent space.
Sorry to necro but I just came across this struggling to do the exact same thing - I got the TBN matrix from the LightingShader, and my understanding is that this will convert from tangent space to model space.
So to go from that to viewspace
vec3 normal = vec3(normalColor.xyz) * tbnMat;
vec4 viewSpaceNormal = vec4(normalFromMap,0.0) * g_WorldViewMatrix;
I know I’ve done something wrong since I’m getting some messed up results. Is this bit wrong? Else I must be cocking up the TBN matrix bit.
EDIT: Oh shit I forgot about taking it from [0,1] to [-1,1] GG no more questions for now! All works