# The Industry's Foundation for High Performance Graphics

1. ## Cube Map Question

I am having a problem understanding how you pass a vector into a cubemap. Right now i am looking over the CubeMap slide from nvidia's site and I am trying to understand the Normalization CubeMap. How do you pass information into a Cubemap?

- Lurking

2. ## Re: Cube Map Question

A cube map is just 6 texture maps each of which represent one side of the cube's faces.

Imagine you're in the center of a unit cube. Given a unit vector, you could "cast a ray" to one side of a face and look up the value of that texel. That's all a cubemap is. It allows you to look up (x,y,z) in one of 6 textures. A normalization cube map takes any (x,y,z) and returns the normalized version of that. When trying to interpolate a normal across a triangle it usually becomes un-normalized. Using a cubemap allows you to renormalize this vector with a simple texture map lookup.

3. ## Re: Cube Map Question

Im sorry about how novice this may sound but how do you use the texture to look up the position of my light source?

- Lurking

4. ## Re: Cube Map Question

Im sorry about how novice this may sound but how do you use the texture to look up the position of my light source?
You can't. Why would you need to use a texture for that? Your light position is stored into a float array in your C code, so you always have access to it.

When you create the normal cubemap just bind it to a texture unit and when you pass your vector as tex coords using glTexCoord or whatever opengl makes it work just fine.

-SirKnight

5. ## Re: Cube Map Question

SirKnight -
Actually you can use a cubemap to look up lighting information. It's pretty straight forward to encode diffuse lights into a cubemap. You can then get as many lights as you want for just one cubemap lookup.

Lurking -
You need to render your lights into 6 textures and then use your normal as the parameter into glTexCoord. You can then disable GL_LIGHTING. You'd also need to update the cubemaps if your lights move.

6. ## Re: Cube Map Question

Yes I know you can store diffuse and specular info in a texture, thats very easy to do, and with a nice fragment program this data can be accessed easily, but he asked for finding the _position_ of the light in a texture. You don't encode light source _positions_ in textures, they just aren't usefull for that.

-SirKnight

7. ## Re: Cube Map Question

Well I plan on using nvparse (which i am very new too) to work w/ my per pixel lighting. So that is why i dont understand how to look up where the position of my light source is.

- Lurking

8. ## Re: Cube Map Question

Lurking,

You need to specify where your light is as an INPUT to the cube map look-up. Ways of doing this include:
- pre-calculating light position and send it in with TexCoord3f()
- using TexGen() in NORMAL_MAP (for diffuse) and REFLECTION_MAP (for specular) mode and rotating texture coordinates using the texture coordinate matrix
- doing it all in a vertex shader

9. ## Re: Cube Map Question

Is there away around using the vertex shader?

- Lurking

10. ## Re: Cube Map Question

Ok now I see what you want. I didn't understand what you meant before. What you need to do is calculate the surface to light vector then pass that as tex coords into a texture unit with a normalization cubemap bound to it. Make sure and transform the light into the correct space first. So the surface to light vector is just: surfToLight = Light - Vertex; Then just pass that into a tex unit like i said above, then its ready to go in the combiners. There are many demos of this around. Check out the Lit Quad demo in the nvidia OpenGL SDK.

-SirKnight

[This message has been edited by SirKnight (edited 07-30-2002).]

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•