# Shader Setup

  • Create Shader(Vertex and Fragment)
  • Compile Shader
  • Attach shader to progrqam
  • Link Program
  • Use Program

# Vertex Shader

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
attribute vec3 aVertexPosition;
attribute vec3 aNormalPosition;
attribute vec2 aTextureCoord;

uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;

varying highp vec2 vTextureCoord;
varying highp vec3 vFragPos;
varying highp vec3 vNormal;

void main(void){
vFragPos = aVertexPosition;
vNormal = aNormalPosition;

gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aVertexPosition,1.0);

vTextureCoord = aTextureCoord;
}

attribute 只会在 vertex Shader 中出现 uniform 自定义 varying 插值的都需要 varying 比如上面给 varying 的赋值,最终都插值成功

# Rendering Equation

更新于

请我喝[茶]~( ̄▽ ̄)~*

Solvarg 微信支付

微信支付

Solvarg 支付宝

支付宝

Solvarg 贝宝

贝宝