Sign in to follow this  
51mon

Map viewer direction to RGBA value?

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this