@galacean/engine-rhi-webgl 1.2.0-alpha.13 → 1.2.0-alpha.15
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/main.js +38 -40
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +38 -40
- package/dist/module.js +39 -41
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/GLRenderTarget.d.ts +3 -2
- package/types/WebGLGraphicDevice.d.ts +5 -3
package/dist/main.js
CHANGED
|
@@ -1077,7 +1077,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1077
1077
|
* @internal
|
|
1078
1078
|
*/ GLTexture._getRenderBufferDepthFormatDetail = function _getRenderBufferDepthFormatDetail(format, gl, isWebGL2) {
|
|
1079
1079
|
switch(format){
|
|
1080
|
-
case engineCore.
|
|
1080
|
+
case engineCore.TextureFormat.Depth:
|
|
1081
1081
|
return {
|
|
1082
1082
|
internalFormat: isWebGL2 ? gl.DEPTH_COMPONENT32F : gl.DEPTH_COMPONENT16,
|
|
1083
1083
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1085,7 +1085,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1085
1085
|
isCompressed: false,
|
|
1086
1086
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1087
1087
|
};
|
|
1088
|
-
case engineCore.
|
|
1088
|
+
case engineCore.TextureFormat.DepthStencil:
|
|
1089
1089
|
return {
|
|
1090
1090
|
internalFormat: isWebGL2 ? gl.DEPTH32F_STENCIL8 : gl.DEPTH_STENCIL,
|
|
1091
1091
|
baseFormat: gl.DEPTH_STENCIL,
|
|
@@ -1093,7 +1093,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1093
1093
|
isCompressed: false,
|
|
1094
1094
|
attachment: gl.DEPTH_STENCIL_ATTACHMENT
|
|
1095
1095
|
};
|
|
1096
|
-
case engineCore.
|
|
1096
|
+
case engineCore.TextureFormat.Stencil:
|
|
1097
1097
|
return {
|
|
1098
1098
|
internalFormat: gl.STENCIL_INDEX8,
|
|
1099
1099
|
baseFormat: gl.STENCIL_ATTACHMENT,
|
|
@@ -1101,7 +1101,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1101
1101
|
isCompressed: false,
|
|
1102
1102
|
attachment: gl.STENCIL_ATTACHMENT
|
|
1103
1103
|
};
|
|
1104
|
-
case engineCore.
|
|
1104
|
+
case engineCore.TextureFormat.Depth16:
|
|
1105
1105
|
return {
|
|
1106
1106
|
internalFormat: gl.DEPTH_COMPONENT16,
|
|
1107
1107
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1109,7 +1109,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1109
1109
|
isCompressed: false,
|
|
1110
1110
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1111
1111
|
};
|
|
1112
|
-
case engineCore.
|
|
1112
|
+
case engineCore.TextureFormat.Depth24Stencil8:
|
|
1113
1113
|
return {
|
|
1114
1114
|
internalFormat: isWebGL2 ? gl.DEPTH24_STENCIL8 : gl.DEPTH_STENCIL,
|
|
1115
1115
|
baseFormat: gl.DEPTH_STENCIL,
|
|
@@ -1117,7 +1117,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1117
1117
|
isCompressed: false,
|
|
1118
1118
|
attachment: gl.DEPTH_STENCIL_ATTACHMENT
|
|
1119
1119
|
};
|
|
1120
|
-
case engineCore.
|
|
1120
|
+
case engineCore.TextureFormat.Depth24:
|
|
1121
1121
|
return {
|
|
1122
1122
|
internalFormat: gl.DEPTH_COMPONENT24,
|
|
1123
1123
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1125,7 +1125,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1125
1125
|
isCompressed: false,
|
|
1126
1126
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1127
1127
|
};
|
|
1128
|
-
case engineCore.
|
|
1128
|
+
case engineCore.TextureFormat.Depth32:
|
|
1129
1129
|
return {
|
|
1130
1130
|
internalFormat: gl.DEPTH_COMPONENT32F,
|
|
1131
1131
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1133,7 +1133,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1133
1133
|
isCompressed: false,
|
|
1134
1134
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1135
1135
|
};
|
|
1136
|
-
case engineCore.
|
|
1136
|
+
case engineCore.TextureFormat.Depth32Stencil8:
|
|
1137
1137
|
return {
|
|
1138
1138
|
internalFormat: gl.DEPTH32F_STENCIL8,
|
|
1139
1139
|
baseFormat: gl.DEPTH_STENCIL,
|
|
@@ -1203,9 +1203,9 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1203
1203
|
*/ GLTexture._supportRenderBufferDepthFormat = function _supportRenderBufferDepthFormat(format, rhi) {
|
|
1204
1204
|
if (!rhi.isWebGL2) {
|
|
1205
1205
|
switch(format){
|
|
1206
|
-
case engineCore.
|
|
1207
|
-
case engineCore.
|
|
1208
|
-
case engineCore.
|
|
1206
|
+
case engineCore.TextureFormat.Depth24:
|
|
1207
|
+
case engineCore.TextureFormat.Depth32:
|
|
1208
|
+
case engineCore.TextureFormat.Depth32Stencil8:
|
|
1209
1209
|
return false;
|
|
1210
1210
|
}
|
|
1211
1211
|
}
|
|
@@ -1308,6 +1308,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1308
1308
|
function GLRenderTarget(rhi, target) {
|
|
1309
1309
|
this._MSAAColorRenderBuffers = [];
|
|
1310
1310
|
this._curMipLevel = 0;
|
|
1311
|
+
this._curFaceIndex = undefined;
|
|
1311
1312
|
this._gl = rhi.gl;
|
|
1312
1313
|
this._isWebGL2 = rhi.isWebGL2;
|
|
1313
1314
|
this._target = target;
|
|
@@ -1359,21 +1360,23 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1359
1360
|
var _proto = GLRenderTarget.prototype;
|
|
1360
1361
|
/**
|
|
1361
1362
|
* Set which face and mipLevel of the cube texture to render to.
|
|
1362
|
-
* @param faceIndex - Cube texture face
|
|
1363
1363
|
* @param mipLevel - Set mip level the data want to write
|
|
1364
|
-
|
|
1364
|
+
* @param faceIndex - Cube texture face
|
|
1365
|
+
*/ _proto.activeRenderTarget = function activeRenderTarget(mipLevel, faceIndex) {
|
|
1366
|
+
// @todo: support MRT
|
|
1365
1367
|
var _this = this, gl = _this._gl, target = _this._target;
|
|
1366
|
-
var depthTexture = target.depthTexture;
|
|
1367
|
-
var colorTexture = target.getColorTexture(0);
|
|
1368
|
-
var mipChanged = mipLevel !== this._curMipLevel;
|
|
1369
1368
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
1369
|
+
var mipChanged = mipLevel !== this._curMipLevel;
|
|
1370
|
+
var faceChanged = faceIndex !== this._curFaceIndex;
|
|
1371
|
+
var colorTexture = target.getColorTexture(0);
|
|
1370
1372
|
if (colorTexture) {
|
|
1371
1373
|
var isCube = _instanceof(colorTexture, engineCore.TextureCube);
|
|
1372
|
-
if (mipChanged || isCube) {
|
|
1374
|
+
if (mipChanged || isCube && faceChanged) {
|
|
1373
1375
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, isCube ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, // @ts-ignore
|
|
1374
1376
|
colorTexture._platformTexture._glTexture, mipLevel);
|
|
1375
1377
|
}
|
|
1376
1378
|
}
|
|
1379
|
+
var depthTexture = target.depthTexture;
|
|
1377
1380
|
if (depthTexture) {
|
|
1378
1381
|
var isCube1 = _instanceof(depthTexture, engineCore.TextureCube);
|
|
1379
1382
|
if (mipChanged || isCube1) {
|
|
@@ -1390,8 +1393,10 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1390
1393
|
}
|
|
1391
1394
|
}
|
|
1392
1395
|
this._curMipLevel = mipLevel;
|
|
1393
|
-
|
|
1394
|
-
this.
|
|
1396
|
+
this._curFaceIndex = faceIndex;
|
|
1397
|
+
if (this._MSAAFrameBuffer) {
|
|
1398
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
|
|
1399
|
+
}
|
|
1395
1400
|
};
|
|
1396
1401
|
/**
|
|
1397
1402
|
* Blit FBO.
|
|
@@ -1429,20 +1434,6 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1429
1434
|
this._MSAAColorRenderBuffers.length = 0;
|
|
1430
1435
|
this._MSAADepthRenderBuffer = null;
|
|
1431
1436
|
};
|
|
1432
|
-
/**
|
|
1433
|
-
* Activate this RenderTarget.
|
|
1434
|
-
* @internal
|
|
1435
|
-
* @remarks
|
|
1436
|
-
* If MSAA is turned on, MSAA FBO is activated, and then this._blitRenderTarget() is performed to exchange FBO.
|
|
1437
|
-
* If MSAA is not turned on, activate the main FBO.
|
|
1438
|
-
*/ _proto._activeRenderTarget = function _activeRenderTarget() {
|
|
1439
|
-
var gl = this._gl;
|
|
1440
|
-
if (this._MSAAFrameBuffer) {
|
|
1441
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
|
|
1442
|
-
} else {
|
|
1443
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
1444
|
-
}
|
|
1445
|
-
};
|
|
1446
1437
|
_proto._bindMainFBO = function _bindMainFBO() {
|
|
1447
1438
|
var gl = this._gl;
|
|
1448
1439
|
var isWebGL2 = this._isWebGL2;
|
|
@@ -1917,23 +1908,30 @@ exports.WebGLMode = void 0;
|
|
|
1917
1908
|
engineCore.Logger.error("draw primitive failed.");
|
|
1918
1909
|
}
|
|
1919
1910
|
};
|
|
1920
|
-
_proto.
|
|
1921
|
-
|
|
1911
|
+
_proto.getMainFrameBufferWidth = function getMainFrameBufferWidth() {
|
|
1912
|
+
return this._mainFrameWidth || this._gl.drawingBufferWidth;
|
|
1913
|
+
};
|
|
1914
|
+
_proto.getMainFrameBufferHeight = function getMainFrameBufferHeight() {
|
|
1915
|
+
return this._mainFrameHeight || this._gl.drawingBufferHeight;
|
|
1916
|
+
};
|
|
1917
|
+
_proto.activeRenderTarget = function activeRenderTarget(renderTarget, viewport, isFlipProjection, mipLevel, faceIndex) {
|
|
1922
1918
|
var bufferWidth, bufferHeight;
|
|
1923
1919
|
if (renderTarget) {
|
|
1924
|
-
|
|
1925
|
-
|
|
1920
|
+
/** @ts-ignore */ renderTarget._isContentLost = false;
|
|
1921
|
+
/** @ts-ignore */ var platformRenderTarget = renderTarget._platformRenderTarget;
|
|
1922
|
+
platformRenderTarget.activeRenderTarget(mipLevel, faceIndex);
|
|
1926
1923
|
bufferWidth = renderTarget.width >> mipLevel;
|
|
1927
1924
|
bufferHeight = renderTarget.height >> mipLevel;
|
|
1928
1925
|
} else {
|
|
1926
|
+
var gl = this._gl;
|
|
1929
1927
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._mainFrameBuffer);
|
|
1930
|
-
bufferWidth = this.
|
|
1931
|
-
bufferHeight = this.
|
|
1928
|
+
bufferWidth = this.getMainFrameBufferWidth();
|
|
1929
|
+
bufferHeight = this.getMainFrameBufferHeight();
|
|
1932
1930
|
}
|
|
1933
1931
|
var width = bufferWidth * viewport.z;
|
|
1934
1932
|
var height = bufferHeight * viewport.w;
|
|
1935
1933
|
var x = viewport.x * bufferWidth;
|
|
1936
|
-
var y = bufferHeight - viewport.y * bufferHeight - height;
|
|
1934
|
+
var y = isFlipProjection ? viewport.y * bufferHeight : bufferHeight - viewport.y * bufferHeight - height;
|
|
1937
1935
|
this.viewport(x, y, width, height);
|
|
1938
1936
|
this.scissor(x, y, width, height);
|
|
1939
1937
|
};
|