Shader Programs
控制顶点和像素如何着色的代码——我们管它叫Shader。比如顶点着色器,我们只写对于顶点如何着色,而不用遍历每个顶点。
- Program vertex and fragment processing stages
- Describe operation on a single vertex (or fragment)
一个像素着色器的例子(OpenGL)
- Shader function executes once per fragment.
- Outputs color of surface at the current fragment’s screen sample position.
- This shader performs a texture lookup to obtain the surface’s material color at this point, then performs a diffuse lighting calculation.
至此已经可以去学习一些OpenGL的内容了,实际上只用写出物体如何摆放,光照方向等。例如前面介绍的矩阵运算,OpenGL都有API可以调用,不用你自己算。
在这里介绍一个网站:Snail Shader Program
可以在网页上写Shader,马上就能看到结果。
这个上面的蜗牛全部是几何形体映射出来的,没有三角形在上面。这个蜗牛例子也是个超级高端的例子,很牛。