Jump to content
  • Advertisement
Sign in to follow this  
Aken H Bosch

OpenGL GL_NORMAL_MAP - Can't find documentation

This topic is 3275 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'm making an OpenGL app using just the fixed-function pipeline, and I noticed that one of the possible arguments for glTexGen (but OpenTK, so GL.TexGen instead) is GL_NORMAL_MAP (but really TextureGenMode.NormalMap)... It appears to be doing something, but I cannot find any documentation on it... The 'red book' page mentions GL_NORMAL_MAP as a valid option, but has no info on what it does. The only place I was able to find any info was an nVidia tutorial, which didn't go into much depth on it either, other than mentioning that the S/T/R texture coordinates are set to the eye-space vertex normals. However, this information does not appear to be quite accurate; it does indeed appear to be basing its result on the vertex normals, but +z in a cubemap appears to correspond to a mix of +z and -y in eye coordinates, and +y appears to be a mix of -z and +y... the +x and -x seem nearly correct, however. If anyone has any correct, detailed info on how the coordinates generated by this mode work, your help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Fixed-function is dead. No reason to spend any time learning it. Learning to implement normal mapping in a shader is far more useful

Share this post


Link to post
Share on other sites
I was able to determine that the coordinates are 45 degrees off from eye-coordinates, around the x axis, although why it's like that I have no idea.

I was ultimately able to get this working properly, and used it to produce this .gif turntable animation with combined ambient/diffuse lighting:



As for this...

Quote:
Original post by RDragon1
Fixed-function is dead. No reason to spend any time learning it. Learning to implement normal mapping in a shader is far more useful


...learning to actually address people's queries instead of telling them to completely overhaul their project is also useful.

Share this post


Link to post
Share on other sites
Without knowing more details, it behooves me to mention that 'neutral' on a normal map is 808080 -- that is, a normal of +z is 8080FF, not 0000FF. Similar for other axises. 0000FF would be [-1,-1,+1], which would be one of the corners ('45 degrees') of the normal space, not one of the edges.

...'course, given that you've gotten it working, chances are you probably already noticed whatever :P

Share this post


Link to post
Share on other sites
Actually, sorry - apparently this has nothing to do with normal mapping at all. AFAICT GL_NORMAL_MAP is used to generate texture coordinates based on the vertex normal, so that you can sample an environment map with it... Although... eye space normals? I'd think world space normals would be more useful

Is that right?

And sorry that you're building your app with ancient tech. Was just trying to push you in the direction of not wasting massive amounts of time fiddling with this stuff, because the knowledge isn't very useful, and I suspect it isn't a massive amount of work to change your app from using fixed function junk to shaders

Share this post


Link to post
Share on other sites
I think it is best to answer the question even if shaders are the norm these days.

Secondly, IMO, GL_NORMAL_MAP is not really useful. GL_REFLECTION_MAP is probably what you want if you want to give that reflective look and also, you need a cubemap for both GL_NORMAL_MAP and GL_REFLECTION_MAP

I have shown the math behind GL_REFLECTION_MAP but not GL_NORMAL_MAP since I am not sure for the normal_map
http://www.opengl.org/wiki/Mathematics_of_glTexGen

Share this post


Link to post
Share on other sites

Quote:
The only place I was able to find any info was an nVidia tutorial, which didn't go into much depth on it either, other than mentioning that the S/T/R texture coordinates are set to the eye-space vertex normals.


GL_NORMAL_MAP works like this. Say you have sphere and you want to draw a smiley face on it, and you want the smiley face to always point to the camera. GL_NORMAL_MAP may be for you. That's probably not what you want.

If you want reflection (and you probably do, it's the main reason anyone uses cubemaps) you should use GL_REFLECTION_MAP. Another rare reason to use cubemaps is in some cases you have an odd-shaped convex object where it might be easier to generate a surface with a cubemap, especially if the camera is inside the object; in which case GL_OBJECT_LINEAR might be appropriate.


Quote:
Without knowing more details, it behooves me to mention that 'neutral' on a normal map is 808080 -- that is, a normal of +z is 8080FF, not 0000FF. Similar for other axises. 0000FF would be [-1,-1,+1], which would be one of the corners ('45 degrees') of the normal space, not one of the edges.


He's not talking about a normal texture map, but automatic texture coordinate generation for vertices, which (unfortunately) involves a constant called GL_NORMAL_MAP. It causes OpenGL to "map" the normal vector for that vertex to the cube map texture coordinates.

Quote:
Fixed-function is dead. No reason to spend any time learning it. Learning to implement normal mapping in a shader is far more useful


RDragon1,

The best way to convince people to adopt new technology is to show that you have mastered the old technology (i.e., by answering the guy's question); that way it looks like you understand why the new technology is better and you speak from experience.

Share this post


Link to post
Share on other sites
Quote:
Original post by aerojockey
RDragon1,

The best way to convince people to adopt new technology is to show that you have mastered the old technology (i.e., by answering the guy's question); that way it looks like you understand why the new technology is better and you speak from experience.


Actually I disagree, at least in this case. It doesn't even matter if fixed-function is 'better', it's deprecated and most current hardware has already eliminated most of the hardware, plus the APIs are driving it out of existence.

Plus, I've only been a graphics programmer for about 2 years, I've never touched fixed-function stuff, and there's no reason I should ever learn how to use it

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!