小编eve*_*ing的帖子

GLSL - 如何避免多边形重叠?

我在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)

opengl lighting glsl

0
推荐指数
1
解决办法
587
查看次数

标签 统计

glsl ×1

lighting ×1

opengl ×1