Search code examples
opengltexturesopengl-3

Regarding seamless cub map textures


I am not sure how seamless cubmap works. What i know is that with this feature, at the edges there is smooth color changes between two edges.

So, i am rendering a cube with 8*8 texture on each face and i am calling glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS) just before glTexImage2D() call. But i dont see any difference in the output by adding glEnable call above. I am expecting there is smooth color change a the edges of cube. I am using GL_CLAMP_TO_EDGE mode for wrapping and GL_NEAREST for minification and magnification filtering.

code:

    GLbyte subpix[]={0, 0, 0, 127,     127,127,127, 127,  127,0,127,127,  0,127,0,127, 0, 127, 127, 127,  127,127,127, 127,   0,0,0,127,  127,127,0,127, 127, 0, 0, 127,
                            0, 127, 127, 127,  127,127,127, 127,   0,0,0,127,  127,127,0,127, 0, 0, 0, 127,    127,127,127, 127,  127,0,0,127,  0,127,0,127, 127,127,0,127,
                            0, 0, 0, 127,    127,127,127, 127,  127,0,0,127,  0,127,0,127, 0, 0, 0, 127,     127,127,127, 127,  127,0,127,127, 56, 32, 54, 127,
                            0, 127, 127, 127,  127,127,127, 127,   127,0,0,127,  0,127,0,127, 127, 0, 0, 127,    0,127,127, 127,  0,0,0,127,  127,127,0,127, 54, 100, 12,127,
                            127, 0, 0, 127,    0,127,127, 127,  0,0,0,127,  127,127,0,127, 56, 32, 54, 127,  54, 100, 12,127,  123,54, 12, 127,  32, 127, 23, 127, 21, 90, 111,127,
                        0, 127, 127, 127,  127,127,0, 127,    127,0,0,127,  0,127,0,127,  127, 0, 0, 127,    0,127,127, 127 , 54, 100, 12,127, 56, 32, 54, 127
        };  

  *target11=GL_TEXTURE_CUBE_MAP;

        glGenTextures(1, &textureId);
        nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glGenTextures(1, &textureId);"));      


        glBindTexture(*target11, textureId);
        glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);

        for(int i=0;i<6;i++)
        {
        glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, GL_RGBA16_SNORM, 7 ,7, 0, GL_RGBA, GL_BYTE,subpix);
        nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexImage2D(types[i], 0, *format, 7 ,7, 0, GL_RGBA, GL_UNSIGNED_BYTE,pix31);"));
            }   

        glTexParameteri(*target11, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
        nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexParameteri(*target11, GL_TEXTURE_MIN_FILTER,GL_NEAREST);"));

         glTexParameteri(*target11, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
         nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexParameteri(*target11, GL_TEXTURE_MAG_FILTER, GL_NEAREST);"));

         glTexParameteri(*target11, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexParameteri(*target11, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);"));

    glTexParameteri(*target11, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
            nResult |= GL_ERROR_CHECK((GL_NO_ERROR, "glTexParameteri(*target11, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);"));
    glEnable(GL_DEPTH_TEST);

Let me know where i am going wrong.


Solution

  • and GL_NEAREST for minification and magnification filtering.

    You're using point sampling; you explicitly asked for seams between every texel. So there's nothing to make seamless.

    Seamless cubemapping is all about doing filtering between faces of the cube. You're not doing filtering at all, so you're not using seamless cubemapping.