Skip to content

Commit

Permalink
Reduce size of line atlas by removing unused channels
Browse files Browse the repository at this point in the history
Saves roughly ~100kb of uncompressed gpu memory, potentially saving texture fetches in the shader
  • Loading branch information
karimnaaji committed Jan 24, 2020
1 parent 8cd474e commit 53a3477
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/render/line_atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class LineAtlas {
signedDistance = (inside ? 1 : -1) * dist;
}

this.data[3 + (index + x) * 4] = Math.max(0, Math.min(255, signedDistance + offset));
this.data[index + x] = Math.max(0, Math.min(255, signedDistance + offset));
}
}

Expand All @@ -139,14 +139,14 @@ class LineAtlas {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, this.data);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, this.width, this.height, 0, gl.ALPHA, gl.UNSIGNED_BYTE, this.data);

} else {
gl.bindTexture(gl.TEXTURE_2D, this.texture);

if (this.dirty) {
this.dirty = false;
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.height, gl.RGBA, gl.UNSIGNED_BYTE, this.data);
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.height, gl.ALPHA, gl.UNSIGNED_BYTE, this.data);
}
}
}
Expand Down

0 comments on commit 53a3477

Please sign in to comment.