没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
OpenGL着色语言(OpenGL Shading Language)是用来在OpenGL中着色编程的语言,也即开发人员写的短小的自定义程序,他们是在图形卡的GPU (Graphic Processor Unit图形处理单元)上执行的,代替了固定的渲染管线的一部分,使渲染管线中不同层次具有可编程性。比如:视图转换、投影转换等。GLSL(GL Shading Language)的着色器代码分成2个部分:Vertex Shader(顶点着色器)和Fragment(片断着色器),有时还会有Geometry Shader(几何着色器)。负责运行顶点着色的是顶点着色器。它可以得到当前OpenGL 中的状态,GLSL内置变量进行传递。GLSL其使用C语言作为基础高阶着色语言,避免了使用汇编语言或硬件规格语言的复杂性。
资源推荐
资源详情
资源评论
The OpenGL
®
Shading Language
Language Version: 4.50
Document Revision: 6
14-Apr-2016
Editor: John Kessenich, Google
Version 1.1 Authors: John Kessenich, Dave Baldwin, Randi Rost
Copyright (c) 2008-2016 The Khronos Group Inc. All Rights Reserved.
This specification is protected by copyright laws and contains material proprietary to the Khronos Group,
Inc. It or any components may not be reproduced, republished, distributed, transmitted, displayed,
broadcast, or otherwise exploited in any manner without the express prior written permission of Khronos
Group. You may use this specification for implementing the functionality therein, without altering or
removing any trademark, copyright or other notice from the specification, but the receipt or
possession of this specification does not convey any rights to reproduce, disclose, or distribute its
contents, or to manufacture, use, or sell anything that it may describe, in whole or in part.
Khronos Group grants express permission to any current Promoter, Contributor or Adopter member of
Khronos to copy and redistribute UNMODIFIED versions of this specification in any fashion, provided that
NO CHARGE is made for the specification and the latest available update of the specification for any
version of the API is used whenever possible. Such distributed specification may be reformatted AS
LONG AS the contents of the specification are not changed in any way. The specification may be
incorporated into a product that is sold as long as such product includes significant independent work
developed by the seller. A link to the current version of this specification on the Khronos Group website
should be included whenever possible with specification distributions.
Khronos Group makes no, and expressly disclaims any, representations or warranties, express or
implied, regarding this specification, including, without limitation, any implied warranties of merchantability
or fitness for a particular purpose or noninfringement of any intellectual property. Khronos Group makes
no, and expressly disclaims any, warranties, express or implied, regarding the correctness, accuracy,
completeness, timeliness, and reliability of the specification. Under no circumstances will
the Khronos Group, or any of its Promoters, Contributors or Members or their respective partners,
officers, directors, employees, agents, or representatives be liable for any damages, whether direct,
indirect, special or consequential damages for lost revenues, lost profits, or otherwise, arising from or in
connection with these materials.
Khronos, SYCL, SPIR, WebGL, EGL, COLLADA, StreamInput, OpenVX, OpenKCam, glTF, OpenKODE,
OpenVG, OpenWF, OpenSL ES, OpenMAX, OpenMAX AL, OpenMAX IL and OpenMAX DL are
trademarks and WebCL is a certification mark of the Khronos Group Inc. OpenCL is a trademark of Apple
Inc. and OpenGL and OpenML are registered trademarks and the OpenGL ES and OpenGL SC logos are
trademarks of Silicon Graphics International used under license by Khronos. All other product names,
trademarks, and/or company names are used solely for identification and belong to their respective
owners.
ii
Table of Contents
1 Introduction.................................................................................................................................1
1.1 Acknowledgments................................................................................................................2
1.2 Changes................................................................................................................................3
1.2.1 Changes from Revision 5 of GLSL Version 4.50.........................................................3
1.2.2 Changes from Revision 3 of GLSL Version 4.50.........................................................3
1.2.3 Summary of Changes from Revision 9 of GLSL Version 4.40....................................4
1.3 Overview..............................................................................................................................4
1.4 Error Handling......................................................................................................................5
1.5 Typographical Conventions..................................................................................................5
1.6 Deprecation..........................................................................................................................5
2 Overview of OpenGL Shading....................................................................................................6
2.1 Vertex Processor...................................................................................................................6
2.2 Tessellation Control Processor.............................................................................................6
2.3 Tessellation Evaluation Processor........................................................................................7
2.4 Geometry Processor.............................................................................................................7
2.5 Fragment Processor..............................................................................................................7
2.6 Compute Processor...............................................................................................................7
3 Basics..........................................................................................................................................9
3.1 Character Set and Phases of Compilation............................................................................9
3.2 Source Strings....................................................................................................................10
3.3 Preprocessor.......................................................................................................................11
3.4 Comments..........................................................................................................................16
3.5 Tokens................................................................................................................................17
3.6 Keywords............................................................................................................................17
3.7 Identifiers...........................................................................................................................19
3.8 Definitions..........................................................................................................................19
3.8.1 Static Use....................................................................................................................20
3.8.2 Uniform and Non-Uniform Control Flow..................................................................20
3.8.3 Dynamically Uniform Expressions and Uniform Control Flow.................................20
4 Variables and Types...................................................................................................................22
4.1 Basic Types.........................................................................................................................22
4.1.1 Void.............................................................................................................................26
4.1.2 Booleans.....................................................................................................................26
4.1.3 Integers.......................................................................................................................26
4.1.4 Floating-Point Variables.............................................................................................28
4.1.5 Vectors........................................................................................................................29
4.1.6 Matrices......................................................................................................................29
4.1.7 Opaque Types.............................................................................................................30
iii
4.1.7.1 Samplers.............................................................................................................30
4.1.7.2 Images.................................................................................................................30
4.1.7.3 Atomic Counters.................................................................................................31
4.1.8 Structures....................................................................................................................31
4.1.9 Arrays..........................................................................................................................32
4.1.10 Implicit Conversions................................................................................................36
4.1.11 Initializers.................................................................................................................37
4.2 Scoping...............................................................................................................................39
4.3 Storage Qualifiers...............................................................................................................42
4.3.1 Default Storage Qualifier............................................................................................43
4.3.2 Constant Qualifier......................................................................................................43
4.3.3 Constant Expressions.................................................................................................44
4.3.4 Input Variables............................................................................................................44
4.3.5 Uniform Variables.......................................................................................................47
4.3.6 Output Variables.........................................................................................................48
4.3.7 Buffer Variables..........................................................................................................50
4.3.8 Shared Variables.........................................................................................................51
4.3.9 Interface Blocks..........................................................................................................51
4.4 Layout Qualifiers................................................................................................................56
4.4.1 Input Layout Qualifiers...............................................................................................58
4.4.1.1 Tessellation Evaluation Inputs............................................................................62
4.4.1.2 Geometry Shader Inputs......................................................................................63
4.4.1.3 Fragment Shader Inputs......................................................................................64
4.4.1.4 Compute Shader Inputs.......................................................................................65
4.4.2 Output Layout Qualifiers............................................................................................66
4.4.2.1 Transform Feedback Layout Qualifiers..............................................................68
4.4.2.2 Tessellation Control Outputs..............................................................................70
4.4.2.3 Geometry Outputs...............................................................................................71
4.4.2.4 Fragment Outputs...............................................................................................73
4.4.3 Uniform Variable Layout Qualifiers...........................................................................74
4.4.4 Subroutine Function Layout Qualifiers......................................................................75
4.4.5 Uniform and Shader Storage Block Layout Qualifiers...............................................75
4.4.6 Opaque-Uniform Layout Qualifiers............................................................................78
4.4.6.1 Atomic Counter Layout Qualifiers......................................................................79
4.4.6.2 Format Layout Qualifiers....................................................................................80
4.5 Interpolation Qualifiers......................................................................................................82
4.5.1 Redeclaring Built-in Interpolation Variables in the Compatibility Profile.................83
4.6 Parameter Qualifiers...........................................................................................................84
4.7 Precision and Precision Qualifiers.....................................................................................84
iv
4.7.1 Range and Precision...................................................................................................84
4.7.2 Precision Qualifiers....................................................................................................85
4.7.3 Default Precision Qualifiers.......................................................................................86
4.7.4 Available Precision Qualifiers....................................................................................87
4.8 Variance and the Invariant Qualifier...................................................................................87
4.8.1 The Invariant Qualifier...............................................................................................87
4.8.2 Invariance of Constant Expressions...........................................................................88
4.9 The Precise Qualifier..........................................................................................................88
4.10 Memory Qualifiers...........................................................................................................91
4.11 Order and Repetition of Qualification..............................................................................94
4.12 Empty Declarations..........................................................................................................94
5 Operators and Expressions........................................................................................................95
5.1 Operators............................................................................................................................95
5.2 Array Operations................................................................................................................96
5.3 Function Calls....................................................................................................................96
5.4 Constructors.......................................................................................................................96
5.4.1 Conversion and Scalar Constructors..........................................................................96
5.4.2 Vector and Matrix Constructors..................................................................................97
5.4.3 Structure Constructors................................................................................................99
5.4.4 Array Constructors....................................................................................................100
5.5 Vector and Scalar Components and Length......................................................................100
5.6 Matrix Components..........................................................................................................102
5.7 Structure and Array Operations........................................................................................102
5.8 Assignments.....................................................................................................................103
5.9 Expressions......................................................................................................................104
5.10 Vector and Matrix Operations........................................................................................107
5.11 Out-of-Bounds Accesses................................................................................................108
6 Statements and Structure.........................................................................................................110
6.1 Function Definitions.........................................................................................................111
6.1.1 Function Calling Conventions..................................................................................114
6.1.2 Subroutines...............................................................................................................115
6.2 Selection...........................................................................................................................116
6.3 Iteration.............................................................................................................................117
6.4 Jumps................................................................................................................................118
7 Built-in Variables....................................................................................................................120
7.1 Built-In Language Variables.............................................................................................120
7.1.1 Compatibility Profile Built-In Language Variables..................................................129
7.2 Compatibility Profile Vertex Shader Built-In Inputs........................................................133
7.3 Built-In Constants............................................................................................................133
v
剩余210页未读,继续阅读
资源评论
wjxwalkon
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- IRLAB高性能服务器用户手册,很好的学习教材
- internet-download-manager-6.42.23俄大神版
- (源码)基于LoRa和ESP32的气体检测系统.zip
- 仿造喜马拉雅的一款在线听书小程序(整套源码)
- (源码)基于JavaServlet的电梯维修派单系统.zip
- (源码)基于C语言的ATTINY414微控制器红外遥控系统.zip
- 基于yolov5目标检测技术,使用onnx模型检测图片并返回位置信息(源码)
- (源码)基于自注意力机制深度学习的点云缺陷检测系统.zip
- java销售数据决策管理系统源码数据库 MySQL源码类型 WebForm
- (源码)基于C++的语音客服DSL系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功