跳到主要内容
← Advanced Rendering

Advanced Rendering

Ins and outs

shader-learning 自学第 1 课:Ins and outs

实时渲染 · 网格 GLSL

第 1 课:Ins and outs

实现

uniform mat4 modelMatrix;
uniform mat4 viewMatrix;
uniform mat4 projectionMatrix;

in vec3 position;
in vec3 normal;
in vec4 color;

out vec3 vNormal;
out vec4 vColor;

void main() {
  vColor = color;
  vNormal = mat3(transpose(inverse(modelMatrix))) * normal;
  gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0);
}