Jump to content
  • Advertisement
Sign in to follow this  
51mon

Map viewer direction to RGBA value?

This topic is 3912 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

I want to map a XYZ viewing direction to a specific RGBA value. So far the only ways I have come to think of is to use environment mapping. Unfortunately you can't wrap the textures in environment mapping successfully (right?). The RGBA distribution has to be some kind of noise but with quite lose restrictions. I was looking into Perlin noise but it seemed to costly (computationally). Does anybody know of some other ideas? Thanks

Share this post


Link to post
Share on other sites
Advertisement
The probably easiest way to map some 3D vector to a 1D/2D/3D/4D value is a cubemap.

You can write (or paint) whatever values you want into the cubemap, and a simple texture fetch (textureCube(cubeMap, yourVector) in GLSL) will map this to a value that corresponds to the "viewing direction" of the input vector. This works really well. In the old days, when texture was faster than ALU, cubemap lookups were for example used to normalize vectors.

I'm not sure what exactly "some kind of noise but with quite loose restrictions" means, but for the cubemap it really doesn't matter so much, you can use what you want, any noise generated in Photoshop, Gimp, or elsewhere. You can also do several lookups and sum up / average the results, or anything.

Share this post


Link to post
Share on other sites
Quote:
Original post by samoth
The probably easiest way to map some 3D vector to a 1D/2D/3D/4D value is a cubemap.

You can write (or paint) whatever values you want into the cubemap, and a simple texture fetch (textureCube(cubeMap, yourVector) in GLSL) will map this to a value that corresponds to the "viewing direction" of the input vector. This works really well. In the old days, when texture was faster than ALU, cubemap lookups were for example used to normalize vectors.

I'm not sure what exactly "some kind of noise but with quite loose restrictions" means, but for the cubemap it really doesn't matter so much, you can use what you want, any noise generated in Photoshop, Gimp, or elsewhere. You can also do several lookups and sum up / average the results, or anything.


Thats exactly what I'm doing now :) I was just checking if there were some good alternative ideas around. The ability to wrap the textures would have been nice. I haven't determine the exact distribution/pattern of the RGBA-values but I imagine some kind of noise will do fine.

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!