Jump to content
  • Advertisement
Sign in to follow this  
tpastor

How do I read a CubeMap on CPU side? (Or how the GPU texCube function read a pixel from a CubeMap)

This topic is 2283 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[color=#333333]
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 ?[color=#333333]
I want something very similar to what texCUBE(link) does in GPU but in CPU.[color=#333333]
I am using XNA and C#, but an example in any language may help.

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!