Is Three.js Normal Map Shader Computing Lighting In Tangent Space? -


i trying familiarized three.js , came across strange can't quite wrap head around.

in other systems, (non web based), i've used, lighting normal maps calculated in tangent space. in three.js things bit different. example, if consider code in webglshaders.js @ line 2643:

"mat3 tsb = mat3( normalize( vtangent ), normalize( vbinormal ), normalize( vnormal ) );", "vec3 finalnormal = tsb * normaltex;", 

they set orthonormal basis matrix tangent space, , transform normal space. far good.

the issue is... seems place transform vectors tangent space???

so light direction vector calculate not converted tangent space, , neither eye direction vector??? both of subsequently used calculate lighting on lines 2692-2694:

"vec3 pointhalfvector = normalize( pointvector + viewposition );",  "float pointdotnormalhalf = max( dot( normal, pointhalfvector ), 0.0 );",  "float pointspecularweight = speculartex.r * max( pow( pointdotnormalhalf, ushininess ), 0.0 );", 

this different method of calculating specular i'm accustomed to. wondering if there out there able explain doing? i'd have idea how shader works can translate unity settings when outputting three.js. that's ultimate goal.

no. lighting calculation being done in camera space.

the tsb matrix, should named tbn matrix, transforms normal tangent space camera space.

you can see yourself: if normalmap flat, normaltex ( 0, 0, 1 ), , when transform tbn matrix, normalized vnormal result.

three.js r.59


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -