2
\$\begingroup\$

I currently have one texture on a gluSphere that represents the Earth being displayed perfectly, but having trouble figuring out how to implement a bumpmap as well. The bumpmap resides in "res/planet/earth/earthbump1k.jpg".Here is the code I have for the regular texture:

    gl.glTranslatef(xPath, 0, yPath + zPos);
    gl.glColor3f(1.0f, 1.0f, 1.0f); // base color for earth

    earthGluSphere = glu.gluNewQuadric();

    colorTexture.enable(); // enable texture
    colorTexture.bind(); // bind texture

    // draw sphere...
    glu.gluDeleteQuadric(earthGluSphere);
    colorTexture.disable();

// texturing 
public void loadPlanetTexture(GL2 gl)
{
    InputStream colorMap = null;

    try
    {
        colorMap = new FileInputStream("res/planet/earth/earthmap1k.jpg");
        TextureData data = TextureIO.newTextureData(colorMap, false, null);
        colorTexture = TextureIO.newTexture(data);
        colorTexture.getImageTexCoords();
        colorTexture.setTexParameteri(GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
        colorTexture.setTexParameteri(GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
        colorMap.close();
    }
    catch(IOException e)
    {
        e.printStackTrace();
        System.exit(1);
    }
    // Set material properties 
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);

    colorTexture.setTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S);
    colorTexture.setTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T); 
}

How would I add the bumpmap as well to the same gluSphere?

\$\endgroup\$
1
  • \$\begingroup\$ Hi, you should avoid legacy OpenGL \$\endgroup\$
    – elect
    Aug 13 '15 at 12:03
2
\$\begingroup\$

For widely used tangent-space normal mapping you'll need to generate tangent-space transform for the sphere and do the lighting calculation in glsl. You can bind the normal map texture into a different texture unit by using glActiveTexture().

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .