渲染管道(2)几何阶段二“顶点着色器”

1. 顶点着色器 (Vertex Shader)

可编程。

输入是单个顶点(以及属性), 输出的是经过变换后的顶点。
在这里插入图片描述
1.1 两个主要的任务

  • 计算顶点的位置(vertex position)MVP变换的模型变换和视图变换,将每个顶点在虚拟空间中的 3D 位置转换为它出现在屏幕上的 2D 坐标(以及 Z 缓冲区的深度值)

  • 可以操纵法线、位置、颜色和纹理坐标、光照信息等属性,提供所有程序员想要的顶点输出数据(vertex output data)

1.2 特性

  • 不能添加或删除顶点。
  • 顶点的处理是相对独立的,顶点之间的联系是未知的。

1.3

A Vertex Shader must have as input the vertex position (in object space). This is a Varying (it varies from vertex to vertex) as well as all the other vertex–specific attributes. All the others inputs are called Uniforms and they are constant for all the vertices processed by a specific shader. The varying Outputs of a Vertex Shader are forwarded throughout the pipeline.

猜你喜欢

转载自blog.csdn.net/thefist11cc/article/details/124114422