没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
The OpenGL
®
Shading Language
Language Version: 4.30
Document Revision: 6
3-Aug-2012
Editor: John Kessenich, LunarG
Version 1.1 Authors: John Kessenich, Dave Baldwin, Randi Rost
Copyright (c) 2008-2012 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 re-formatted 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 web-site
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 non-infringement 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, OpenKODE, OpenKOGS, OpenVG, OpenMAX, OpenSL ES and OpenWF are trademarks of
the Khronos Group Inc. COLLADA is a trademark of Sony Computer Entertainment Inc. used by
permission by Khronos. OpenGL and OpenML are registered trademarks and the OpenGL ES logo is a
trademark of Silicon Graphics Inc. used by permission 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 Summary of Changes from Version 4.20.....................................................................3
1.3 Overview..............................................................................................................................5
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........................................................................................................................9
3.2 Source Strings......................................................................................................................9
3.3 Preprocessor.......................................................................................................................10
3.4 Comments..........................................................................................................................15
3.5 Tokens................................................................................................................................16
3.6 Keywords............................................................................................................................16
3.7 Identifiers...........................................................................................................................18
3.8 Definitions..........................................................................................................................18
3.8.1 Static Use....................................................................................................................19
3.8.2 Uniform and Non-Uniform Control Flow..................................................................19
3.8.3 Dynamically Uniform Expressions.............................................................................19
4 Variables and Types..................................................................................................................20
4.1 Basic Types........................................................................................................................20
4.1.1 Void............................................................................................................................24
4.1.2 Booleans.....................................................................................................................24
4.1.3 Integers.......................................................................................................................24
4.1.4 Floating-Point Variables.............................................................................................26
4.1.5 Vectors........................................................................................................................27
4.1.6 Matrices......................................................................................................................27
4.1.7 Opaque Types.............................................................................................................28
4.1.7.1 Samplers.............................................................................................................28
4.1.7.2 Images.................................................................................................................28
iii
4.1.7.3 Atomic Counters.................................................................................................29
4.1.8 Structures....................................................................................................................29
4.1.9 Arrays.........................................................................................................................30
4.1.10 Implicit Conversions................................................................................................34
4.1.11 Initializers.................................................................................................................35
4.2 Scoping...............................................................................................................................37
4.3 Storage Qualifiers...............................................................................................................40
4.3.1 Default Storage Qualifier............................................................................................41
4.3.2 Constant Qualifier......................................................................................................41
4.3.3 Constant Expressions.................................................................................................41
4.3.4 Input Variables...........................................................................................................42
4.3.5 Uniform Variables......................................................................................................45
4.3.6 Output Variables.........................................................................................................45
4.3.7 Buffer Variables.........................................................................................................47
4.3.8 Shared Variables.........................................................................................................48
4.3.9 Interface Blocks..........................................................................................................48
4.4 Layout Qualifiers................................................................................................................52
4.4.1 Input Layout Qualifiers...............................................................................................53
4.4.1.1 Tessellation Evaluation Inputs............................................................................55
4.4.1.2 Geometry Shader Inputs......................................................................................56
4.4.1.3 Fragment Shader Inputs......................................................................................57
4.4.1.4 Compute Shader Inputs.......................................................................................58
4.4.2 Output Layout Qualifiers............................................................................................59
4.4.2.1 Tessellation Control Outputs..............................................................................61
4.4.2.2 Geometry Outputs...............................................................................................61
4.4.2.3 Fragment Outputs...............................................................................................63
4.4.3 Uniform Variable Layout Qualifiers...........................................................................64
4.4.4 Subroutine Function Layout Qualifiers......................................................................65
4.4.5 Uniform and Shader Storage Block Layout Qualifiers...............................................66
4.4.6 Opaque-Uniform Layout Qualifiers............................................................................68
4.4.6.1 Atomic Counter Layout Qualifiers.....................................................................69
4.4.6.2 Format Layout Qualifiers....................................................................................70
4.5 Interpolation Qualifiers......................................................................................................72
4.5.1 Redeclaring Built-in Interpolation Variables in the Compatibility Profile.................73
4.6 Parameter Qualifiers...........................................................................................................74
4.7 Precision and Precision Qualifiers.....................................................................................74
4.7.1 Range and Precision...................................................................................................74
4.7.2 Precision Qualifiers....................................................................................................75
4.7.3 Default Precision Qualifiers.......................................................................................76
iv
4.7.4 Available Precision Qualifiers....................................................................................77
4.8 Variance and the Invariant Qualifier..................................................................................77
4.8.1 The Invariant Qualifier...............................................................................................77
4.8.2 Invariance of Constant Expressions...........................................................................78
4.9 The Precise Qualifier..........................................................................................................78
4.10 Memory Qualifiers...........................................................................................................81
4.11 Order of Qualification......................................................................................................84
5 Operators and Expressions........................................................................................................85
5.1 Operators............................................................................................................................85
5.2 Array Operations...............................................................................................................86
5.3 Function Calls....................................................................................................................86
5.4 Constructors.......................................................................................................................86
5.4.1 Conversion and Scalar Constructors..........................................................................86
5.4.2 Vector and Matrix Constructors.................................................................................87
5.4.3 Structure Constructors................................................................................................89
5.4.4 Array Constructors.....................................................................................................90
5.5 Vector and Scalar Components and Length.......................................................................90
5.6 Matrix Components............................................................................................................92
5.7 Structure and Array Operations..........................................................................................92
5.8 Assignments.......................................................................................................................93
5.9 Expressions........................................................................................................................94
5.10 Vector and Matrix Operations..........................................................................................97
5.11 Out-of-Bounds Accesses..................................................................................................98
6 Statements and Structure...........................................................................................................99
6.1 Function Definitions.........................................................................................................100
6.1.1 Function Calling Conventions..................................................................................103
6.1.2 Subroutines...............................................................................................................104
6.2 Selection...........................................................................................................................105
6.3 Iteration............................................................................................................................106
6.4 Jumps................................................................................................................................107
7 Built-in Variables....................................................................................................................109
7.1 Built-In Language Variables............................................................................................109
7.1.1 Compatibility Profile Built-In Language Variables..................................................118
7.2 Compatibility Profile Vertex Shader Built-In Inputs.......................................................121
7.3 Built-In Constants............................................................................................................122
7.3.1 Compatibility Profile Built-In Constants..................................................................123
7.4 Built-In Uniform State.....................................................................................................124
7.4.1 Compatibility Profile State.......................................................................................124
8 Built-in Functions...................................................................................................................128
v
剩余195页未读,继续阅读
资源评论
- 可爱多0012015-03-06不错,很实用
- gougoudexili2014-08-12资源很好 有用 感谢楼主
GIS_Tracker
- 粉丝: 19
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功