0

不知道这叫什么,但是当从远处查看我的模型时,看起来照明没有应用到某些边缘,这使得它们脱颖而出。有任何想法吗?我没有使用任何纹理。

顶点着色器:

attribute vec3 aPosition;
attribute vec3 aNormal;

uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
uniform mat4 uNormalMatrix;

varying vec3 vLighting;

void main(void) {
  vec3 ambientLight = vec3(0.2, 0.2, 0.2);
  vec3 directionalLight = vec3(1.0, 0.5, 0.5);
  vec3 directionalLightDirection = vec3(0.8, 0.7, 0.6);

  vec4 transformedNormal = uNormalMatrix * vec4(aNormal, 1.0);
  float directional = max(dot(transformedNormal.xyz, directionalLightDirection), 0.0);
  vLighting = ambientLight + (directionalLight * directional);

  gl_Position = uPMatrix * uMVMatrix * vec4(aPosition / 80.0, 1.0);
}

片段着色器:

precision mediump float;

varying vec3 vLighting;

void main(void) {
  vec4 skin = vec4(0.8, 0.6, 0.4, 1.0);
  gl_FragColor = vec4(skin.rgb * vLighting, skin.a);
}

图片:

问题 放大

4

0 回答 0