Hello,
I would like to add bump mapping in an old code (if possible).
A polygon is created in a display list using glutess.
This code is added in the display list for automatic texture coordinates calculation :
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, s_vector);
glTexGenfv(GL_T, GL_OBJECT_PLANE, t_vector);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
Then to draw :
- bind the texture
- call the display list
- A simple shader retrieves the pixel color with a sampler2D texture2D(TextureID, texCoord)
Is it possible to add a normal map image in the same way with automatic calculation ?
I saw that GL_NORMAL_MAP exists. So maybe something like that :
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
Is there something automatic in opengl ? (without manually computing and storing tangent space)
Thanks