Env Mapping - Txt Cords needed ?

Hello,

i tried to do some Enviroment Mapping, i loaded a .3ds Object that i have designed in 3d Max 5, also i defined the texture to be mapped like a sphere.

I do not fully understand if OpenGL needs the Txt Cords, or i have to remove them fully when setup a display-list when rendering EnvMapping ! Did someone knows this ? Actually i render under Java with LWJGL on a ATI 9700.

Thx,
Jens


The Network is the Music
www.mac-systems.de

envmapping being “dynamic” ie depending on object/viewer doesnt need fixed texcoords.

however you need to generate them on the fly using glTexGen(…)
The GL_ARB_texture_cube_map extension does have those.
Be aware so for complete environment mapping you would need to have 6 textures, that is one for each side of the “skybox”.

often spheremapping is used to kinda fake reflections and does come with standard GL.

Hi,

yes Spheremapping was what i wanted to setup first :slight_smile:

I have setup the Spheremapping , but well the Object looks in general good, but it seems that every second Tri looks distorted only when Spheremapping is on, if i render the object with Texture Cords from .3ds it looks fine, any suggestions ?

Drawing Code:

        GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
        GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
        GL11.glEnable(GL11.GL_AUTO_NORMAL);
        GL11.glEnable(GL11.GL_NORMALIZE);
        
        GL11.glDisable(GL11.GL_LIGHTING);


        GL11.glCallList(displayListIndex);

        GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
        GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
        GL11.glDisable(GL11.GL_AUTO_NORMAL);
        GL11.glDisable(GL11.GL_NORMALIZE);

Texture Generation Code:

   // Create A IntBuffer For Image Address In Memory
    IntBuffer buf = BufferUtils.createIntBuffer(1);

    GL11.glGenTextures(buf); // Create Texture In OpenGL

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
    // Typical Texture Generation Using Data From The Image

    // Linear Filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    // Linear Filteri
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    // Repeat the Texture S
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    // Repeat the Texture T
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);

    GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
    GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_SPHERE_MAP);
    GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_SPHERE_MAP);


    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tex.getWidth(), tex.getHeight(), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch);

thx,
Jens


The Network is the Music
www.mac-systems.de