• Create Account

### #Actualmrhyperpenguin

Posted 14 April 2012 - 09:28 AM

The largest component of the normal vector tells you which face it intersects. Next divide the normal vector by the absolute value of the largest component. Then scale and shit the other two components into the usual range for uvs ([0, 1] on each axis).

For example if you had the vector <-3, -1, 2>.

First it intersects the negative x face. Then

<-3, -1, 2> / |-3| = <-1, -1/3, 2/3>.

Finally just scale the remaining two components from [-1, 1] to [0, 1], <-1/3, 2/3> * 0.5 + 0.5 = <2/3, 5/6>. And similarly for each other face.

Victor

### #1mrhyperpenguin

Posted 14 April 2012 - 09:27 AM

The largest component of the normal vector tells you which face it intersects. Next divide the normal vector by the absolute value of the largest component. Then scale and shit the other two components into the usual range for uvs ([0, 1] on each axis).

For example if you had the vector <-3, -1, 2>.

First it intersects the negative x face. Then

<-3, -1, 2> / |-3| = <1, -1/3, 2/3>.

Finally just scale the remaining two components from [-1, 1] to [0, 1], <-1/3, 2/3> * 0.5 + 0.5 = <2/3, 5/6>. And similarly for each other face.

Victor

PARTNERS