-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathH3DU.ShaderInfo.html
executable file
·326 lines (225 loc) · 14.1 KB
/
H3DU.ShaderInfo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<!DOCTYPE html><html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><title>H3DU.ShaderInfo</title><meta name="viewport" content="width=device-width"><link rel=stylesheet type="text/css" href="/style.css"></head><body> <div class="header">
<p><a href="#navigation">Menu</a> - <a href="#top">Top</a> - <a href="/">Home</a> -
<a href="http://peteroupc.github.io/">Donate to Me</a></p></div>
<div class="mainarea" id="top">
<h1>H3DU.ShaderInfo</h1>
<p><a href="index.html">Back to documentation index.</a></p>
<p><a name='H3DU.ShaderInfo'></a></p>
<h3>H3DU.ShaderInfo([vertexShader], [fragmentShader])</h3>
<p>Holds source code for a WebGL shader program. A shader program in
WebGL consists of a vertex shader (which processes vertices),
and a fragment shader (which processes pixels). Shader programs
are specially designed for running on a graphics processing unit,
or GPU.</p>
<p>This class also stores semantics and uniform values associated with the shader
source code.</p>
<p>Note that this class is not associated with any WebGL context, so the
uniform values this object stores is not set for any WebGL context.</p>
<p>Currently, the following attribute names are associated
with this object by default:<ul>
<li><code>position</code> - "POSITION" semantic</li>
<li><code>normal</code> - "NORMAL" semantic</li>
<li><code>uv</code> - "TEXCOORD_0" semantic</li>
<li><code>tangent</code> - Attribute for tangents.</li>
<li><code>bitangent</code> - Attribute for bitangents</li>
<li><code>colorAttr</code> - "COLOR"</li>
</ul></p>
<p>Currently, the following uniform names are associated
with this object by default:<ul>
<li><code>projection</code> - Projection matrix</li>
<li><code>modelViewMatrix</code> - Model-view matrix</li>
<li><code>normalMatrix</code> - Inverse transpose of the model-view matrix</li>
<li><code>world</code> - World matrix.</li>
<li><code>inverseView</code> - Inverse view matrix.</li>
</ul></p>
<h4>Parameters</h4>
<ul>
<li><code>vertexShader</code> (Type: string) (optional)<br>Source text of a vertex shader, in OpenGL ES Shading Language (GLSL). If null, a default vertex shader is used instead.</li>
<li><code>fragmentShader</code> (Type: string) (optional)<br>Source text of a fragment shader in GLSL. If null, a default fragment shader is used instead.</li>
</ul>
<h3>Methods</h3>
<ul>
<li><a href="#H3DU.ShaderInfo_copy">copy</a><br>Returns a new shader info object with the information in this object
copied to that object.</li>
<li><a href="#H3DU.ShaderInfo_dispose">dispose</a><br><strong>Deprecated: Yes</strong></li>
<li><a href="#H3DU.ShaderInfo.getBasicVertex">getBasicVertex</a><br>Gets the text of a basic vertex shader.</li>
<li><a href="#H3DU.ShaderInfo.getDefaultFragment">getDefaultFragment</a><br>Gets the text of the default fragment shader.</li>
<li><a href="#H3DU.ShaderInfo.getDefaultVertex">getDefaultVertex</a><br>Gets the text of the default vertex shader.</li>
<li><a href="#H3DU.ShaderInfo_getFragmentShader">getFragmentShader</a><br>Gets the text of the fragment shader stored in this object.</li>
<li><a href="#H3DU.ShaderInfo_getVertexShader">getVertexShader</a><br>Gets the text of the vertex shader stored in this object.</li>
<li><a href="#H3DU.ShaderInfo.makeCopyEffect">makeCopyEffect</a><br>Generates source code for a shader program that copies the colors of a texture.</li>
<li><a href="#H3DU.ShaderInfo.makeEdgeDetectEffect">makeEdgeDetectEffect</a><br>Generates source code for a shader program that generates a two-color texture showing
the source texture's edges.</li>
<li><a href="#H3DU.ShaderInfo.makeEffect">makeEffect</a><br>Generates source code for a shader program for applying
a raster effect (postprocessing effect) to a texture.</li>
<li><a href="#H3DU.ShaderInfo.makeEffectFragment">makeEffectFragment</a><br>Generates source code for a fragment shader for applying
a raster effect to a texture.</li>
<li><a href="#H3DU.ShaderInfo.makeInvertEffect">makeInvertEffect</a><br>Generates source code for a shader program that inverts the colors of a texture.</li>
<li><a href="#H3DU.ShaderInfo_setSemantic">setSemantic</a><br>Sets the semantic for a vertex attribute.</li>
<li><a href="#H3DU.ShaderInfo_setUniformSemantic">setUniformSemantic</a><br>Sets a semantic for the specified named uniform.</li>
<li><a href="#H3DU.ShaderInfo_setUniforms">setUniforms</a><br>Sets the values of one or more uniforms used by this shader program.</li>
</ul>
<p><a name='H3DU.ShaderInfo_copy'></a></p>
<h3>H3DU.ShaderInfo#copy()</h3>
<p>Returns a new shader info object with the information in this object
copied to that object.</p>
<h4>Return Value</h4>
<p>Return value. (Type: <a href="H3DU.ShaderInfo.html">H3DU.ShaderInfo</a>)</p>
<p><a name='H3DU.ShaderInfo_dispose'></a></p>
<h3>H3DU.ShaderInfo#dispose()</h3>
<p><strong>Deprecated: Yes</strong></p>
<p>This method was introduced for compatibility reasons.</p>
<p><a name='H3DU.ShaderInfo.getBasicVertex'></a></p>
<h3>(static) H3DU.ShaderInfo.getBasicVertex()</h3>
<p>Gets the text of a basic vertex shader.</p>
<h4>Return Value</h4>
<p>The resulting shader text. (Type: string)</p>
<p><a name='H3DU.ShaderInfo.getDefaultFragment'></a></p>
<h3>(static) H3DU.ShaderInfo.getDefaultFragment()</h3>
<p>Gets the text of the default fragment shader.</p>
<h4>Return Value</h4>
<p>The resulting shader text. (Type: string)</p>
<p><a name='H3DU.ShaderInfo.getDefaultVertex'></a></p>
<h3>(static) H3DU.ShaderInfo.getDefaultVertex()</h3>
<p>Gets the text of the default vertex shader. Putting "#define SHADING\n"
at the start of the return value enables the lighting model.</p>
<h4>Return Value</h4>
<p>The resulting shader text. (Type: string)</p>
<p><a name='H3DU.ShaderInfo_getFragmentShader'></a></p>
<h3>H3DU.ShaderInfo#getFragmentShader()</h3>
<p>Gets the text of the fragment shader stored in this object.</p>
<h4>Return Value</h4>
<p>return value. (Type: string)</p>
<p><a name='H3DU.ShaderInfo_getVertexShader'></a></p>
<h3>H3DU.ShaderInfo#getVertexShader()</h3>
<p>Gets the text of the vertex shader stored in this object.</p>
<h4>Return Value</h4>
<p>return value. (Type: string)</p>
<p><a name='H3DU.ShaderInfo.makeCopyEffect'></a></p>
<h3>(static) H3DU.ShaderInfo.makeCopyEffect()</h3>
<p>Generates source code for a shader program that copies the colors of a texture.</p>
<h4>Return Value</h4>
<p>The resulting shader program. (Type: <a href="H3DU.ShaderInfo.html">H3DU.ShaderInfo</a>)</p>
<p><a name='H3DU.ShaderInfo.makeEdgeDetectEffect'></a></p>
<h3>(static) H3DU.ShaderInfo.makeEdgeDetectEffect()</h3>
<p>Generates source code for a shader program that generates a two-color texture showing
the source texture's edges.</p>
<h4>Return Value</h4>
<p>The resulting shader program. (Type: <a href="H3DU.ShaderInfo.html">H3DU.ShaderInfo</a>)</p>
<p><a name='H3DU.ShaderInfo.makeEffect'></a></p>
<h3>(static) H3DU.ShaderInfo.makeEffect(functionCode)</h3>
<p>Generates source code for a shader program for applying
a raster effect (postprocessing effect) to a texture.</p>
<h4>Parameters</h4>
<ul>
<li><p><code>functionCode</code> (Type: string)<br>A string giving shader code in OpenGL ES Shading Language (GLSL) that must contain a function with the following signature:</p>
<p>vec4 textureEffect(sampler2D sampler, vec2 uvCoord, vec2 textureSize)</p>
<p>where <code>sampler</code> is the texture sampler, <code>uvCoord</code> is the texture coordinates ranging from 0 to 1 in each component, <code>textureSize</code> is the dimensions of the texture in pixels, and the return value is the new color at the specified texture coordinates. Besides this requirement, the shader code is also free to define additional uniforms, constants, functions, and so on (but not another "main" function).</p></li>
</ul>
<h4>Return Value</h4>
<p>The resulting shader program. (Type: <a href="H3DU.ShaderInfo.html">H3DU.ShaderInfo</a>)</p>
<p><a name='H3DU.ShaderInfo.makeEffectFragment'></a></p>
<h3>(static) H3DU.ShaderInfo.makeEffectFragment(functionCode)</h3>
<p>Generates source code for a fragment shader for applying
a raster effect to a texture.</p>
<h4>Parameters</h4>
<ul>
<li><code>functionCode</code> (Type: string)<br>See <a href="H3DU.ShaderInfo.html#H3DU.ShaderInfo.makeEffect">H3DU.ShaderInfo.makeEffect</a>.</li>
</ul>
<h4>Return Value</h4>
<p>The source text of the resulting fragment shader. (Type: string)</p>
<p><a name='H3DU.ShaderInfo.makeInvertEffect'></a></p>
<h3>(static) H3DU.ShaderInfo.makeInvertEffect()</h3>
<p>Generates source code for a shader program that inverts the colors of a texture.</p>
<h4>Return Value</h4>
<p>The resulting shader program. (Type: <a href="H3DU.ShaderInfo.html">H3DU.ShaderInfo</a>)</p>
<p><a name='H3DU.ShaderInfo_setSemantic'></a></p>
<h3>H3DU.ShaderInfo#setSemantic(name, semantic, semanticIndex)</h3>
<p>Sets the semantic for a vertex attribute.</p>
<h4>Parameters</h4>
<ul>
<li><code>name</code> (Type: string)<br>Name of the attribute.</li>
<li><code>semantic</code> (Type: Number | String)<br>An attribute semantic, such as <a href="H3DU.Semantic.html#H3DU.Semantic.POSITION">H3DU.Semantic.POSITION</a>, "POSITION", or "TEXCOORD_0".</li>
<li><code>semanticIndex</code> (Type: number)<br>The set index of the attribute for the specified semantic. 0 is the first index of the attribute, 1 is the second, and so on. This is ignored if "semantic" is a string.</li>
</ul>
<h4>Return Value</h4>
<p>This object. Throws an error if the specified
semantic is unsupported. (Type: <a href="H3DU.ShaderInfo.html">H3DU.ShaderInfo</a>)</p>
<p><a name='H3DU.ShaderInfo_setUniformSemantic'></a></p>
<h3>H3DU.ShaderInfo#setUniformSemantic(u, sem)</h3>
<p>Sets a semantic for the specified named uniform.</p>
<h4>Parameters</h4>
<ul>
<li><code>u</code> (Type: string)<br>The name of the uniform.</li>
<li><code>sem</code> (Type: number)<br>A uniform semantic given in <a href="H3DU.Semantic.html">H3DU.Semantic</a>.</li>
</ul>
<h4>Return Value</h4>
<p>This object. (Type: <a href="H3DU.ShaderInfo.html">H3DU.ShaderInfo</a>)</p>
<p><a name='H3DU.ShaderInfo_setUniforms'></a></p>
<h3>H3DU.ShaderInfo#setUniforms(uniforms)</h3>
<p>Sets the values of one or more uniforms used by this shader program.
Since this object doesn't store a WebGL context, or receive one as input,
the uniforms won't be associated with a WebGL context.</p>
<h4>Parameters</h4>
<ul>
<li><code>uniforms</code> (Type: Object)<br>An object whose keys are the names of uniforms defined in either the vertex or fragment shader of this shader program. If the uniform is an array, each element in the array is named as in these examples: "unif[0]", "unif[1]". If it's a struct, each member in the struct is named as in these examples: "unif.member1", "unif.member2". If it's an array of struct, each member is named as in these examples: "unif[0].member1", "unif[0].member2". The value of each key depends on the data type expected for the uniform named by that key. The value can be a 3-, 4-, 9-, or 16-element array if the uniform is a "vec3", "vec4", "mat3", or "mat4", respectively, or a Number if the uniform is a "float" or "int".</li>
</ul>
<h4>Return Value</h4>
<p>This object. (Type: <a href="H3DU.ShaderInfo.html">H3DU.ShaderInfo</a>)</p>
<p><a href="index.html">Back to documentation index.</a></p>
</div><nav id="navigation"><ul>
<li><a href="/">Back to start site.</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io">This site's repository (source code)</a>
<li><a href="https://github.com/peteroupc/peteroupc.github.io/issues">Post an issue or comment</a></ul>
<p>
<a href="//twitter.com/share">Share via Twitter</a>, <a href="//www.facebook.com/sharer/sharer.php" id="sharer">Share via Facebook</a>
</p>
</div>
<h3>Navigation</h3>
<ul>
<li><a href="DrawingToy.html">DrawingToy</a></li>
<li><a href="Epitrochoid.html">Epitrochoid</a></li>
<li><a href="H3DU.html">H3DU</a></li>
<li><a href="H3DU.BSplineCurve.html">H3DU.BSplineCurve</a></li>
<li><a href="H3DU.BSplineSurface.html">H3DU.BSplineSurface</a></li>
<li><a href="H3DU.BufferAccessor.html">H3DU.BufferAccessor</a></li>
<li><a href="H3DU.Camera.html">H3DU.Camera</a></li>
<li><a href="H3DU.Curve.html">H3DU.Curve</a></li>
<li><a href="H3DU.CurveBuilder.html">H3DU.CurveBuilder</a></li>
<li><a href="H3DU.CurveTube.html">H3DU.CurveTube</a></li>
<li><a href="H3DU.GraphicsPath.html">H3DU.GraphicsPath</a></li>
<li><a href="H3DU.InputTracker.html">H3DU.InputTracker</a></li>
<li><a href="H3DU.MathUtil.html">H3DU.MathUtil</a></li>
<li><a href="H3DU.MeshBuffer.html">H3DU.MeshBuffer</a></li>
<li><a href="H3DU.Meshes.html">H3DU.Meshes</a></li>
<li><a href="H3DU.PiecewiseCurve.html">H3DU.PiecewiseCurve</a></li>
<li><a href="H3DU.Shape.html">H3DU.Shape</a></li>
<li><a href="H3DU.ShapeGroup.html">H3DU.ShapeGroup</a></li>
<li><a href="H3DU.Surface.html">H3DU.Surface</a></li>
<li><a href="H3DU.SurfaceBuilder.html">H3DU.SurfaceBuilder</a></li>
<li><a href="H3DU.TextFont.html">H3DU.TextFont</a></li>
<li><a href="H3DU.TextureAtlas.html">H3DU.TextureAtlas</a></li>
<li><a href="H3DU.Transform.html">H3DU.Transform</a></li>
<li><a href="Hypotrochoid.html">Hypotrochoid</a></li>
<li><a href="MatrixStack.html">MatrixStack</a></li>
<li><a href="Polyhedra.html">Polyhedra</a></li>
<li><a href="Promise.html">Promise</a></li>
<li><a href="Semantic.html">Semantic</a></li>
<li><a href="StarField.html">StarField</a></li>
<li><a href="Superellipsoid.html">Superellipsoid</a></li>
<li><a href="Supertoroid.html">Supertoroid</a></li>
<li><a href="SurfaceOfRevolution.html">SurfaceOfRevolution</a></li>
<li><a href="Trochoid.html">Trochoid</a></li>
<li><a href="curveCatacaustic.html">curveCatacaustic</a></li>
<li><a href="curveEvolute.html">curveEvolute</a></li>
<li><a href="curveInverse.html">curveInverse</a></li>
<li><a href="curveInvolute.html">curveInvolute</a></li>
<li><a href="curveOrthotomic.html">curveOrthotomic</a></li>
<li><a href="curvePedalCurve.html">curvePedalCurve</a></li>
<li><a href="curveRadialCurve.html">curveRadialCurve</a></li>
<li><a href="polarCurve.html">polarCurve</a></li>
<li><a href="ruledSurface.html">ruledSurface</a></li>
<li><a href="spiralCurve.html">spiralCurve</a></li>
</ul>
</nav>
</body></html>