Iron Perth
Registered User
Join date: 9 Mar 2005
Posts: 802
|
10-22-2006 15:09
Hi anyone,
Can you post the math behind planar textures? I am trying to figure out a formula for the horizontal and vertical shift based on the position of the prim, but it seems dependent on the particular face the texture is on (and the shape of the prim). Any hints would be appreciated.
Cheers,
Iron.
_____________________
http://ironperth.com - Games for SecondLife and more.
|
Liana Linden
Linden Lab Employee
Join date: 23 Jan 2006
Posts: 23
|
10-23-2006 12:03
Interesting question. I've asked one of our developers to reply.
|
Runitai Linden
Linden Lab Employee
Join date: 29 Aug 2005
Posts: 52
|
10-23-2006 12:44
The gist of it is:
For each vertex, given: B - binormal T - tangent N - normal P - position in prim space
The resulting texture coordinate <u,v> is:
u = B dot P v = T dot P
For curved surfaces, since the normal, tangent, and binormal aren't constant, distortion occurs. Also, there is some fuzzy math that keeps the texture from being flipped by changing the sign of the binormal. Once the planar projection is complete, the usual texture transforms are applied (repeats and offsets).
|