@galacean/effects-webgl 2.6.6 → 2.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gl-engine.d.ts +320 -3
- package/dist/gl-geometry.d.ts +1 -2
- package/dist/gl-gpu-buffer.d.ts +3 -3
- package/dist/gl-material-state.d.ts +2 -2
- package/dist/gl-material.d.ts +4 -4
- package/dist/gl-program.d.ts +0 -2
- package/dist/gl-renderer-internal.d.ts +0 -2
- package/dist/gl-renderer.d.ts +3 -5
- package/dist/gl-shader-library.d.ts +2 -3
- package/dist/gl-shader.d.ts +0 -2
- package/dist/gl-texture.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/package.json +2 -2
- package/dist/gl-pipeline-context.d.ts +0 -325
- package/dist/gl-uniform-utils.d.ts +0 -46
package/dist/gl-engine.d.ts
CHANGED
|
@@ -1,11 +1,328 @@
|
|
|
1
|
-
import { Engine } from '@galacean/effects-core';
|
|
2
1
|
import type { GLRendererInternal } from './gl-renderer-internal';
|
|
3
2
|
import type { GLRenderer } from './gl-renderer';
|
|
4
|
-
import
|
|
3
|
+
import { GLShaderLibrary } from './gl-shader-library';
|
|
4
|
+
import type { Nullable, Texture, math } from '@galacean/effects-core';
|
|
5
|
+
import { Engine } from '@galacean/effects-core';
|
|
6
|
+
type Color = math.Color;
|
|
7
|
+
type Vector2 = math.Vector2;
|
|
8
|
+
type Vector3 = math.Vector3;
|
|
9
|
+
type Vector4 = math.Vector4;
|
|
10
|
+
type Matrix3 = math.Matrix3;
|
|
11
|
+
type Matrix4 = math.Matrix4;
|
|
12
|
+
type Quaternion = math.Quaternion;
|
|
5
13
|
export declare class GLEngine extends Engine {
|
|
14
|
+
gl: WebGLRenderingContext | WebGL2RenderingContext;
|
|
15
|
+
textureUnitDict: Record<string, WebGLTexture | null>;
|
|
16
|
+
shaderLibrary: GLShaderLibrary;
|
|
17
|
+
private readonly maxTextureCount;
|
|
18
|
+
private glCapabilityCache;
|
|
19
|
+
private currentFramebuffer;
|
|
20
|
+
private currentTextureBinding;
|
|
21
|
+
private currentRenderbuffer;
|
|
22
|
+
private activeTextureIndex;
|
|
23
|
+
private pixelStorei;
|
|
6
24
|
constructor(gl: WebGLRenderingContext | WebGL2RenderingContext);
|
|
7
25
|
dispose(): void;
|
|
8
26
|
getGLRenderer(): GLRenderer;
|
|
9
27
|
getGLRendererInternal(): GLRendererInternal;
|
|
10
|
-
|
|
28
|
+
private reset;
|
|
29
|
+
toggle(capability: GLenum, enable?: boolean): void;
|
|
30
|
+
/**
|
|
31
|
+
* 对于该上下文开启某种特性
|
|
32
|
+
* @param capability
|
|
33
|
+
* example:
|
|
34
|
+
* gl.enable(gl.DITHER);
|
|
35
|
+
*/
|
|
36
|
+
enable(capability: GLenum): void;
|
|
37
|
+
/**
|
|
38
|
+
* 基于某种上下文关闭特性
|
|
39
|
+
* @param capability
|
|
40
|
+
* example:
|
|
41
|
+
* gl.disable(gl.DITHER);
|
|
42
|
+
*/
|
|
43
|
+
disable(capability: GLenum): void;
|
|
44
|
+
/**
|
|
45
|
+
* 绑定framebuffer webgl2新增: gl.DRAW_FRAMEBUFFER 和 gl.READ_FRAMEBUFFER
|
|
46
|
+
* @param target
|
|
47
|
+
* @param framebuffer
|
|
48
|
+
* example:
|
|
49
|
+
* const framebuffer = gl.createFramebuffer();
|
|
50
|
+
* gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
51
|
+
*/
|
|
52
|
+
bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer | null): void;
|
|
53
|
+
bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer | null): void;
|
|
54
|
+
/**
|
|
55
|
+
* 绑定系统 framebuffer
|
|
56
|
+
*/
|
|
57
|
+
bindSystemFramebuffer(): void;
|
|
58
|
+
/**
|
|
59
|
+
* 将定义好的 WebGLProgram 对象添加到当前的渲染状态中。
|
|
60
|
+
* @param program
|
|
61
|
+
* example:
|
|
62
|
+
* gl.useProgram(program);
|
|
63
|
+
* gl.useProgram(null);
|
|
64
|
+
*/
|
|
65
|
+
useProgram(program: WebGLProgram | null): void;
|
|
66
|
+
/**
|
|
67
|
+
* 使用预设值来清空缓冲
|
|
68
|
+
* @param mask
|
|
69
|
+
* example:
|
|
70
|
+
* gl.clear(gl.DEPTH_BUFFER_BIT);
|
|
71
|
+
* gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT);
|
|
72
|
+
*/
|
|
73
|
+
clear(mask: number): void;
|
|
74
|
+
/*** depth start ***/
|
|
75
|
+
/**
|
|
76
|
+
* 设置深度缓冲区的深度清除值
|
|
77
|
+
* @param depth
|
|
78
|
+
* example:
|
|
79
|
+
* gl.clearDepth(0.5);
|
|
80
|
+
*/
|
|
81
|
+
clearDepth(depth: GLclampf): void;
|
|
82
|
+
/**
|
|
83
|
+
* 指定将输入像素深度与当前深度缓冲区值进行比较的函数。
|
|
84
|
+
* @param func
|
|
85
|
+
* example:
|
|
86
|
+
* gl.enable(gl.DEPTH_TEST);
|
|
87
|
+
* gl.depthFunc(gl.NEVER);
|
|
88
|
+
*/
|
|
89
|
+
depthFunc(func: GLenum): void;
|
|
90
|
+
/**
|
|
91
|
+
* 设置是否启用写入深度缓冲。
|
|
92
|
+
* @param flag
|
|
93
|
+
* example:
|
|
94
|
+
* gl.depthMask(false);
|
|
95
|
+
*/
|
|
96
|
+
depthMask(flag: boolean): void;
|
|
97
|
+
polygonOffset(factor: number, unit: number): void;
|
|
98
|
+
/**
|
|
99
|
+
* 将 z 值从规范化设备坐标映射到窗口坐标
|
|
100
|
+
* @param zNear
|
|
101
|
+
* @param zFar
|
|
102
|
+
* example:
|
|
103
|
+
* gl.depthRange(0.2, 0.6);
|
|
104
|
+
*/
|
|
105
|
+
depthRange(zNear: number, zFar: number): void;
|
|
106
|
+
/*** depth end ***/
|
|
107
|
+
/*** stencil start ***/
|
|
108
|
+
/**
|
|
109
|
+
* 模版测试设置函数和引用值。
|
|
110
|
+
* @param func
|
|
111
|
+
* @param ref
|
|
112
|
+
* @param mask
|
|
113
|
+
* example:
|
|
114
|
+
* gl.enable(gl.STENCIL_TEST);
|
|
115
|
+
* gl.stencilFunc(gl.LESS, 0, 0b1110011);
|
|
116
|
+
*/
|
|
117
|
+
clearStencil(s: GLint): void;
|
|
118
|
+
/**
|
|
119
|
+
* 控制启用和禁用模板平面中单个位的正面和背面写入
|
|
120
|
+
* @param mask
|
|
121
|
+
* example:
|
|
122
|
+
* gl.stencilMask(0xff);
|
|
123
|
+
*/
|
|
124
|
+
stencilMask(mask: number): void;
|
|
125
|
+
/**
|
|
126
|
+
* 模版测试设置函数和引用值。
|
|
127
|
+
* @param func
|
|
128
|
+
* @param ref
|
|
129
|
+
* @param mask
|
|
130
|
+
* example:
|
|
131
|
+
* gl.enable(gl.STENCIL_TEST);
|
|
132
|
+
* gl.stencilFunc(gl.LESS, 0, 0b1110011);
|
|
133
|
+
*/
|
|
134
|
+
stencilFunc(func: GLenum, ref: GLint, mask: GLuint): void;
|
|
135
|
+
/**
|
|
136
|
+
* 单面模版测试
|
|
137
|
+
* @param face
|
|
138
|
+
* @param func
|
|
139
|
+
* @param ref
|
|
140
|
+
* @param mask
|
|
141
|
+
* example:
|
|
142
|
+
* gl.enable(gl.STENCIL_TEST);
|
|
143
|
+
* gl.stencilFuncSeparate(gl.FRONT, gl.LESS, 0.2, 1110011);
|
|
144
|
+
*/
|
|
145
|
+
stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint): void;
|
|
146
|
+
/**
|
|
147
|
+
* 单面的mask写入
|
|
148
|
+
* @param face
|
|
149
|
+
* @param mask
|
|
150
|
+
* example:
|
|
151
|
+
* gl.stencilMaskSeparate(gl.FRONT, 110101);
|
|
152
|
+
*/
|
|
153
|
+
stencilMaskSeparate(face: GLenum, mask: GLuint): void;
|
|
154
|
+
/**
|
|
155
|
+
* 设置正面和背面模板测试操作
|
|
156
|
+
* @param fail
|
|
157
|
+
* @param zfail
|
|
158
|
+
* @param zpass
|
|
159
|
+
* example:
|
|
160
|
+
* gl.enable(gl.STENCIL_TEST);
|
|
161
|
+
* gl.stencilOp(gl.INCR, gl.DECR, gl.INVERT);
|
|
162
|
+
*/
|
|
163
|
+
stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum): void;
|
|
164
|
+
/**
|
|
165
|
+
* 设置正面和/或背面模板测试操作
|
|
166
|
+
* @param face
|
|
167
|
+
* @param fail
|
|
168
|
+
* @param zfail
|
|
169
|
+
* @param zpass
|
|
170
|
+
* example:
|
|
171
|
+
* gl.enable(gl.STENCIL_TEST);
|
|
172
|
+
* gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl.INVERT);
|
|
173
|
+
*/
|
|
174
|
+
stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum): void;
|
|
175
|
+
/*** stencil end ***/
|
|
176
|
+
/*** face start ***/
|
|
177
|
+
/**
|
|
178
|
+
* 剔除方式
|
|
179
|
+
* @param mode
|
|
180
|
+
* example:
|
|
181
|
+
* gl.enable(gl.CULL_FACE);
|
|
182
|
+
* gl.cullFace(gl.FRONT_AND_BACK);
|
|
183
|
+
*/
|
|
184
|
+
cullFace(mode: GLenum): void;
|
|
185
|
+
/**
|
|
186
|
+
* 设置卷绕方向
|
|
187
|
+
* @param mode
|
|
188
|
+
* example:
|
|
189
|
+
* gl.frontFace(gl.CW);
|
|
190
|
+
*/
|
|
191
|
+
frontFace(mode: GLenum): void;
|
|
192
|
+
/*** face end ***/
|
|
193
|
+
/*** color start ***/
|
|
194
|
+
/**
|
|
195
|
+
* 设置颜色写入
|
|
196
|
+
* @param red
|
|
197
|
+
* @param green
|
|
198
|
+
* @param blue
|
|
199
|
+
* @param alpha
|
|
200
|
+
* example:
|
|
201
|
+
* gl.colorMask(true, true, true, false);
|
|
202
|
+
*/
|
|
203
|
+
clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void;
|
|
204
|
+
/**
|
|
205
|
+
* 设置颜色写入
|
|
206
|
+
* @param red
|
|
207
|
+
* @param green
|
|
208
|
+
* @param blue
|
|
209
|
+
* @param alpha
|
|
210
|
+
* example:
|
|
211
|
+
* gl.colorMask(true, true, true, false);
|
|
212
|
+
*/
|
|
213
|
+
colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void;
|
|
214
|
+
/**
|
|
215
|
+
* 设置源和目标混合因子
|
|
216
|
+
* @param red
|
|
217
|
+
* @param green
|
|
218
|
+
* @param blue
|
|
219
|
+
* @param alpha
|
|
220
|
+
* example:
|
|
221
|
+
* gl.blendColor(0, 0.5, 1, 1);
|
|
222
|
+
*/
|
|
223
|
+
blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void;
|
|
224
|
+
/**
|
|
225
|
+
* 用于混合像素算法
|
|
226
|
+
* @param sfactor
|
|
227
|
+
* @param dfactor
|
|
228
|
+
* example:
|
|
229
|
+
* gl.enable(gl.BLEND);
|
|
230
|
+
* gl.blendFunc(gl.SRC_COLOR, gl.DST_COLOR);
|
|
231
|
+
*/
|
|
232
|
+
blendFunc(sfactor: GLenum, dfactor: GLenum): void;
|
|
233
|
+
/**
|
|
234
|
+
* 分别设置应用在 RGB 和 Alpha 上的 factor
|
|
235
|
+
* @param srcRGB
|
|
236
|
+
* @param dstRGB
|
|
237
|
+
* @param srcAlpha
|
|
238
|
+
* @param dstAlpha
|
|
239
|
+
* example:
|
|
240
|
+
* gl.enable(gl.BLEND);
|
|
241
|
+
* gl.blendFuncSeparate(gl.SRC_COLOR, gl.DST_COLOR, gl.ONE, gl.ZERO);
|
|
242
|
+
*/
|
|
243
|
+
blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum): void;
|
|
244
|
+
/**
|
|
245
|
+
* 设置混合模式
|
|
246
|
+
* @param mode
|
|
247
|
+
* example:
|
|
248
|
+
* gl.blendEquation(gl.FUNC_ADD);
|
|
249
|
+
* gl.blendEquation(gl.FUNC_SUBTRACT);
|
|
250
|
+
* gl.blendEquation(gl.FUNC_REVERSE_SUBTRACT);
|
|
251
|
+
*/
|
|
252
|
+
blendEquation(mode: GLenum): void;
|
|
253
|
+
/**
|
|
254
|
+
* 可以分别对 RGB 和 Alpha 做不同的操作处理
|
|
255
|
+
* @param modeRGB
|
|
256
|
+
* @param modeAlpha
|
|
257
|
+
* example:
|
|
258
|
+
* gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_SUBTRACT);
|
|
259
|
+
*/
|
|
260
|
+
blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum): void;
|
|
261
|
+
/*** color end ***/
|
|
262
|
+
/**
|
|
263
|
+
* 图像预处理
|
|
264
|
+
* @param pname
|
|
265
|
+
* @param param
|
|
266
|
+
* example:
|
|
267
|
+
* var tex = gl.createTexture();
|
|
268
|
+
* gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
269
|
+
* gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
|
|
270
|
+
*/
|
|
271
|
+
setPixelStorei(pname: GLenum, param: GLenum): void;
|
|
272
|
+
/**
|
|
273
|
+
* 用来设置视口,即指定从标准设备到窗口坐标的x、y仿射变换。
|
|
274
|
+
* @param x
|
|
275
|
+
* @param y
|
|
276
|
+
* @param width
|
|
277
|
+
* @param height
|
|
278
|
+
* example:
|
|
279
|
+
* gl.viewport(0, 0, width, height);
|
|
280
|
+
*/
|
|
281
|
+
viewport(x: number, y: number, width: number, height: number): void;
|
|
282
|
+
/**
|
|
283
|
+
* 激活指定的纹理单元
|
|
284
|
+
* @param texture
|
|
285
|
+
* example:
|
|
286
|
+
* gl.activeTexture(gl.TEXTURE1);
|
|
287
|
+
*/
|
|
288
|
+
activeTexture(texture: GLenum): void;
|
|
289
|
+
/**
|
|
290
|
+
* 绑定WebGLTexture
|
|
291
|
+
* @param target
|
|
292
|
+
* @param texture
|
|
293
|
+
* @param force
|
|
294
|
+
* example:
|
|
295
|
+
* const texture = gl.createTexture();
|
|
296
|
+
* gl.bindTexture(gl.TEXTURE_2D, texture)
|
|
297
|
+
*/
|
|
298
|
+
bindTexture(target: GLenum, texture: WebGLTexture | null, force?: boolean): void;
|
|
299
|
+
private set1;
|
|
300
|
+
private set2;
|
|
301
|
+
private set3;
|
|
302
|
+
private set4;
|
|
303
|
+
get(name: string): any;
|
|
304
|
+
setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
|
|
305
|
+
setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
|
|
306
|
+
setFloats(uniform: Nullable<WebGLUniformLocation>, value: number[]): void;
|
|
307
|
+
setVector2(uniform: Nullable<WebGLUniformLocation>, value: Vector2): void;
|
|
308
|
+
setVector3(uniform: Nullable<WebGLUniformLocation>, value: Vector3): void;
|
|
309
|
+
setVector4(uniform: Nullable<WebGLUniformLocation>, value: Vector4): void;
|
|
310
|
+
setColor(uniform: Nullable<WebGLUniformLocation>, value: Color): void;
|
|
311
|
+
setQuaternion(uniform: Nullable<WebGLUniformLocation>, value: Quaternion): void;
|
|
312
|
+
setVector4Array(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
|
|
313
|
+
setMatrix(uniform: Nullable<WebGLUniformLocation>, value: Matrix4): void;
|
|
314
|
+
setMatrix3(uniform: Nullable<WebGLUniformLocation>, value: Matrix3): void;
|
|
315
|
+
setMatrixArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
|
|
316
|
+
setTexture(uniform: Nullable<WebGLUniformLocation>, channel: number, texture: Texture): void;
|
|
317
|
+
/**
|
|
318
|
+
* 查询所有uniform的location。
|
|
319
|
+
* @param program 查询的shader program
|
|
320
|
+
* @param uniformsNames 查询的uniform名称列表
|
|
321
|
+
* @returns
|
|
322
|
+
*/
|
|
323
|
+
getUniforms(program: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
|
|
324
|
+
private setFloat4;
|
|
325
|
+
private setFloat3;
|
|
326
|
+
private setFloat2;
|
|
11
327
|
}
|
|
328
|
+
export {};
|
package/dist/gl-geometry.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { Engine, GeometryProps, SkinProps } from '@galacean/effects-core';
|
|
|
2
2
|
import { spec, Geometry } from '@galacean/effects-core';
|
|
3
3
|
import type { GLGPUBufferProps } from './gl-gpu-buffer';
|
|
4
4
|
import { GLGPUBuffer } from './gl-gpu-buffer';
|
|
5
|
-
import type { GLPipelineContext } from './gl-pipeline-context';
|
|
6
5
|
import type { GLVertexArrayObject } from './gl-vertex-array-object';
|
|
7
6
|
/**
|
|
8
7
|
* 应用层 Geometry 对象,本身不直接保存 GPU 资源而是通过 geometryInternal 成员保存 GPU 资源
|
|
@@ -73,7 +72,7 @@ export declare class GLGeometry extends Geometry {
|
|
|
73
72
|
getDrawCount(): number;
|
|
74
73
|
getSkinProps(): SkinProps;
|
|
75
74
|
private getAttributeBufferOption;
|
|
76
|
-
createIndicesBuffer(
|
|
75
|
+
createIndicesBuffer(data: spec.TypedArray): GLGPUBuffer;
|
|
77
76
|
flush(): void;
|
|
78
77
|
private processProps;
|
|
79
78
|
fromData(data: spec.GeometryData): void;
|
package/dist/gl-gpu-buffer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Disposable, spec } from '@galacean/effects-core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GLEngine } from './gl-engine';
|
|
3
3
|
type GPUBufferTarget = WebGLRenderingContext['ARRAY_BUFFER'] | WebGLRenderingContext['ELEMENT_ARRAY_BUFFER'] | WebGL2RenderingContext['COPY_READ_BUFFER'] | WebGL2RenderingContext['COPY_WRITE_BUFFER'] | WebGL2RenderingContext['TRANSFORM_FEEDBACK_BUFFER'] | WebGL2RenderingContext['UNIFORM_BUFFER'] | WebGL2RenderingContext['PIXEL_PACK_BUFFER'] | WebGL2RenderingContext['PIXEL_UNPACK_BUFFER'];
|
|
4
4
|
type GPUBufferType = WebGLRenderingContext['UNSIGNED_INT'] | WebGLRenderingContext['UNSIGNED_SHORT'] | WebGLRenderingContext['UNSIGNED_BYTE'] | WebGLRenderingContext['FLOAT'] | WebGLRenderingContext['INT'] | WebGLRenderingContext['SHORT'] | WebGLRenderingContext['BYTE'];
|
|
5
5
|
export interface GLGPUBufferProps {
|
|
@@ -14,7 +14,7 @@ export interface GLGPUBufferProps {
|
|
|
14
14
|
usage?: WebGLRenderingContext['STATIC_DRAW'] | WebGLRenderingContext['DYNAMIC_DRAW'];
|
|
15
15
|
}
|
|
16
16
|
export declare class GLGPUBuffer implements Disposable {
|
|
17
|
-
readonly
|
|
17
|
+
readonly engine: GLEngine;
|
|
18
18
|
readonly bytesPerElement: number;
|
|
19
19
|
readonly target: GPUBufferTarget;
|
|
20
20
|
readonly type: GPUBufferType;
|
|
@@ -22,7 +22,7 @@ export declare class GLGPUBuffer implements Disposable {
|
|
|
22
22
|
readonly glBuffer: WebGLBuffer | null;
|
|
23
23
|
private byteLength;
|
|
24
24
|
private destroyed;
|
|
25
|
-
constructor(
|
|
25
|
+
constructor(engine: GLEngine, props: GLGPUBufferProps);
|
|
26
26
|
get elementCount(): number;
|
|
27
27
|
get isDestroyed(): boolean;
|
|
28
28
|
private createGLBuffer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GLEngine } from './gl-engine';
|
|
2
2
|
export declare class GLMaterialState {
|
|
3
3
|
blending: boolean;
|
|
4
4
|
blendFunctionParameters: [blendSrc: GLenum, blendDst: GLenum, blendSrcAlpha: GLenum, blendDstAlpha: GLenum];
|
|
@@ -46,5 +46,5 @@ export declare class GLMaterialState {
|
|
|
46
46
|
setFrontFace(value: GLenum): void;
|
|
47
47
|
setCullFace(value: GLenum): void;
|
|
48
48
|
reset(): void;
|
|
49
|
-
apply(
|
|
49
|
+
apply(engine: GLEngine): void;
|
|
50
50
|
}
|
package/dist/gl-material.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Engine, GlobalUniforms,
|
|
1
|
+
import type { Engine, GlobalUniforms, MaterialProps, Renderer, Texture, UndefinedAble } from '@galacean/effects-core';
|
|
2
2
|
import { spec, Material, math } from '@galacean/effects-core';
|
|
3
|
-
import type {
|
|
3
|
+
import type { GLEngine } from './gl-engine';
|
|
4
4
|
type Color = math.Color;
|
|
5
5
|
type Vector2 = math.Vector2;
|
|
6
6
|
type Vector3 = math.Vector3;
|
|
@@ -80,7 +80,7 @@ export declare class GLMaterial extends Material {
|
|
|
80
80
|
/**shader和texture的GPU资源初始化。 */
|
|
81
81
|
initialize(): void;
|
|
82
82
|
createShaderVariant(): void;
|
|
83
|
-
setupStates(
|
|
83
|
+
setupStates(engine: GLEngine): void;
|
|
84
84
|
use(renderer: Renderer, globalUniforms?: GlobalUniforms): void;
|
|
85
85
|
getFloat(name: string): number | null;
|
|
86
86
|
setFloat(name: string, value: number): void;
|
|
@@ -119,6 +119,6 @@ export declare class GLMaterial extends Material {
|
|
|
119
119
|
toData(): spec.MaterialData;
|
|
120
120
|
cloneUniforms(sourceMaterial: Material): void;
|
|
121
121
|
private checkUniform;
|
|
122
|
-
dispose(
|
|
122
|
+
dispose(): void;
|
|
123
123
|
}
|
|
124
124
|
export {};
|
package/dist/gl-program.d.ts
CHANGED
|
@@ -21,9 +21,7 @@ export declare class GLProgram implements Disposable {
|
|
|
21
21
|
engine: GLEngine;
|
|
22
22
|
readonly program: WebGLProgram;
|
|
23
23
|
private readonly id;
|
|
24
|
-
private readonly uniformBlockMap;
|
|
25
24
|
private attribInfoMap;
|
|
26
|
-
private pipelineContext;
|
|
27
25
|
constructor(engine: GLEngine, program: WebGLProgram, id: string);
|
|
28
26
|
bind(): void;
|
|
29
27
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Disposable, LostHandler, Material, Geometry } from '@galacean/effects-core';
|
|
2
2
|
import type { GLFramebuffer } from './gl-framebuffer';
|
|
3
3
|
import type { GLGPUBuffer } from './gl-gpu-buffer';
|
|
4
|
-
import type { GLPipelineContext } from './gl-pipeline-context';
|
|
5
4
|
import type { GLRenderbuffer } from './gl-renderbuffer';
|
|
6
5
|
import { GLTexture } from './gl-texture';
|
|
7
6
|
import { GLVertexArrayObject } from './gl-vertex-array-object';
|
|
@@ -10,7 +9,6 @@ export declare class GLRendererInternal implements Disposable, LostHandler {
|
|
|
10
9
|
engine: GLEngine;
|
|
11
10
|
emptyTexture2D: GLTexture;
|
|
12
11
|
emptyTextureCube: GLTexture;
|
|
13
|
-
pipelineContext: GLPipelineContext;
|
|
14
12
|
gl: WebGLRenderingContext | WebGL2RenderingContext;
|
|
15
13
|
readonly name: string;
|
|
16
14
|
readonly textures: GLTexture[];
|
package/dist/gl-renderer.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Disposable, Framebuffer, GLType, Geometry, LostHandler, Material, RenderFrame, RenderPass, RenderPassClearAction, RenderPassStoreAction, RendererComponent, RestoreHandler, ShaderLibrary } from '@galacean/effects-core';
|
|
2
|
-
import { FilterMode, RenderTextureFormat, Renderer
|
|
1
|
+
import type { Disposable, Framebuffer, GLType, Geometry, LostHandler, Material, RenderFrame, RenderPass, RenderPassClearAction, RenderPassStoreAction, RendererComponent, RestoreHandler, ShaderLibrary, math } from '@galacean/effects-core';
|
|
2
|
+
import { FilterMode, RenderTextureFormat, Renderer } from '@galacean/effects-core';
|
|
3
3
|
import { ExtWrap } from './ext-wrap';
|
|
4
4
|
import { GLContextManager } from './gl-context-manager';
|
|
5
|
-
import { GLPipelineContext } from './gl-pipeline-context';
|
|
6
5
|
import { GLRendererInternal } from './gl-renderer-internal';
|
|
7
6
|
type Matrix4 = math.Matrix4;
|
|
8
7
|
type Vector4 = math.Vector4;
|
|
@@ -13,7 +12,6 @@ export declare class GLRenderer extends Renderer implements Disposable {
|
|
|
13
12
|
extension: ExtWrap;
|
|
14
13
|
framebuffer: Framebuffer;
|
|
15
14
|
temporaryRTs: Record<string, Framebuffer>;
|
|
16
|
-
pipelineContext: GLPipelineContext;
|
|
17
15
|
readonly context: GLContextManager;
|
|
18
16
|
constructor(canvas: HTMLCanvasElement | OffscreenCanvas, framework: GLType, renderOptions?: WebGLContextAttributes);
|
|
19
17
|
get isDestroyed(): boolean;
|
|
@@ -28,7 +26,7 @@ export declare class GLRenderer extends Renderer implements Disposable {
|
|
|
28
26
|
setGlobalInt(name: string, value: number): void;
|
|
29
27
|
setGlobalMatrix(name: string, value: Matrix4): void;
|
|
30
28
|
setGlobalVector3(name: string, value: Vector3): void;
|
|
31
|
-
drawGeometry(geometry: Geometry, material: Material, subMeshIndex?: number): void;
|
|
29
|
+
drawGeometry(geometry: Geometry, matrix: Matrix4, material: Material, subMeshIndex?: number): void;
|
|
32
30
|
setFramebuffer(framebuffer: Framebuffer | null): void;
|
|
33
31
|
getFramebuffer(): Framebuffer;
|
|
34
32
|
getTemporaryRT(name: string, width: number, height: number, depthBuffer: number, filter: FilterMode, format: RenderTextureFormat): Framebuffer;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { Disposable, RestoreHandler, ShaderCompileResult, ShaderLibrary, ShaderMacros, ShaderWithSource } from '@galacean/effects-core';
|
|
2
2
|
import { GLShaderVariant } from './gl-shader';
|
|
3
|
-
import type { GLPipelineContext } from './gl-pipeline-context';
|
|
4
3
|
import type { GLEngine } from './gl-engine';
|
|
5
4
|
export declare class GLShaderLibrary implements ShaderLibrary, Disposable, RestoreHandler {
|
|
6
5
|
engine: GLEngine;
|
|
7
|
-
pipelineContext: GLPipelineContext;
|
|
8
6
|
readonly shaderResults: Record<string, ShaderCompileResult>;
|
|
9
7
|
private readonly glAsyncCompileExt;
|
|
10
8
|
private programMap;
|
|
@@ -12,7 +10,7 @@ export declare class GLShaderLibrary implements ShaderLibrary, Disposable, Resto
|
|
|
12
10
|
private glFragShaderMap;
|
|
13
11
|
private shaderAllDone;
|
|
14
12
|
private cachedShaders;
|
|
15
|
-
constructor(engine: GLEngine
|
|
13
|
+
constructor(engine: GLEngine);
|
|
16
14
|
compileAllShaders(asyncCallback?: (results: ShaderCompileResult[]) => void): void;
|
|
17
15
|
addShader(shaderSource: ShaderWithSource, macros?: ShaderMacros): string;
|
|
18
16
|
createShader(shaderSource: ShaderWithSource, macros?: ShaderMacros): GLShaderVariant;
|
|
@@ -24,3 +22,4 @@ export declare class GLShaderLibrary implements ShaderLibrary, Disposable, Resto
|
|
|
24
22
|
restore(): void;
|
|
25
23
|
dispose(): void;
|
|
26
24
|
}
|
|
25
|
+
export declare function stringHash(...strings: string[]): number;
|
package/dist/gl-shader.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ShaderCompileResult, ShaderWithSource, Texture, Engine, math } from '@galacean/effects-core';
|
|
2
2
|
import { ShaderVariant } from '@galacean/effects-core';
|
|
3
3
|
import type { GLProgram } from './gl-program';
|
|
4
|
-
import type { GLPipelineContext } from './gl-pipeline-context';
|
|
5
4
|
type Color = math.Color;
|
|
6
5
|
type Vector2 = math.Vector2;
|
|
7
6
|
type Vector3 = math.Vector3;
|
|
@@ -10,7 +9,6 @@ type Matrix3 = math.Matrix3;
|
|
|
10
9
|
type Matrix4 = math.Matrix4;
|
|
11
10
|
type Quaternion = math.Quaternion;
|
|
12
11
|
export declare class GLShaderVariant extends ShaderVariant {
|
|
13
|
-
pipelineContext: GLPipelineContext;
|
|
14
12
|
program: GLProgram;
|
|
15
13
|
compileResult: ShaderCompileResult;
|
|
16
14
|
id: string;
|
package/dist/gl-texture.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Texture } from '@galacean/effects-core';
|
|
|
3
3
|
export declare class GLTexture extends Texture implements Disposable, RestoreHandler {
|
|
4
4
|
textureBuffer: WebGLTexture | null;
|
|
5
5
|
target: GLenum;
|
|
6
|
-
private pipelineContext;
|
|
7
6
|
private initialized;
|
|
8
7
|
constructor(engine: Engine, source?: TextureSourceOptions);
|
|
9
8
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export * from './gl-texture';
|
|
|
7
7
|
export * from './gl-framebuffer';
|
|
8
8
|
export * from './gl-gpu-buffer';
|
|
9
9
|
export * from './gl-vertex-array-object';
|
|
10
|
-
export * from './gl-pipeline-context';
|
|
11
10
|
export * from './gl-shader-library';
|
|
12
11
|
export * from './gl-engine';
|
|
13
12
|
export * from './gl-shader';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/effects-webgl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0-alpha.1",
|
|
4
4
|
"description": "Galacean Effects runtime webgl for the web",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"registry": "https://registry.npmjs.org"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@galacean/effects-core": "2.
|
|
41
|
+
"@galacean/effects-core": "2.7.0-alpha.1"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"prebuild": "pnpm clean",
|
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
import type { Disposable, Nullable, Texture, math } from '@galacean/effects-core';
|
|
2
|
-
import { GLShaderLibrary } from './gl-shader-library';
|
|
3
|
-
import type { GLEngine } from './gl-engine';
|
|
4
|
-
type Color = math.Color;
|
|
5
|
-
type Vector2 = math.Vector2;
|
|
6
|
-
type Vector3 = math.Vector3;
|
|
7
|
-
type Vector4 = math.Vector4;
|
|
8
|
-
type Matrix3 = math.Matrix3;
|
|
9
|
-
type Matrix4 = math.Matrix4;
|
|
10
|
-
type Quaternion = math.Quaternion;
|
|
11
|
-
export declare class GLPipelineContext implements Disposable {
|
|
12
|
-
engine: GLEngine;
|
|
13
|
-
gl: WebGLRenderingContext | WebGL2RenderingContext;
|
|
14
|
-
textureUnitDict: Record<string, WebGLTexture | null>;
|
|
15
|
-
shaderLibrary: GLShaderLibrary;
|
|
16
|
-
private readonly maxTextureCount;
|
|
17
|
-
private glCapabilityCache;
|
|
18
|
-
private currentFramebuffer;
|
|
19
|
-
private currentTextureBinding;
|
|
20
|
-
private currentRenderbuffer;
|
|
21
|
-
private activeTextureIndex;
|
|
22
|
-
private pixelStorei;
|
|
23
|
-
constructor(engine: GLEngine, gl: WebGLRenderingContext | WebGL2RenderingContext);
|
|
24
|
-
dispose(): void;
|
|
25
|
-
private reset;
|
|
26
|
-
toggle(capability: GLenum, enable?: boolean): void;
|
|
27
|
-
/**
|
|
28
|
-
* 对于该上下文开启某种特性
|
|
29
|
-
* @param capability
|
|
30
|
-
* example:
|
|
31
|
-
* gl.enable(gl.DITHER);
|
|
32
|
-
*/
|
|
33
|
-
enable(capability: GLenum): void;
|
|
34
|
-
/**
|
|
35
|
-
* 基于某种上下文关闭特性
|
|
36
|
-
* @param capability
|
|
37
|
-
* example:
|
|
38
|
-
* gl.disable(gl.DITHER);
|
|
39
|
-
*/
|
|
40
|
-
disable(capability: GLenum): void;
|
|
41
|
-
/**
|
|
42
|
-
* 绑定framebuffer webgl2新增: gl.DRAW_FRAMEBUFFER 和 gl.READ_FRAMEBUFFER
|
|
43
|
-
* @param target
|
|
44
|
-
* @param framebuffer
|
|
45
|
-
* example:
|
|
46
|
-
* const framebuffer = gl.createFramebuffer();
|
|
47
|
-
* gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
48
|
-
*/
|
|
49
|
-
bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer | null): void;
|
|
50
|
-
bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer | null): void;
|
|
51
|
-
/**
|
|
52
|
-
* 绑定系统 framebuffer
|
|
53
|
-
*/
|
|
54
|
-
bindSystemFramebuffer(): void;
|
|
55
|
-
/**
|
|
56
|
-
* 将定义好的 WebGLProgram 对象添加到当前的渲染状态中。
|
|
57
|
-
* @param program
|
|
58
|
-
* example:
|
|
59
|
-
* gl.useProgram(program);
|
|
60
|
-
* gl.useProgram(null);
|
|
61
|
-
*/
|
|
62
|
-
useProgram(program: WebGLProgram | null): void;
|
|
63
|
-
/**
|
|
64
|
-
* 使用预设值来清空缓冲
|
|
65
|
-
* @param mask
|
|
66
|
-
* example:
|
|
67
|
-
* gl.clear(gl.DEPTH_BUFFER_BIT);
|
|
68
|
-
* gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT);
|
|
69
|
-
*/
|
|
70
|
-
clear(mask: number): void;
|
|
71
|
-
/*** depth start ***/
|
|
72
|
-
/**
|
|
73
|
-
* 设置深度缓冲区的深度清除值
|
|
74
|
-
* @param depth
|
|
75
|
-
* example:
|
|
76
|
-
* gl.clearDepth(0.5);
|
|
77
|
-
*/
|
|
78
|
-
clearDepth(depth: GLclampf): void;
|
|
79
|
-
/**
|
|
80
|
-
* 指定将输入像素深度与当前深度缓冲区值进行比较的函数。
|
|
81
|
-
* @param func
|
|
82
|
-
* example:
|
|
83
|
-
* gl.enable(gl.DEPTH_TEST);
|
|
84
|
-
* gl.depthFunc(gl.NEVER);
|
|
85
|
-
*/
|
|
86
|
-
depthFunc(func: GLenum): void;
|
|
87
|
-
/**
|
|
88
|
-
* 设置是否启用写入深度缓冲。
|
|
89
|
-
* @param flag
|
|
90
|
-
* example:
|
|
91
|
-
* gl.depthMask(false);
|
|
92
|
-
*/
|
|
93
|
-
depthMask(flag: boolean): void;
|
|
94
|
-
polygonOffset(factor: number, unit: number): void;
|
|
95
|
-
/**
|
|
96
|
-
* 将 z 值从规范化设备坐标映射到窗口坐标
|
|
97
|
-
* @param zNear
|
|
98
|
-
* @param zFar
|
|
99
|
-
* example:
|
|
100
|
-
* gl.depthRange(0.2, 0.6);
|
|
101
|
-
*/
|
|
102
|
-
depthRange(zNear: number, zFar: number): void;
|
|
103
|
-
/*** depth end ***/
|
|
104
|
-
/*** stencil start ***/
|
|
105
|
-
/**
|
|
106
|
-
* 模版测试设置函数和引用值。
|
|
107
|
-
* @param func
|
|
108
|
-
* @param ref
|
|
109
|
-
* @param mask
|
|
110
|
-
* example:
|
|
111
|
-
* gl.enable(gl.STENCIL_TEST);
|
|
112
|
-
* gl.stencilFunc(gl.LESS, 0, 0b1110011);
|
|
113
|
-
*/
|
|
114
|
-
clearStencil(s: GLint): void;
|
|
115
|
-
/**
|
|
116
|
-
* 控制启用和禁用模板平面中单个位的正面和背面写入
|
|
117
|
-
* @param mask
|
|
118
|
-
* example:
|
|
119
|
-
* gl.stencilMask(0xff);
|
|
120
|
-
*/
|
|
121
|
-
stencilMask(mask: number): void;
|
|
122
|
-
/**
|
|
123
|
-
* 模版测试设置函数和引用值。
|
|
124
|
-
* @param func
|
|
125
|
-
* @param ref
|
|
126
|
-
* @param mask
|
|
127
|
-
* example:
|
|
128
|
-
* gl.enable(gl.STENCIL_TEST);
|
|
129
|
-
* gl.stencilFunc(gl.LESS, 0, 0b1110011);
|
|
130
|
-
*/
|
|
131
|
-
stencilFunc(func: GLenum, ref: GLint, mask: GLuint): void;
|
|
132
|
-
/**
|
|
133
|
-
* 单面模版测试
|
|
134
|
-
* @param face
|
|
135
|
-
* @param func
|
|
136
|
-
* @param ref
|
|
137
|
-
* @param mask
|
|
138
|
-
* example:
|
|
139
|
-
* gl.enable(gl.STENCIL_TEST);
|
|
140
|
-
* gl.stencilFuncSeparate(gl.FRONT, gl.LESS, 0.2, 1110011);
|
|
141
|
-
*/
|
|
142
|
-
stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint): void;
|
|
143
|
-
/**
|
|
144
|
-
* 单面的mask写入
|
|
145
|
-
* @param face
|
|
146
|
-
* @param mask
|
|
147
|
-
* example:
|
|
148
|
-
* gl.stencilMaskSeparate(gl.FRONT, 110101);
|
|
149
|
-
*/
|
|
150
|
-
stencilMaskSeparate(face: GLenum, mask: GLuint): void;
|
|
151
|
-
/**
|
|
152
|
-
* 设置正面和背面模板测试操作
|
|
153
|
-
* @param fail
|
|
154
|
-
* @param zfail
|
|
155
|
-
* @param zpass
|
|
156
|
-
* example:
|
|
157
|
-
* gl.enable(gl.STENCIL_TEST);
|
|
158
|
-
* gl.stencilOp(gl.INCR, gl.DECR, gl.INVERT);
|
|
159
|
-
*/
|
|
160
|
-
stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum): void;
|
|
161
|
-
/**
|
|
162
|
-
* 设置正面和/或背面模板测试操作
|
|
163
|
-
* @param face
|
|
164
|
-
* @param fail
|
|
165
|
-
* @param zfail
|
|
166
|
-
* @param zpass
|
|
167
|
-
* example:
|
|
168
|
-
* gl.enable(gl.STENCIL_TEST);
|
|
169
|
-
* gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl.INVERT);
|
|
170
|
-
*/
|
|
171
|
-
stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum): void;
|
|
172
|
-
/*** stencil end ***/
|
|
173
|
-
/*** face start ***/
|
|
174
|
-
/**
|
|
175
|
-
* 剔除方式
|
|
176
|
-
* @param mode
|
|
177
|
-
* example:
|
|
178
|
-
* gl.enable(gl.CULL_FACE);
|
|
179
|
-
* gl.cullFace(gl.FRONT_AND_BACK);
|
|
180
|
-
*/
|
|
181
|
-
cullFace(mode: GLenum): void;
|
|
182
|
-
/**
|
|
183
|
-
* 设置卷绕方向
|
|
184
|
-
* @param mode
|
|
185
|
-
* example:
|
|
186
|
-
* gl.frontFace(gl.CW);
|
|
187
|
-
*/
|
|
188
|
-
frontFace(mode: GLenum): void;
|
|
189
|
-
/*** face end ***/
|
|
190
|
-
/*** color start ***/
|
|
191
|
-
/**
|
|
192
|
-
* 设置颜色写入
|
|
193
|
-
* @param red
|
|
194
|
-
* @param green
|
|
195
|
-
* @param blue
|
|
196
|
-
* @param alpha
|
|
197
|
-
* example:
|
|
198
|
-
* gl.colorMask(true, true, true, false);
|
|
199
|
-
*/
|
|
200
|
-
clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void;
|
|
201
|
-
/**
|
|
202
|
-
* 设置颜色写入
|
|
203
|
-
* @param red
|
|
204
|
-
* @param green
|
|
205
|
-
* @param blue
|
|
206
|
-
* @param alpha
|
|
207
|
-
* example:
|
|
208
|
-
* gl.colorMask(true, true, true, false);
|
|
209
|
-
*/
|
|
210
|
-
colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void;
|
|
211
|
-
/**
|
|
212
|
-
* 设置源和目标混合因子
|
|
213
|
-
* @param red
|
|
214
|
-
* @param green
|
|
215
|
-
* @param blue
|
|
216
|
-
* @param alpha
|
|
217
|
-
* example:
|
|
218
|
-
* gl.blendColor(0, 0.5, 1, 1);
|
|
219
|
-
*/
|
|
220
|
-
blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void;
|
|
221
|
-
/**
|
|
222
|
-
* 用于混合像素算法
|
|
223
|
-
* @param sfactor
|
|
224
|
-
* @param dfactor
|
|
225
|
-
* example:
|
|
226
|
-
* gl.enable(gl.BLEND);
|
|
227
|
-
* gl.blendFunc(gl.SRC_COLOR, gl.DST_COLOR);
|
|
228
|
-
*/
|
|
229
|
-
blendFunc(sfactor: GLenum, dfactor: GLenum): void;
|
|
230
|
-
/**
|
|
231
|
-
* 分别设置应用在 RGB 和 Alpha 上的 factor
|
|
232
|
-
* @param srcRGB
|
|
233
|
-
* @param dstRGB
|
|
234
|
-
* @param srcAlpha
|
|
235
|
-
* @param dstAlpha
|
|
236
|
-
* example:
|
|
237
|
-
* gl.enable(gl.BLEND);
|
|
238
|
-
* gl.blendFuncSeparate(gl.SRC_COLOR, gl.DST_COLOR, gl.ONE, gl.ZERO);
|
|
239
|
-
*/
|
|
240
|
-
blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum): void;
|
|
241
|
-
/**
|
|
242
|
-
* 设置混合模式
|
|
243
|
-
* @param mode
|
|
244
|
-
* example:
|
|
245
|
-
* gl.blendEquation(gl.FUNC_ADD);
|
|
246
|
-
* gl.blendEquation(gl.FUNC_SUBTRACT);
|
|
247
|
-
* gl.blendEquation(gl.FUNC_REVERSE_SUBTRACT);
|
|
248
|
-
*/
|
|
249
|
-
blendEquation(mode: GLenum): void;
|
|
250
|
-
/**
|
|
251
|
-
* 可以分别对 RGB 和 Alpha 做不同的操作处理
|
|
252
|
-
* @param modeRGB
|
|
253
|
-
* @param modeAlpha
|
|
254
|
-
* example:
|
|
255
|
-
* gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_SUBTRACT);
|
|
256
|
-
*/
|
|
257
|
-
blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum): void;
|
|
258
|
-
/*** color end ***/
|
|
259
|
-
/**
|
|
260
|
-
* 图像预处理
|
|
261
|
-
* @param pname
|
|
262
|
-
* @param param
|
|
263
|
-
* example:
|
|
264
|
-
* var tex = gl.createTexture();
|
|
265
|
-
* gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
266
|
-
* gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
|
|
267
|
-
*/
|
|
268
|
-
setPixelStorei(pname: GLenum, param: GLenum): void;
|
|
269
|
-
/**
|
|
270
|
-
* 用来设置视口,即指定从标准设备到窗口坐标的x、y仿射变换。
|
|
271
|
-
* @param x
|
|
272
|
-
* @param y
|
|
273
|
-
* @param width
|
|
274
|
-
* @param height
|
|
275
|
-
* example:
|
|
276
|
-
* gl.viewport(0, 0, width, height);
|
|
277
|
-
*/
|
|
278
|
-
viewport(x: number, y: number, width: number, height: number): void;
|
|
279
|
-
/**
|
|
280
|
-
* 激活指定的纹理单元
|
|
281
|
-
* @param texture
|
|
282
|
-
* example:
|
|
283
|
-
* gl.activeTexture(gl.TEXTURE1);
|
|
284
|
-
*/
|
|
285
|
-
activeTexture(texture: GLenum): void;
|
|
286
|
-
/**
|
|
287
|
-
* 绑定WebGLTexture
|
|
288
|
-
* @param target
|
|
289
|
-
* @param texture
|
|
290
|
-
* @param force
|
|
291
|
-
* example:
|
|
292
|
-
* const texture = gl.createTexture();
|
|
293
|
-
* gl.bindTexture(gl.TEXTURE_2D, texture)
|
|
294
|
-
*/
|
|
295
|
-
bindTexture(target: GLenum, texture: WebGLTexture | null, force?: boolean): void;
|
|
296
|
-
private set1;
|
|
297
|
-
private set2;
|
|
298
|
-
private set3;
|
|
299
|
-
private set4;
|
|
300
|
-
get(name: string): any;
|
|
301
|
-
setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
|
|
302
|
-
setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
|
|
303
|
-
setFloats(uniform: Nullable<WebGLUniformLocation>, value: number[]): void;
|
|
304
|
-
setVector2(uniform: Nullable<WebGLUniformLocation>, value: Vector2): void;
|
|
305
|
-
setVector3(uniform: Nullable<WebGLUniformLocation>, value: Vector3): void;
|
|
306
|
-
setVector4(uniform: Nullable<WebGLUniformLocation>, value: Vector4): void;
|
|
307
|
-
setColor(uniform: Nullable<WebGLUniformLocation>, value: Color): void;
|
|
308
|
-
setQuaternion(uniform: Nullable<WebGLUniformLocation>, value: Quaternion): void;
|
|
309
|
-
setVector4Array(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
|
|
310
|
-
setMatrix(uniform: Nullable<WebGLUniformLocation>, value: Matrix4): void;
|
|
311
|
-
setMatrix3(uniform: Nullable<WebGLUniformLocation>, value: Matrix3): void;
|
|
312
|
-
setMatrixArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
|
|
313
|
-
setTexture(uniform: Nullable<WebGLUniformLocation>, channel: number, texture: Texture): void;
|
|
314
|
-
/**
|
|
315
|
-
* 查询所有uniform的location。
|
|
316
|
-
* @param program 查询的shader program
|
|
317
|
-
* @param uniformsNames 查询的uniform名称列表
|
|
318
|
-
* @returns
|
|
319
|
-
*/
|
|
320
|
-
getUniforms(program: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
|
|
321
|
-
private setFloat4;
|
|
322
|
-
private setFloat3;
|
|
323
|
-
private setFloat2;
|
|
324
|
-
}
|
|
325
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Disposable, UniformValue, spec } from '@galacean/effects-core';
|
|
2
|
-
import { GLGPUBuffer } from './gl-gpu-buffer';
|
|
3
|
-
import type { GLPipelineContext } from './gl-pipeline-context';
|
|
4
|
-
type BlockUniformInfo = [
|
|
5
|
-
type: number,
|
|
6
|
-
offset: number,
|
|
7
|
-
size: number,
|
|
8
|
-
blockIndex: number,
|
|
9
|
-
arrayStride: number,
|
|
10
|
-
maxStride: number,
|
|
11
|
-
rowMajor: number,
|
|
12
|
-
index: number,
|
|
13
|
-
byteLength: number
|
|
14
|
-
];
|
|
15
|
-
export interface UniformBlockSpec {
|
|
16
|
-
index: number;
|
|
17
|
-
usedByVertexShader: boolean;
|
|
18
|
-
usedByFragmentShader: boolean;
|
|
19
|
-
size: number;
|
|
20
|
-
uniformIndices: number[];
|
|
21
|
-
used: boolean;
|
|
22
|
-
name: string;
|
|
23
|
-
uniforms: Record<string, BlockUniformInfo>;
|
|
24
|
-
id: string;
|
|
25
|
-
}
|
|
26
|
-
interface UBODirtyFlag {
|
|
27
|
-
start: number;
|
|
28
|
-
dirty: boolean;
|
|
29
|
-
buffer?: spec.TypedArray;
|
|
30
|
-
}
|
|
31
|
-
export declare class UniformBlockBuffer implements Disposable {
|
|
32
|
-
private readonly info;
|
|
33
|
-
buffer?: GLGPUBuffer;
|
|
34
|
-
dirtyFlags: Record<string, UBODirtyFlag>;
|
|
35
|
-
keepData: boolean;
|
|
36
|
-
constructor(pipelineContext: GLPipelineContext, info: UniformBlockSpec);
|
|
37
|
-
setValues(uniformValues: Record<string, UniformValue>, dirtyFlags: Record<string, boolean>, uniformValueOffsets: Record<string, spec.vec2>): void;
|
|
38
|
-
bind(gl: WebGL2RenderingContext, program: WebGLProgram, bufferBindIndex: number): void;
|
|
39
|
-
dispose(): void;
|
|
40
|
-
}
|
|
41
|
-
export declare function createUniformBlockDataFromProgram(gl: WebGL2RenderingContext, program: WebGLProgram): {
|
|
42
|
-
blockSpecs: UniformBlockSpec[];
|
|
43
|
-
blockUniformNames: string[];
|
|
44
|
-
};
|
|
45
|
-
export declare function stringHash(...strings: string[]): number;
|
|
46
|
-
export {};
|