#Compute tangents + bitangents for cube?

10 messages · Page 1 of 1 (latest)

pale wave
#

I'm trying to convert tangents and bitangents / binormals for a cube. Does bufferGeometry.computeTangents() work for a cube? And is there a trivial way to compute the bitangent n the vertex shader given normal and tangent, or do I need to do that in javascript?

I'm trying to make a parallax mapping shader, and it's not rendering properly, so I'm first trying to figure out if I'm generating tangents correctly, and then figure out bitangents

pale wave
pale wave
#

Also I was under the impression tangents are a vector3, but threejs generates them as a vector4?

pale wave
#

here is the tangets helper for the cube - do these look right?

pale wave
#

I've confirmed those tangents are right (they point in the positive u direction of the uv map). I'm trying to figure out of my bitangents are wrong, and/or if my camera position is wrong

random cove
#

There is a very straightforward way of computing the bitangent, yes — just take the cross product of the tangent with the normal. (May or may not need to be the other way around, I don't know which way it's defined here).

pale wave
#

cross(tangent, normal); or vice versa? edit: Ah nvm it's the same question you had lol

pale wave
#

This tutorial calculates the view vector with vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );

Is this the same or different than the camera position in the scene? I'm also passing in the camera position as a uniform and trying to figure out if this is meaningfully different

pale wave
pale wave