PDA

View Full Version : Simple Per-Pixel Lighting Question?



Lurking
07-25-2002, 10:19 AM
Hello, I have been going over so great slides at the developers site at nvidia.com. I am learning how to use the nvparse tool to tweak the register combiners for perpixel lighting. I understand most if not all of the theory behind it but i am having a hard time understanding afew things.
=======================================
1. How do you get the normals from the normal map? I plan on using the photoshop plugin to get my normal maps. I dont quite understand how you get a normal from each texel from the map?
2. I am REALLY new to cube maps and just saw my first slide on them. How do you generate a cubemap? Is it just like a normal map but is a 3d texture?
=======================================
Thanks for reading. If you could help me out that would just make my day. Thanks again!

- Lurking

V-man
07-25-2002, 10:39 AM
Originally posted by Lurking:

1. How do you get the normals from the normal map? I plan on using the photoshop plugin to get my normal maps. I dont quite understand how you get a normal from each texel from the map?


The normal map stores the normals in it's color components. If you have RGB 888, then you have 8 bit for x, then y, then z. This is just a texture so you load them, and you can use the reg combiners to compute output color with it. There is also ARB_texture_env_combine which lets you do the same thing the ARB way.



Originally posted by Lurking:

2. I am REALLY new to cube maps and just saw my first slide on them. How do you generate a cubemap? Is it just like a normal map but is a 3d texture?


Its just another texture, not necessarely a normal map. For example, You can use it for environment mapping too.

It's not a 3D texture. It is more like 6 textures in one. There is a UP, DOWN, LEFT, RIGHT, FRONT, BACK and each is a 2D texture.

You generate them by loading.

glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X);
........
glEnable(GL_TEXTURE_CUBE_MAP);
For texture mapping with a cube map, I beleive you will need the r component as well, just like in 3D textures.
V-man

Lurking
07-25-2002, 11:10 AM
So, right now i am using this doc to understand per pixel lighting/bump mapping:
http://developer.nvidia.com/docs/IO/1273/ATT/BumpMappingWithRegisterCombiners.pdf

but i dont know how the cubemap knows were my light is in the world if the cubemap is just a texture. Right now i am using the DevIL tool for loading images. If you could help me agian to understand how the cubemap knows were my light (glLight*()) is that would help out alot! Kind of confusing i know!

- Lurking

Joel
07-25-2002, 12:58 PM
Originally posted by Lurking:
=======================================

2. I am REALLY new to cube maps and just saw my first slide on them. How do you generate a cubemap? Is it just like a normal map but is a 3d texture?
=======================================
- Lurking

As you have been told cube maps are in fact 6 textures. you can see it as a cube using a texture for each face. you access it with 3 tex coord that represents a direction.
If you want an example of how to build a cube map i suggest you to read glh_cube_map.h from the NVSDK.
This is how i learned http://www.opengl.org/discussion_boards/ubb/smile.gif
On the nvidia site you can also find a file called CubeMaps.pdf that explains quite well how they work. at least they explain better than I http://www.opengl.org/discussion_boards/ubb/wink.gif.

If you have trouble finding this files let me know.

Hope this helps.

Joel.

edit : didn't saw your last post. must be blind http://www.opengl.org/discussion_boards/ubb/smile.gif
cube maps are just used for normalizing (at least for per pixel lighting) your vertex to light vectors extrapolated. As they are extrapolated they aren't normalized thru all the triangle. that's where the cube map is used.
You can also use register combiners to normalize your vectors. I've read that's it's more efficient.
I'll code this when i'll find some time.

[This message has been edited by Joel (edited 07-25-2002).]

Lurking
07-25-2002, 01:47 PM
Thanks for your replies. I will work on getting this stuff down. Any additional help is still welcome but thanks alot!

- Lurking