visgl / deck.gl

WebGL2 powered visualization framework
https://deck.gl
MIT License
12.06k stars 2.08k forks source link

[Bug] LayerExtension has no effect on Tile3DLayer #7952

Closed RELNO closed 1 year ago

RELNO commented 1 year ago

Description

When using LayerExtension with simple frag shader, most layers are impacted, besides Tile3DLayer. Example below shows Tile3DLayer and TileLayer. LayerExtension only impacts TileLayer (https://codesandbox.io/p/sandbox/small-water-fkrzcm) Note: this applies to all Tile3DLayer sources, regardless if its google 3d tiles, archgis, etc.

Screenshot 2023-06-16 at 1 42 04 PM Screenshot 2023-06-16 at 1 42 10 PM

Where Extension is:

import { LayerExtension } from "@deck.gl/core";

export default class ColorExtension extends LayerExtension {

  getShaders() {
    return {
      inject: {
        "fs:DECKGL_FILTER_COLOR": `
        color = vec4(1,0,0, 1);
            `,
      },
    };
  }
}

Flavors

Expected Behavior

LayerExtension frag shader should apply to all layers

Steps to Reproduce

add LayerExtension with shader to Tile3DLayer. See here https://codesandbox.io/p/sandbox/small-water-fkrzcm

Environment

Logs

No response

RELNO commented 1 year ago

@Pessimistress since tile3d is composite of ScenegraphLayer (in this case), I wonder if https://github.com/visgl/deck.gl/pull/5214 might be related.

RELNO commented 1 year ago

Further investigation shows that getShaders has no impact on extended Tile3DLayer:

import { Tile3DLayer } from "@deck.gl/geo-layers";

export default class ExtendedTile3DLayer extends Tile3DLayer {
  initializeState(state) {
    super.initializeState();
    console.log("This will be logged");
  }

  getShaders() {
    console.log("This will not be logged")
    return Object.assign({}, super.getShaders, {
      fs: "color = vec4(1.0, 0.0, 0.0, 1.0);",
    });

  getLoadOptions() {
    console.log("This won't as well :( ");
  }

  }
}
Pessimistress commented 1 year ago

@RELNO Regarding your last comment, composite layers never call getShaders. The Tile3DLayer renders ScenegraphLayer, which calls its own getShaders. Extensions should theoretically work, though, I'll need to investigate.

RELNO commented 1 year ago

@Pessimistress thanks, makes total sense. In terms of the sublayer (Scenegraph), two things to note:

Pessimistress commented 1 year ago

Fixed in v8.9.20.

RELNO commented 1 year ago

works great, thanks @Pessimistress!