我不确定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);
让我知道我哪里出错了。
答案 0 :(得分:3)
和GL_NEAREST用于缩小和放大过滤。
你正在使用点抽样;你明确地询问每个纹素之间的接缝。所以没有什么是无缝的。
无缝立方体贴图就是在立方体的面之间进行过滤。你根本没有做过滤,所以你没有使用无缝的立方体贴图。