How do I read a CubeMap on CPU side? (Or how the GPU texCube function read a pixel from a CubeMap),
Members - Reputation: 121
Posted 14 April 2012 - 07:37 AM
I need to extract the one pixel from a CubeMap (I already have the 6 textures extracted) using the normal vector. How can I achieve this ?
I want something very similar to what texCUBE(link) does in GPU but in CPU.
I am using XNA and C#, but an example in any language may help.
Creator and Developer
Team Blog: http://ploobs.com.br
Members - Reputation: 467
Posted 14 April 2012 - 09:27 AM
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.