我不确定无缝 cubmap 是如何工作的。我所知道的是,使用此功能,在边缘处,两个边缘之间会出现平滑的颜色变化。
因此,我在每个面上渲染一个具有 8*8 纹理的立方体,并且在 glTexImage2D() 调用之前调用 glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS)。但是通过在上面添加 glEnable 调用,我看不到输出有任何差异。我期待立方体的边缘有平滑的颜色变化。我使用 GL_CLAMP_TO_EDGE 模式进行包装,使用 GL_NEAREST 进行缩小和放大过滤。
代码:
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);
让我知道我哪里出错了。