GLSL Versions和GLSL ES Versions 的之间的关系和区别
来源:互联网 发布:飞行员 知乎 编辑:程序博客网 时间:2024/04/25 20:31
https://github.com/mattdesl/lwjgl-basics/wiki/GLSL-Versions
GLSL Versions
OpenGL Version
GLSL Version
2.0
110
2.1
120
3.0
130
3.1
140
3.2
150
3.3
330
4.0
400
4.1
410
4.2
420
4.3
430
GLSL ES Versions (Android, iOS, WebGL)
OpenGL ES has its own Shading Language, and the versioning starts fresh. It is based on OpenGL Shading Language version 1.10.
OpenGL ES VersionGLSL ES Version2.01003.0300So, for example, if a feature is available in GLSL 120, it probably won't be available in GLSL ES 100 unless the ES compiler specifically allows it.
Differences at a Glance
Version 100
Vertex shader:
uniform mat4 projTrans;attribute vec2 Position;attribute vec2 TexCoord;varying vec2 vTexCoord;void main() {vTexCoord = TexCoord;gl_Position = u_projView * vec4(Position, 0.0, 1.0);}
Fragment shader:
uniform sampler2D tex0;varying vec2 vTexCoord;void main() { vec4 color = texture2D(tex0, vTexCoord); gl_FragColor = color;}
Version 330
As of GLSL 130+, in
and out
are used instead of attribute
and varying
. GLSL 330+ includes other features like layout qualifiers and changestexture2D
to texture
.
Vertex shader:
#version 330uniform mat4 projTrans;layout(location = 0) in vec2 Position;layout(location = 1) in vec2 TexCoord;out vec2 vTexCoord;void main() {vTexCoord = TexCoord;gl_Position = u_projView * vec4(Position, 0, 1);}
Fragment shader:
#version 330uniform sampler2D tex0;in vec2 vTexCoord;//use your own output instead of gl_FragColor out vec4 fragColor;void main() { //'texture' instead of 'texture2D' fragColor = texture(tex0, vTexCoord);}
Other Significant Changes
GLSL 120 Additions
- You can initialize arrays within a shader, like so:However, the above is not supported on Mac OSX Snow Leopard, even with GLSL 120. (1)
float a[5] = float[5](3.4, 4.2, 5.0, 5.2, 1.1);float b[5] = float[](3.4, 4.2, 5.0, 5.2, 1.1);
- You can initialize uniforms in a shader, and the value will be set at link time:
uniform float val = 1.0;
- You can use built-ins like
sin()
when setting aconst
value - Integers are implicitly converted to floats when necessary, for example:
float f = 1.0; <-- validfloat g = 1; <-- only supported in GLSL 120vec2 v = vec2(1, 2.0); <-- only supported in GLSL 120
- You can use
f
to define a float:float f = 2.5f;
GLSL 130 Additions
int
anduint
support (and bitwise operations with them)switch
statement support- New built-ins:
trunc()
,round()
,roundEven()
,isnan()
,isinf()
,modf()
- Fragment output can be user-defined
- Input and output is declared with
in
andout
syntax instead ofattribute
andvarying
GLSL 150 Additions
texture()
should now be used instead oftexture2D()
GLSL 330 Additions
- Layout qualifiers can declare the location of vertex shader inputs and fragment shader outputs, eg:Formally this was only possible with
layout(location = 2) in vec3 values[4];
ARB_explicit_attrib_location
extension
- GLSL Versions和GLSL ES Versions 的之间的关系和区别
- GLSL Versions
- OpenGL支持的GLSL Versions 版本对应
- cuda glsl opengl 等等之间的关系
- “Bundle version” 和 “Bundle versions string, short”的区别
- “Bundle version” 和 “Bundle versions string, short”的区别
- Bundle versions string, short 和 Bundle version的区别
- Bundle versions string, short 和 Bundle version的区别
- HLSL 与 GLSL 之间的映射关系参考
- Bundle versions 与 Bundle versions string, short 的区别
- 04 WebGL 着色器编程语言GLSL ES的矢量和矩阵
- 12 WebGL 着色器编程语言GLSL ES的全局变量和局部变量
- GLSL的多纹理输入和输出
- iOS 【Xcode-“Bundle version” 和“Bundle versions string,short”的区别&“缺省”的概念】
- Opengl 和 GLSL版本对应关系
- 在OpenGL和GLSL之间传递变量
- 在OpenGL和GLSL之间传递变量
- [Qt和GLSL的笔记3] GLSL基本知识和两个小例子
- 深入理解Unity脚本的执行顺序
- 新的开始
- 【字符串操作】12.字符型转换到整型(atoi)
- uedit用法--集成到java工程中
- SQL Server 中的嵌套事务与@@TranCount(转)
- GLSL Versions和GLSL ES Versions 的之间的关系和区别
- 小琪不小气 - 微信自带表情符号的默认代码
- MCR/MRC学习
- DLL编写教程
- LDR伪指令和LDR指令学习
- vim高级编辑(一)
- 黑马程序员_Java高新技术_泛型
- 黑马程序员_Java高新技术_类加载器的深入讲解与应用
- codeforces #198 div.2 解题报告