glsl 的reflect(I,N)其中I是 眼睛(camera)位置到顶点位置的方向向量,N为顶点法线,必须要归一化

橙宝书里给出的计算过程是这样的:reflect(I,N) = I - 2 *dot(I,N)*N

vec3 reflect(const vec3 &i, const vec3 &n)
{
return i - 2.0f * dot(n, i) * n;
}

OpenGL cubeMap-LMLPHP

OpenGL cubeMap-LMLPHP

//cubeMap
glGenTextures(1, &m_TexID);

glBindTexture(GL_TEXTURE_CUBE_MAP, m_TexID);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_GENERATE_MIPMAP, GL_TRUE);

//-x
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X , 0, GL_RGBA8, NegX.getWidth(), NegX.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NegX.getData());
//x
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X , 0, GL_RGBA8, PosX.getWidth(), PosX.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, PosX.getData());
//y
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y , 0, GL_RGBA8, PosY.getWidth(), PosY.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, PosY.getData());
//-y
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y , 0, GL_RGBA8, NegY.getWidth(), NegY.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NegY.getData());
//z
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z , 0, GL_RGBA8, PosZ.getWidth(), PosZ.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, PosZ.getData());
//-z
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z , 0, GL_RGBA8, NegZ.getWidth(), NegZ.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NegZ.getData());

glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

Texture targetOrientation
GL_TEXTURE_CUBE_MAP_POSITIVE_XRight
GL_TEXTURE_CUBE_MAP_NEGATIVE_XLeft
GL_TEXTURE_CUBE_MAP_POSITIVE_YTop
GL_TEXTURE_CUBE_MAP_NEGATIVE_YBottom
GL_TEXTURE_CUBE_MAP_POSITIVE_ZBack
GL_TEXTURE_CUBE_MAP_NEGATIVE_ZFront

//----------------------------------------------------暂且记下,回去再写

OpenGL cubeMap-LMLPHP

OpenGL cubeMap-LMLPHP

05-11 11:29