我在GLSL中制作每像素照明着色器.图为一个立方体网格,根据它们绘制的顺序,应该被遮盖的边在其他边上呈现.当我切换到我的固定功能opengl照明设置时,这不是问题.是什么导致它,我该如何解决?
顶点着色器:
varying vec4 ecPos;
varying vec3 normal;
void main()
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
/* first transform the normal into eye space and normalize the result */
normal = normalize(gl_NormalMatrix * gl_Normal);
/* compute the vertex position in camera space. */
ecPos = gl_ModelViewMatrix * gl_Vertex;
gl_Position = ftransform();
}
Run Code Online (Sandbox Code Playgroud)
片段着色器:
varying vec4 ecPos;
varying vec3 normal;
uniform sampler2D tex;
uniform vec2 resolution;
void main()
{
vec3 n,halfV,lightDir;
float NdotL,NdotHV;
vec4 color = gl_LightModel.ambient;
vec4 texC = …Run Code Online (Sandbox Code Playgroud)