Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomLayerInterface to expose projection matrix parameters #12888

Open
Pessimistress opened this issue Sep 13, 2023 · 0 comments
Open

CustomLayerInterface to expose projection matrix parameters #12888

Pessimistress opened this issue Sep 13, 2023 · 0 comments

Comments

@Pessimistress
Copy link

Motivation

For our custom layer implementation to properly match the base map in an interleaved 3D context, we need access to the projection matrix parameters.

CustomLayerInterface.render currently exposes a single matrix argument that is the combined view projection matrix. In our implementation, coordinate transforms are done on the GPU for better performance, but shader uniforms only support up to 32-bit floats. To compensate for lost precision, we calculate the view matrix and projection matrix separately.

Historically we poke into the source code of the Transform class to try match our calculation with the base map. This has become increasingly problematic as the base map could change its near/far plane calculation between versions. It would be much easier if CustomLayerInterface.render could expose the view and projection matrices separately, or even the individual projection matrix parameters (fov, near, far).

Design Alternatives

A non-breaking API change could be adding a third parameter to CustomLayerInterface.render:

render(gl: WebGLRenderingContext, matrix: number[], transform: {
  pixelMatrix: number[];
  projMatrix: number[];
  ...
})

Implementation

The separate matrices and nearZ/farZ etc. are already stored in map.transform as private properties. Making them visible to a custom layer has minimal overhead but will help create much more robust third-party renderers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants