@galacean/engine 1.5.0-alpha.0 → 1.5.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/browser.js CHANGED
@@ -9300,74 +9300,6 @@
9300
9300
  /** None layer. */ Layer[Layer["Nothing"] = 0] = "Nothing";
9301
9301
  return Layer;
9302
9302
  }({});
9303
- /**
9304
- * @internal
9305
- */ var PipelineUtils = /*#__PURE__*/ function() {
9306
- function PipelineUtils() {}
9307
- /**
9308
- * Recreate texture if needed.
9309
- * @param engine - Engine
9310
- * @param currentTexture - Current texture
9311
- * @param width - Need texture width
9312
- * @param height - Need texture height
9313
- * @param format - Need texture format
9314
- * @param mipmap - Need texture mipmap
9315
- * @param isSRGBColorSpace - Whether to use sRGB color space
9316
- * @param textureWrapMode - Texture wrap mode
9317
- * @param textureFilterMode - Texture filter mode
9318
- * @returns Texture
9319
- */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap, isSRGBColorSpace, textureWrapMode, textureFilterMode) {
9320
- if (currentTexture) {
9321
- if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.isSRGBColorSpace !== isSRGBColorSpace || currentTexture.mipmapCount > 1 !== mipmap) {
9322
- currentTexture.destroy(true);
9323
- currentTexture = new Texture2D(engine, width, height, format, mipmap, isSRGBColorSpace);
9324
- currentTexture.isGCIgnored = true;
9325
- }
9326
- } else {
9327
- currentTexture = new Texture2D(engine, width, height, format, mipmap, isSRGBColorSpace);
9328
- currentTexture.isGCIgnored = true;
9329
- }
9330
- currentTexture.wrapModeU = currentTexture.wrapModeV = textureWrapMode;
9331
- currentTexture.filterMode = textureFilterMode;
9332
- return currentTexture;
9333
- };
9334
- /**
9335
- * Recreate render target if needed.
9336
- * @param engine - Engine
9337
- * @param currentRenderTarget - Current render target
9338
- * @param width - Need render target width
9339
- * @param height - Need render target height
9340
- * @param colorFormat - Need render target color format
9341
- * @param depthFormat - Need render target depth format
9342
- * @param mipmap - Need render target mipmap
9343
- * @param isSRGBColorSpace - Whether to use sRGB color space
9344
- * @param antiAliasing - Need render target anti aliasing
9345
- * @param textureWrapMode - Texture wrap mode
9346
- * @param textureFilterMode - Texture filter mode
9347
- * @returns Render target
9348
- */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, isSRGBColorSpace, antiAliasing, textureWrapMode, textureFilterMode) {
9349
- var currentColorTexture = currentRenderTarget == null ? void 0 : currentRenderTarget.getColorTexture(0);
9350
- var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap, isSRGBColorSpace, textureWrapMode, textureFilterMode) : null;
9351
- if (needDepthTexture) {
9352
- var currentDepthTexture = currentRenderTarget == null ? void 0 : currentRenderTarget.depthTexture;
9353
- var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap, isSRGBColorSpace, textureWrapMode, textureFilterMode) : null;
9354
- if (currentColorTexture !== colorTexture || currentDepthTexture !== _$needDepthTexture) {
9355
- currentRenderTarget == null ? void 0 : currentRenderTarget.destroy(true);
9356
- currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, _$needDepthTexture, antiAliasing);
9357
- currentRenderTarget.isGCIgnored = true;
9358
- }
9359
- } else {
9360
- if (currentColorTexture !== colorTexture || (currentRenderTarget == null ? void 0 : currentRenderTarget._depthFormat) !== depthFormat || currentRenderTarget.antiAliasing !== antiAliasing) {
9361
- currentRenderTarget == null ? void 0 : currentRenderTarget.destroy(true);
9362
- currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthFormat, antiAliasing);
9363
- currentRenderTarget.isGCIgnored = true;
9364
- }
9365
- }
9366
- return currentRenderTarget;
9367
- };
9368
- return PipelineUtils;
9369
- }();
9370
- PipelineUtils.defaultViewport = new Vector4(0, 0, 1, 1);
9371
9303
  /**
9372
9304
  * Used to update tags.
9373
9305
  */ var UpdateFlag = /*#__PURE__*/ function() {
@@ -10257,7 +10189,7 @@
10257
10189
  * The anti-aliasing mode.
10258
10190
  */ var AntiAliasing = /*#__PURE__*/ function(AntiAliasing) {
10259
10191
  /* Disable anti-aliasing. */ AntiAliasing[AntiAliasing["None"] = 0] = "None";
10260
- /* Fast approximate anti-aliasing. */ AntiAliasing[AntiAliasing["FXAA"] = 1] = "FXAA";
10192
+ /* Fast approximate anti-aliasing, it detects and smooths jagged edges based on luminance contrast in the final rendered image. */ AntiAliasing[AntiAliasing["FXAA"] = 1] = "FXAA";
10261
10193
  return AntiAliasing;
10262
10194
  }({});
10263
10195
  /**
@@ -10861,11 +10793,14 @@
10861
10793
  *
10862
10794
  * @defaultValue `Downsampling.TwoX`
10863
10795
  */ _this.opaqueTextureDownsampling = Downsampling.TwoX, /**
10864
- * Multi-sample anti-aliasing samples when use independent canvas mode.
10796
+ * The number of samples used for hardware multisample anti-aliasing (MSAA) to smooth geometry edges during rasterization.
10797
+ * Higher sample counts (e.g., 2x, 4x, 8x) produce smoother edges.
10798
+ *
10799
+ * @defaultValue `MSAASamples.FourX`
10800
+ */ _this.msaaSamples = MSAASamples.FourX, /**
10801
+ * The screen-space anti-aliasing mode applied after the camera renders the final image.
10802
+ * Unlike MSAA, it can smooth all pixels, including by shader-generated specular, alpha-cutoff edge, low resolution texture.
10865
10803
  *
10866
- * @remarks It will take effect when `independentCanvasEnabled` property is `true`, otherwise it will be invalid.
10867
- */ _this.msaaSamples = MSAASamples.None, /**
10868
- * Anti-aliasing mode.
10869
10804
  * @defaultValue `AntiAliasing.None`
10870
10805
  */ _this.antiAliasing = AntiAliasing.None, /** @internal */ _this._cameraType = CameraType$1.Normal, /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection(), /** @internal */ _this._frustum = new BoundingFrustum(), /** @internal */ _this._virtualCamera = new VirtualCamera(), /** @internal */ _this._replacementShader = null, /** @internal */ _this._replacementSubShaderTag = null, /** @internal */ _this._replacementFailureStrategy = null, /** @internal */ _this._cameraIndex = -1, _this._priority = 0, _this._shaderData = new ShaderData(ShaderDataGroup.Camera), _this._isCustomViewMatrix = false, _this._isCustomProjectionMatrix = false, _this._fieldOfView = 45, _this._orthographicSize = 10, _this._isProjectionDirty = true, _this._isInvProjMatDirty = true, _this._customAspectRatio = undefined, _this._renderTarget = null, _this._depthBufferParams = new Vector4(), _this._opaqueTextureEnabled = false, _this._enableHDR = false, _this._enablePostProcess = false, _this._viewport = new Vector4(0, 0, 1, 1), _this._pixelViewport = new Rect(0, 0, 0, 0), _this._inverseProjectionMatrix = new Matrix(), _this._invViewProjMat = new Matrix();
10871
10806
  _this._isViewMatrixDirty = entity.registerWorldChangeFlag();
@@ -11042,7 +10977,7 @@
11042
10977
  Logger.error("mipLevel only take effect in WebGL2.0");
11043
10978
  }
11044
10979
  var ignoreClearFlags;
11045
- if (this._cameraType !== CameraType$1.Normal && !this._renderTarget && !this.independentCanvasEnabled) {
10980
+ if (this._cameraType !== CameraType$1.Normal && !this._renderTarget && !this._isIndependentCanvasEnabled()) {
11046
10981
  ignoreClearFlags = engine.xrManager._getCameraIgnoreClearFlags(this._cameraType);
11047
10982
  }
11048
10983
  this._renderPipeline.render(context, cubeFace, mipLevel, ignoreClearFlags);
@@ -11076,6 +11011,31 @@
11076
11011
  };
11077
11012
  /**
11078
11013
  * @internal
11014
+ * Whether independent canvas is enabled.
11015
+ */ _proto._isIndependentCanvasEnabled = function _isIndependentCanvasEnabled() {
11016
+ // Uber pass need internal RT
11017
+ if (this.enablePostProcess && this.scene.postProcessManager._isValid()) {
11018
+ return true;
11019
+ }
11020
+ // Final pass should sRGB conversion and FXAA
11021
+ if (this._needFinalPass()) {
11022
+ return true;
11023
+ }
11024
+ var renderTarget = this._renderTarget;
11025
+ // Need HDR and opaque texture
11026
+ if (this.enableHDR || this.opaqueTextureEnabled) {
11027
+ if (renderTarget) {
11028
+ // If camera is HDR and format is same with renderTarget can reuse renderTarget if renderTarget is same HDR format
11029
+ // If camera is LDR and opaqueTextureEnabled is true, can reuse renderTarget if renderTarget is LDR format(Only R8G8B8A8)
11030
+ return this._getInternalColorTextureFormat() !== renderTarget.getColorTexture(0).format;
11031
+ } else {
11032
+ return true;
11033
+ }
11034
+ }
11035
+ return false;
11036
+ };
11037
+ /**
11038
+ * @internal
11079
11039
  */ _proto._getInternalColorTextureFormat = function _getInternalColorTextureFormat() {
11080
11040
  return this._enableHDR ? this.engine._hardwareRenderer.isWebGL2 ? TextureFormat.R11G11B10_UFloat : TextureFormat.R16G16B16A16 : TextureFormat.R8G8B8A8;
11081
11041
  };
@@ -11201,12 +11161,6 @@
11201
11161
  this._updatePixelViewport();
11202
11162
  var _this__customAspectRatio;
11203
11163
  (_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projectionMatrixChange();
11204
- this._checkMainCanvasAntialiasWaste();
11205
- };
11206
- _proto._checkMainCanvasAntialiasWaste = function _checkMainCanvasAntialiasWaste() {
11207
- if (this._phasedActiveInScene && this.independentCanvasEnabled && Vector4.equals(this._viewport, PipelineUtils.defaultViewport)) {
11208
- Logger.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.");
11209
- }
11210
11164
  };
11211
11165
  _proto._dispatchModify = function _dispatchModify(flag) {
11212
11166
  var _this__updateFlagManager;
@@ -11220,43 +11174,11 @@
11220
11174
  * If enabled, the opaque texture can be accessed in the shader using `camera_OpaqueTexture`.
11221
11175
  *
11222
11176
  * @defaultValue `false`
11223
- * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
11224
11177
  */ function get() {
11225
11178
  return this._opaqueTextureEnabled;
11226
11179
  },
11227
11180
  set: function set(value) {
11228
- if (this._opaqueTextureEnabled !== value) {
11229
- this._opaqueTextureEnabled = value;
11230
- this._checkMainCanvasAntialiasWaste();
11231
- }
11232
- }
11233
- },
11234
- {
11235
- key: "independentCanvasEnabled",
11236
- get: /**
11237
- * Whether independent canvas is enabled.
11238
- * @remarks If true, the msaa in viewport can turn or off independently by `msaaSamples` property.
11239
- */ function get() {
11240
- // Uber pass need internal RT
11241
- if (this.enablePostProcess && this.scene.postProcessManager._isValid()) {
11242
- return true;
11243
- }
11244
- // Final pass should sRGB conversion and FXAA
11245
- if (this._needFinalPass()) {
11246
- return true;
11247
- }
11248
- var renderTarget = this._renderTarget;
11249
- // Need HDR and opaque texture
11250
- if (this.enableHDR || this.opaqueTextureEnabled) {
11251
- if (renderTarget) {
11252
- // If camera is HDR and format is same with renderTarget can reuse renderTarget if renderTarget is same HDR format
11253
- // If camera is LDR and opaqueTextureEnabled is true, can reuse renderTarget if renderTarget is LDR format(Only R8G8B8A8)
11254
- return this._getInternalColorTextureFormat() !== renderTarget.getColorTexture(0).format;
11255
- } else {
11256
- return true;
11257
- }
11258
- }
11259
- return false;
11181
+ this._opaqueTextureEnabled = value;
11260
11182
  }
11261
11183
  },
11262
11184
  {
@@ -11453,7 +11375,6 @@
11453
11375
  get: /**
11454
11376
  * Whether to enable HDR.
11455
11377
  * @defaultValue `false`
11456
- * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
11457
11378
  */ function get() {
11458
11379
  return this._enableHDR;
11459
11380
  },
@@ -11466,7 +11387,6 @@
11466
11387
  return;
11467
11388
  }
11468
11389
  this._enableHDR = value;
11469
- this._checkMainCanvasAntialiasWaste();
11470
11390
  }
11471
11391
  }
11472
11392
  },
@@ -11475,14 +11395,12 @@
11475
11395
  get: /**
11476
11396
  * Whether to enable post process.
11477
11397
  * @defaultValue `false`
11478
- * @remarks If enabled, the `independentCanvasEnabled` property will be forced to be true.
11479
11398
  */ function get() {
11480
11399
  return this._enablePostProcess;
11481
11400
  },
11482
11401
  set: function set(value) {
11483
11402
  if (this._enablePostProcess !== value) {
11484
11403
  this._enablePostProcess = value;
11485
- this._checkMainCanvasAntialiasWaste();
11486
11404
  }
11487
11405
  }
11488
11406
  },
@@ -14145,6 +14063,74 @@
14145
14063
  __decorate$1([
14146
14064
  deepClone
14147
14065
  ], PostProcess.prototype, "_effects", void 0);
14066
+ /**
14067
+ * @internal
14068
+ */ var PipelineUtils = /*#__PURE__*/ function() {
14069
+ function PipelineUtils() {}
14070
+ /**
14071
+ * Recreate texture if needed.
14072
+ * @param engine - Engine
14073
+ * @param currentTexture - Current texture
14074
+ * @param width - Need texture width
14075
+ * @param height - Need texture height
14076
+ * @param format - Need texture format
14077
+ * @param mipmap - Need texture mipmap
14078
+ * @param isSRGBColorSpace - Whether to use sRGB color space
14079
+ * @param textureWrapMode - Texture wrap mode
14080
+ * @param textureFilterMode - Texture filter mode
14081
+ * @returns Texture
14082
+ */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap, isSRGBColorSpace, textureWrapMode, textureFilterMode) {
14083
+ if (currentTexture) {
14084
+ if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.isSRGBColorSpace !== isSRGBColorSpace || currentTexture.mipmapCount > 1 !== mipmap) {
14085
+ currentTexture.destroy(true);
14086
+ currentTexture = new Texture2D(engine, width, height, format, mipmap, isSRGBColorSpace);
14087
+ currentTexture.isGCIgnored = true;
14088
+ }
14089
+ } else {
14090
+ currentTexture = new Texture2D(engine, width, height, format, mipmap, isSRGBColorSpace);
14091
+ currentTexture.isGCIgnored = true;
14092
+ }
14093
+ currentTexture.wrapModeU = currentTexture.wrapModeV = textureWrapMode;
14094
+ currentTexture.filterMode = textureFilterMode;
14095
+ return currentTexture;
14096
+ };
14097
+ /**
14098
+ * Recreate render target if needed.
14099
+ * @param engine - Engine
14100
+ * @param currentRenderTarget - Current render target
14101
+ * @param width - Need render target width
14102
+ * @param height - Need render target height
14103
+ * @param colorFormat - Need render target color format
14104
+ * @param depthFormat - Need render target depth format
14105
+ * @param mipmap - Need render target mipmap
14106
+ * @param isSRGBColorSpace - Whether to use sRGB color space
14107
+ * @param antiAliasing - Need render target anti aliasing
14108
+ * @param textureWrapMode - Texture wrap mode
14109
+ * @param textureFilterMode - Texture filter mode
14110
+ * @returns Render target
14111
+ */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, needDepthTexture, mipmap, isSRGBColorSpace, antiAliasing, textureWrapMode, textureFilterMode) {
14112
+ var currentColorTexture = currentRenderTarget == null ? void 0 : currentRenderTarget.getColorTexture(0);
14113
+ var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap, isSRGBColorSpace, textureWrapMode, textureFilterMode) : null;
14114
+ if (needDepthTexture) {
14115
+ var currentDepthTexture = currentRenderTarget == null ? void 0 : currentRenderTarget.depthTexture;
14116
+ var _$needDepthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap, isSRGBColorSpace, textureWrapMode, textureFilterMode) : null;
14117
+ if (currentColorTexture !== colorTexture || currentDepthTexture !== _$needDepthTexture) {
14118
+ currentRenderTarget == null ? void 0 : currentRenderTarget.destroy(true);
14119
+ currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, _$needDepthTexture, antiAliasing);
14120
+ currentRenderTarget.isGCIgnored = true;
14121
+ }
14122
+ } else {
14123
+ if (currentColorTexture !== colorTexture || (currentRenderTarget == null ? void 0 : currentRenderTarget._depthFormat) !== depthFormat || currentRenderTarget.antiAliasing !== antiAliasing) {
14124
+ currentRenderTarget == null ? void 0 : currentRenderTarget.destroy(true);
14125
+ currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthFormat, antiAliasing);
14126
+ currentRenderTarget.isGCIgnored = true;
14127
+ }
14128
+ }
14129
+ return currentRenderTarget;
14130
+ };
14131
+ return PipelineUtils;
14132
+ }();
14133
+ PipelineUtils.defaultViewport = new Vector4(0, 0, 1, 1);
14148
14134
  exports.Collider = /*#__PURE__*/ function(Component) {
14149
14135
  _inherits$2(Collider, Component);
14150
14136
  function Collider(entity) {
@@ -19711,7 +19697,8 @@
19711
19697
  */ _proto.render = function render(context, cubeFace, mipLevel, ignoreClear) {
19712
19698
  context.rendererUpdateFlag = ContextRendererUpdateFlag.All;
19713
19699
  var camera = this._camera;
19714
- var scene = camera.scene, engine = camera.engine, renderTarget = camera.renderTarget, independentCanvasEnabled = camera.independentCanvasEnabled;
19700
+ var scene = camera.scene, engine = camera.engine, renderTarget = camera.renderTarget;
19701
+ var independentCanvasEnabled = camera._isIndependentCanvasEnabled();
19715
19702
  var rhi = engine._hardwareRenderer;
19716
19703
  var cullingResults = this._cullingResults;
19717
19704
  var sunlight = scene._lightManager._sunlight;
@@ -19719,10 +19706,12 @@
19719
19706
  var depthPassEnabled = camera.depthTextureMode === DepthTextureMode.PrePass && depthOnlyPass._supportDepthTexture;
19720
19707
  var finalClearFlags = camera.clearFlags & ~(ignoreClear != null ? ignoreClear : CameraClearFlags.None);
19721
19708
  var msaaSamples = renderTarget ? renderTarget.antiAliasing : camera.msaaSamples;
19709
+ // Check whether can use `blitFramebuffer` to blit internal render target, source maybe screen canvas or camera's render target
19710
+ // Our screen canvas's anti-aliasing is always disable, so blit source and dest is always same by below rules:
19722
19711
  // 1. Only support blitFramebuffer in webgl2 context
19723
19712
  // 2. Can't blit normal FBO to MSAA FBO
19724
19713
  // 3. Can't blit screen MSAA FBO to normal FBO in mac safari platform and mobile, but mac chrome and firfox is OK
19725
- this._canUseBlitFrameBuffer = rhi.isWebGL2 && msaaSamples === 1 && (!!renderTarget || !rhi.context.antialias);
19714
+ this._canUseBlitFrameBuffer = rhi.isWebGL2 && msaaSamples === 1;
19726
19715
  // Because internal render target is linear color space, so we should convert srgb background color to linear color space
19727
19716
  var isSRGBBackground = !renderTarget || renderTarget.getColorTexture(0).isSRGBColorSpace;
19728
19717
  this._shouldCopyBackgroundColor = independentCanvasEnabled && !(finalClearFlags & CameraClearFlags.Color) && (!this._canUseBlitFrameBuffer || isSRGBBackground);
@@ -19750,11 +19739,11 @@
19750
19739
  var depthFormat;
19751
19740
  if (camera.renderTarget) {
19752
19741
  depthFormat = camera.renderTarget._depthFormat;
19753
- } else if (rhi.context.depth && rhi.context.stencil) {
19742
+ } else if (rhi._options.depth && rhi._options.stencil) {
19754
19743
  depthFormat = TextureFormat.Depth24Stencil8;
19755
- } else if (rhi.context.depth) {
19744
+ } else if (rhi._options.depth) {
19756
19745
  depthFormat = TextureFormat.Depth24;
19757
- } else if (rhi.context.stencil) {
19746
+ } else if (rhi._options.stencil) {
19758
19747
  depthFormat = TextureFormat.Stencil;
19759
19748
  } else {
19760
19749
  depthFormat = null;
@@ -19804,23 +19793,24 @@
19804
19793
  // If color target is null, hardware will not convert linear color space to sRGB
19805
19794
  var color = colorTarget ? background._linearSolidColor : background.solidColor;
19806
19795
  finalClearFlags !== CameraClearFlags.None && rhi.clearRenderTarget(engine, finalClearFlags, color);
19807
- if (internalColorTarget && finalClearFlags !== CameraClearFlags.All) {
19808
- // Can use `blitFramebuffer` API to copy color/depth/stencil buffer from back buffer to internal RT
19809
- if (this._canUseBlitFrameBuffer) {
19810
- var blitIgnoreFlags = finalClearFlags | (this._shouldCopyBackgroundColor ? CameraClearFlags.Color : CameraClearFlags.None);
19811
- rhi.blitInternalRTByBlitFrameBuffer(camera.renderTarget, internalColorTarget, blitIgnoreFlags, camera.viewport);
19812
- } else {
19813
- if (!(finalClearFlags & CameraClearFlags.DepthStencil)) {
19814
- Logger.warn("We clear all depth/stencil state cause of the internalRT can't copy depth/stencil buffer from back buffer when use copy plan");
19796
+ if (internalColorTarget) {
19797
+ // Force clear internal color target depth and stencil buffer, because it already missed due to post process, HDR, sRGB covert, etc.
19798
+ var keepDSFlags = ~finalClearFlags & CameraClearFlags.DepthStencil;
19799
+ if (keepDSFlags) {
19800
+ rhi.clearRenderTarget(engine, keepDSFlags);
19801
+ }
19802
+ var keepColorFlag = ~finalClearFlags & CameraClearFlags.Color;
19803
+ if (keepColorFlag) {
19804
+ if (this._shouldCopyBackgroundColor) {
19805
+ // Copy RT's color buffer to grab texture
19806
+ rhi.copyRenderTargetToSubTexture(camera.renderTarget, this._copyBackgroundTexture, camera.viewport);
19807
+ // Then blit grab texture to internal RT's color buffer
19808
+ Blitter.blitTexture(engine, this._copyBackgroundTexture, internalColorTarget, 0, undefined, camera.renderTarget ? undefined : engine._basicResources.blitScreenMaterial);
19809
+ } else {
19810
+ // Only blit color buffer from back buffer
19811
+ var ignoreFlags = CameraClearFlags.DepthStencil;
19812
+ rhi.blitInternalRTByBlitFrameBuffer(camera.renderTarget, internalColorTarget, ignoreFlags, camera.viewport);
19815
19813
  }
19816
- // We must clear depth/stencil buffer manually if current context don't support `blitFramebuffer` API
19817
- rhi.clearRenderTarget(engine, CameraClearFlags.DepthStencil);
19818
- }
19819
- if (this._shouldCopyBackgroundColor) {
19820
- // Copy RT's color buffer to grab texture
19821
- rhi.copyRenderTargetToSubTexture(camera.renderTarget, this._copyBackgroundTexture, camera.viewport);
19822
- // Then blit grab texture to internal RT's color buffer
19823
- Blitter.blitTexture(engine, this._copyBackgroundTexture, internalColorTarget, 0, undefined, camera.renderTarget ? undefined : engine._basicResources.blitScreenMaterial);
19824
19814
  }
19825
19815
  context.setRenderTarget(colorTarget, colorViewport, mipLevel, cubeFace);
19826
19816
  }
@@ -43177,9 +43167,17 @@
43177
43167
  this._scissorEnable = false;
43178
43168
  var options = _extends$1({
43179
43169
  webGLMode: 0,
43180
- stencil: true,
43181
43170
  _forceFlush: false,
43182
- _maxAllowSkinUniformVectorCount: 256
43171
+ _maxAllowSkinUniformVectorCount: 256,
43172
+ alpha: true,
43173
+ depth: true,
43174
+ stencil: true,
43175
+ failIfMajorPerformanceCaveat: false,
43176
+ powerPreference: "default",
43177
+ premultipliedAlpha: true,
43178
+ preserveDrawingBuffer: false,
43179
+ desynchronized: false,
43180
+ xrCompatible: false
43183
43181
  }, initializeOptions);
43184
43182
  if (SystemInfo.platform === Platform.IPhone || SystemInfo.platform === Platform.IPad) {
43185
43183
  var version = SystemInfo.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);
@@ -43192,37 +43190,50 @@
43192
43190
  }
43193
43191
  }
43194
43192
  this._options = options;
43193
+ // Force disable stencil, antialias and depth, we configure them in internal render target
43194
+ this._webGLOptions = {
43195
+ antialias: false,
43196
+ depth: false,
43197
+ stencil: false,
43198
+ alpha: options.alpha,
43199
+ failIfMajorPerformanceCaveat: options.failIfMajorPerformanceCaveat,
43200
+ powerPreference: options.powerPreference,
43201
+ premultipliedAlpha: options.premultipliedAlpha,
43202
+ preserveDrawingBuffer: options.preserveDrawingBuffer,
43203
+ desynchronized: options.desynchronized,
43204
+ xrCompatible: options.xrCompatible
43205
+ };
43195
43206
  this._onWebGLContextLost = this._onWebGLContextLost.bind(this);
43196
43207
  this._onWebGLContextRestored = this._onWebGLContextRestored.bind(this);
43197
43208
  }
43198
43209
  var _proto = WebGLGraphicDevice.prototype;
43199
43210
  _proto.init = function init(canvas, onDeviceLost, onDeviceRestored) {
43200
- var options = this._options;
43201
43211
  var webCanvas = canvas._webCanvas;
43202
- var webGLMode = options.webGLMode;
43212
+ var webGLMode = this._options.webGLMode;
43203
43213
  this._onDeviceLost = onDeviceLost;
43204
43214
  this._onDeviceRestored = onDeviceRestored;
43205
43215
  webCanvas.addEventListener("webglcontextlost", this._onWebGLContextLost, false);
43206
43216
  webCanvas.addEventListener("webglcontextrestored", this._onWebGLContextRestored, false);
43207
43217
  webCanvas.addEventListener("webglcontextcreationerror", this._onContextCreationError, false);
43208
43218
  this._webCanvas = webCanvas;
43219
+ var webGLOptions = this._webGLOptions;
43209
43220
  var gl;
43210
43221
  if (webGLMode == 0 || webGLMode == 1) {
43211
- gl = webCanvas.getContext("webgl2", options);
43222
+ gl = webCanvas.getContext("webgl2", webGLOptions);
43212
43223
  if (!gl && (typeof OffscreenCanvas === "undefined" || !_instanceof1$1(webCanvas, OffscreenCanvas))) {
43213
- gl = webCanvas.getContext("experimental-webgl2", options);
43224
+ gl = webCanvas.getContext("experimental-webgl2", webGLOptions);
43214
43225
  }
43215
43226
  this._isWebGL2 = true;
43216
- // Prevent weird browsers to lie (such as safari!)
43227
+ // Prevent weird browsers to lie (such as safari!)ƒ
43217
43228
  if (gl && !gl.deleteQuery) {
43218
43229
  this._isWebGL2 = false;
43219
43230
  }
43220
43231
  }
43221
43232
  if (!gl) {
43222
43233
  if (webGLMode == 0 || webGLMode == 2) {
43223
- gl = webCanvas.getContext("webgl", options);
43234
+ gl = webCanvas.getContext("webgl", webGLOptions);
43224
43235
  if (!gl && (typeof OffscreenCanvas === "undefined" || !_instanceof1$1(webCanvas, OffscreenCanvas))) {
43225
- gl = webCanvas.getContext("experimental-webgl", options);
43236
+ gl = webCanvas.getContext("experimental-webgl", webGLOptions);
43226
43237
  }
43227
43238
  this._isWebGL2 = false;
43228
43239
  }
@@ -43486,7 +43497,6 @@
43486
43497
  if (debugRenderInfo != null) {
43487
43498
  this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
43488
43499
  }
43489
- this._contextAttributes = gl.getContextAttributes();
43490
43500
  };
43491
43501
  _proto.destroy = function destroy() {
43492
43502
  var webCanvas = this._webCanvas;
@@ -43543,12 +43553,6 @@
43543
43553
  get: function get() {
43544
43554
  return this.capability.canIUseMoreJoints;
43545
43555
  }
43546
- },
43547
- {
43548
- key: "context",
43549
- get: function get() {
43550
- return this._contextAttributes;
43551
- }
43552
43556
  }
43553
43557
  ]);
43554
43558
  return WebGLGraphicDevice;
@@ -50836,7 +50840,7 @@
50836
50840
  ], EXT_texture_webp);
50837
50841
 
50838
50842
  //@ts-ignore
50839
- var version = "1.5.0-alpha.0";
50843
+ var version = "1.5.0-alpha.1";
50840
50844
  console.log("Galacean Engine Version: " + version);
50841
50845
  for(var key in CoreObjects){
50842
50846
  Loader.registerClass(key, CoreObjects[key]);