Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/dev/core/src/Engines/abstractEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export abstract class AbstractEngine {
/** @internal */
public _stencilState = new StencilState();
/** @internal */
public _alphaState = new AlphaState();
public _alphaState = new AlphaState(false);
/** @internal */
public _alphaMode = Array(8).fill(-1);
/** @internal */
Expand Down
3 changes: 3 additions & 0 deletions packages/dev/core/src/Engines/thinEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { Effect } from "../Materials/effect";
import { _ConcatenateShader, _GetGlobalDefines } from "./abstractEngine.functions";
import { resetCachedPipeline } from "core/Materials/effect.functions";
import { HasStencilAspect, IsDepthTexture } from "core/Materials/Textures/textureHelper.functions";
import { AlphaState } from "../States/alphaCullingState";

/**
* Keeps track of all the buffer info used in engine.
Expand Down Expand Up @@ -628,6 +629,8 @@ export class ThinEngine extends AbstractEngine {
const oesDrawBuffersIndexed = this._gl.getExtension("OES_draw_buffers_indexed");
this._caps.blendParametersPerTarget = oesDrawBuffersIndexed ? true : false;

this._alphaState = new AlphaState(this._caps.blendParametersPerTarget);

if (oesDrawBuffersIndexed) {
this._gl.blendEquationSeparateIndexed = oesDrawBuffersIndexed.blendEquationSeparateiOES.bind(oesDrawBuffersIndexed);
this._gl.blendEquationIndexed = oesDrawBuffersIndexed.blendEquationiOES.bind(oesDrawBuffersIndexed);
Expand Down
3 changes: 3 additions & 0 deletions packages/dev/core/src/Engines/webgpuEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import type { InternalTextureCreationOptions, TextureSize } from "../Materials/T
import { WebGPUSnapshotRendering } from "./WebGPU/webgpuSnapshotRendering";
import type { WebGPUDataBuffer } from "../Meshes/WebGPU/webgpuDataBuffer";
import type { WebGPURenderTargetWrapper } from "./WebGPU/webgpuRenderTargetWrapper";
import { AlphaState } from "../States/alphaCullingState";

import "../Buffers/buffer.align";

Expand Down Expand Up @@ -947,6 +948,8 @@ export class WebGPUEngine extends ThinWebGPUEngine {
_checkNonFloatVertexBuffersDontRecreatePipelineContext: true,
_collectUbosUpdatedInFrame: false,
};

this._alphaState = new AlphaState(this._caps.blendParametersPerTarget);
}

private _initializeContextAndSwapChain(): void {
Expand Down
9 changes: 5 additions & 4 deletions packages/dev/core/src/States/alphaCullingState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export class AlphaState {

/**
* Initializes the state.
* @param _supportBlendParametersPerTarget - Whether blend parameters per target is supported
*/
public constructor() {
public constructor(private _supportBlendParametersPerTarget: boolean) {
this.reset();
}

Expand Down Expand Up @@ -117,7 +118,7 @@ export class AlphaState {

// Alpha blend
if (this._isAlphaBlendDirty) {
if (numTargets === 1) {
if (numTargets === 1 || !this._supportBlendParametersPerTarget) {
if (this._alphaBlend[0]) {
gl.enable(gl.BLEND);
} else {
Expand All @@ -140,7 +141,7 @@ export class AlphaState {

// Alpha function
if (this._isBlendFunctionParametersDirty) {
if (numTargets === 1) {
if (numTargets === 1 || !this._supportBlendParametersPerTarget) {
gl.blendFuncSeparate(
<number>this._blendFunctionParameters[0],
<number>this._blendFunctionParameters[1],
Expand All @@ -165,7 +166,7 @@ export class AlphaState {

// Alpha equation
if (this._isBlendEquationParametersDirty) {
if (numTargets === 1) {
if (numTargets === 1 || !this._supportBlendParametersPerTarget) {
gl.blendEquationSeparate(<number>this._blendEquationParameters[0], <number>this._blendEquationParameters[1]);
} else {
const gl2 = gl as WebGL2RenderingContext;
Expand Down
Loading