Skip to content

Commit

Permalink
chore(driver): docs
Browse files Browse the repository at this point in the history
  • Loading branch information
atty303 committed May 16, 2024
1 parent c7ca7aa commit 3d77db7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/driver/src/js/renderer/webgl_backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class WebGL1Backend {
constructor(canvas: OffscreenCanvas) {
this._canvas = canvas;

const gl = canvas.getContext("webgl", { antialias: false });
const gl = canvas.getContext("webgl", { antialias: false, depth: false, premultipliedAlpha: true });
if (!gl) throw new Error("Failed to get WebGL context");
this.gl = gl;

Expand Down Expand Up @@ -338,8 +338,13 @@ export class WebGL1Backend {
}

// Draw
// gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);

// https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic/blob/v2.0.2/engine/render/r_main.cpp#L430-L434
// NOTE: SimpleGraphic's default should be PB_ALPHA, but it doesn't draw correctly unless RB_PRE_ALPHA
// gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); // RB_ALPHA
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); // RB_PRE_ALPHA
// gl.blendFunc(gl.ONE, gl.ONE); // RB_ADDITIVE

// TODO: Use bufferSubData
// gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices.buffer);
gl.vertexAttribPointer(p.position, 2, gl.FLOAT, false, 52, 0);
Expand Down

0 comments on commit 3d77db7

Please sign in to comment.