我正在尝试阅读本教程:
https://aerotwist.com/tutorials/an-introduction-to-shaders-part-2/
但我无法跟进。基本上,代码使用直接在GPU上运行的着色器创建定向光。这是代码:
// same name and type as VS
varying vec3 vNormal;
void main() {
// calc the dot product and clamp
// 0 -> 1 rather than -1 -> 1
vec3 light = vec3(0.5,0.2,1.0);
// ensure it's normalized
light = normalize(light);
// calculate the dot product of
// the light to the vertex normal
float dProd = max(0.0, dot(vNormal, light));
// feed into our frag colour
gl_FragColor = vec4(dProd, dProd, dProd, 1.0);
}
Run Code Online (Sandbox Code Playgroud)
具体来说,我不明白的这一行是:
float dProd = max(0.0, …Run Code Online (Sandbox Code Playgroud)