开始学习GLSL
2010-02-26 17:01
176 查看
There are three types of inputs and outputs in a shader: uniforms, attributes and varyings.
Uniforms are values which do not change during a rendering, for example the light position or the light color. Uniforms are available in vertex and fragment shaders. Uniforms are read-only.
Attributes are only available in vertex shader and they are input values which change every vertex, for example the vertex position or normals. Attributes are read-only.
Varyings are used for passing data from a vertex shader to a fragment shader. Varyings are (perspective correct) interpolated across the primitive. Varyings are read-only in fragment shader but are read- and writeable in vertex shader (but be careful, reading a varying type before writing to it will return an undefined value). If you want to use varyings you have to declare the same varying in your vertex shader and in your fragment shader.
All uniform, attribute and varying types HAVE to be global. You are not allowed to specify a uniform/attribute/varying type in a function or a void.
Uniforms are values which do not change during a rendering, for example the light position or the light color. Uniforms are available in vertex and fragment shaders. Uniforms are read-only.
Attributes are only available in vertex shader and they are input values which change every vertex, for example the vertex position or normals. Attributes are read-only.
Varyings are used for passing data from a vertex shader to a fragment shader. Varyings are (perspective correct) interpolated across the primitive. Varyings are read-only in fragment shader but are read- and writeable in vertex shader (but be careful, reading a varying type before writing to it will return an undefined value). If you want to use varyings you have to declare the same varying in your vertex shader and in your fragment shader.
All uniform, attribute and varying types HAVE to be global. You are not allowed to specify a uniform/attribute/varying type in a function or a void.
相关文章推荐
- 开始学习 Backbone
- 开始写学习笔记啦。。。。
- 为什么要开始学习设计模式
- 开始学习软件
- 开始学习编程
- 2008年7月22号,晴,天气又开始有些热了。学习时的苦痛是暂时的,未学到的痛苦是终生的-------哈佛自习墙
- 从0开始学习 GitHub 系列之「06.团队合作利器 Branch」
- 从AlexNet开始(二):利用AlexNet结构学习tensorflow
- iOS 8 Metal Swift教程 :开始学习
- [学习笔记]开始学directx了之一
- 开始记录我的学习历程
- [翻译]NDK之一:开始学习NDK编程
- 遗传算法与直接搜索工具箱学习笔记 四-----从直接搜索算法开始
- 从0开始学习 GitHub 系列之「06.团队合作利器 Branch」
- 开始C的学习,从基础做起。
- 开始学习Uboot
- 开始学习存储,从EMC开始。
- 第三章 Getting Started with the Zookeeper API(开始学习Zookeeper API)【上】
- 五一过后,不再观望,开始学习,加入我们吧
- 学习从历史开始