1.每个Vertex Shader都有用户定义的输入属性,例如:位置,法线向量和纹理坐标等.Vertex Shaders也接收一致变量(uniform variables). uniform variables:一个只读的全局变量是为所有的顶点绘制调用 2.除了用户定义的输入变量,GLSL为每个Vertex定义了一组输入属性(内置变量), in int gl_VertexID; in int gl_InstanceID; gl_VertexID:当前被处理的顶点的索引.它是当前顶点在数组中的索引
内置变量都在UnityShaderVariables.cginc文件中声明 变换矩阵 All these matrices arefloat4x4 type. Name Value UNITY_MATRIX_MVP Current model * view * projection matrix. 从object space转到 projection space UNITY_MATRIX_MV Current model * view matrix. 从object space转到camera
Unity provides a handful of builtin values for your shaders: things like current object's transformation matrices, time etc. Unity为你在编写shader是提供了少量的内置变量:类似 当前物体的变换矩阵,时间等. You just use them in ShaderLab like you'd use any other property, the only diff