Skip to content

Commit

Permalink
Use selection color for outline (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
slimbuck authored Dec 18, 2024
1 parent e0823cb commit 7ae0698
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class Outline extends Element {
const outlineTextureId = device.scope.resolve('outlineTexture');
const alphaCutoffId = device.scope.resolve('alphaCutoff');
const clrId = device.scope.resolve('clr');
const clr = this.clr;
const clrStorage = [1, 1, 1, 1];
const events = this.scene.events;

Expand All @@ -74,10 +73,11 @@ class Outline extends Element {
device.setDepthState(DepthState.NODEPTH);
device.setStencilState(null, null);

clrStorage[0] = clr.r;
clrStorage[1] = clr.g;
clrStorage[2] = clr.b;
clrStorage[3] = clr.a;
const selectedClr = events.invoke('selectedClr');
clrStorage[0] = selectedClr.r;
clrStorage[1] = selectedClr.g;
clrStorage[2] = selectedClr.b;
clrStorage[3] = selectedClr.a;

outlineTextureId.setValue(this.entity.camera.renderTarget.colorBuffer);
alphaCutoffId.setValue(events.invoke('camera.mode') === 'rings' ? 0.0 : 0.4);
Expand Down
4 changes: 2 additions & 2 deletions src/shaders/outline-shader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const fragmentShader = /* glsl*/ `
discard;
}
for (int x = -3; x <= 3; x++) {
for (int y = -3; y <= 3; y++) {
for (int x = -2; x <= 2; x++) {
for (int y = -2; y <= 2; y++) {
if ((x != 0) && (y != 0) && (texelFetch(outlineTexture, texel + ivec2(x, y), 0).a > alphaCutoff)) {
gl_FragColor = clr;
return;
Expand Down

0 comments on commit 7ae0698

Please sign in to comment.