Uniform与proper
时间: 2023-12-10 17:04:53 浏览: 152
Uniform 和 Property 都是用于在着色器程序和外部程序之间进行数据传递的机制,但它们的使用方式和作用略有不同。
Uniform 是一种用于在顶点着色器和片元着色器之间传递数据的机制。Uniform 变量是全局变量,可以在着色器程序的任何位置访问。Uniform 变量通常用于传递一些全局的变量、纹理等信息,例如投影矩阵、光照信息等。在外部程序中,可以使用 glUniform 函数来设置 Uniform 变量的值。
Property 是一种用于在 Unity 中传递数据的机制。Property 变量通常用于在外部程序中设置 Shader 中的变量,例如设置材质的颜色、纹理等信息。在 Shader 中,使用 Properties 语句来声明 Property 变量,并使用 CGPROGRAM 和 ENDCG 语句来定义 Shader 程序。在外部程序中,可以使用 Material 类型的变量来设置 Shader 中的 Property 变量。
可以看出,Uniform 变量是一种用于在着色器程序间传递数据的机制,而 Property 变量则是一种用于在 Unity 中传递数据的机制。两者使用的场合和方式略有不同,但都是用于在着色器程序和外部程序之间进行数据传递的重要机制。
阅读全文
相关推荐














