Replies: 3 comments
-
Not sure I fully follow, but if you have a good idea how to improve this without introducing any breaking changes feel free to open a PR. |
Beta Was this translation helpful? Give feedback.
-
i have the same problem, i created a pretty simple custom layer that applies a texture with N pixels per side per tile, with some irrelevant bicubic interpolation, i'm using the vertexShaderPrelude and define strings to setup my vertex shader, then i call the projectTile function, in render i create my mesh i use createTileMesh, so, in an ideal world, calling projectTile would take terrain into account, and the mesh for a tile would be the more complex 3D one when terrain is on, BUT, and this is a big one, i used this example https://maplibre.org/maplibre-gl-js/docs/examples/globe-custom-tiles/ as a starting point, so, i only recreate a shader when variantName changes, so, even (in my dreams ?) both the vertexShaderPrelude and define AND the createTileMesh would seamlessly work, i would not know, as im not including "terrain" on, in the key for my shader cache, anyway, im a noob, but, either i'm an idiot, that is very likely, or, createTileMesh and the vertex shader injected source code could be improved, or, in the very best case, the sample code is outdated, i know this is probably not the most typicall use of maplibre, but it's one of the ways someone can push boundaries, so i think it's worth helping poor devs like me and anyone who tries something similare if someone can tell me how to do this i will create a simple example to help anyone else who wants to do something similar, custom layers, when shared, make this platform even greater sorry if i missed some obvious API or doc that helps to do this, there is so much to read ! |
Beta Was this translation helpful? Give feedback.
-
Custom layer is a complicated solution, so I'm not sure I'll be able to help here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
render_to_texture.ts
file, render the tiles by multiple layers and use the finished tile texture(were to pulled fromRenderPool
) to render the terrain.However, in the
if
statement below,LAYER
object does not havecustom
property, so the custom type layer is not entered in the if statement and is not pushed tothis._stacks
.see the code here.
For the above reasons, the tile texture is not directly accessible on the custom type layer.
Also, in
RenderPool
, the tile texture is returned to the pool and reused, so even if access is possible, the custom layer does not know if it is the right timing tile texture.That is why the custom layer does not have access to the textures used in the final terrain and therefore cannot interact with the terrain provided by maplibre.
To correct this issue, we need to add
custom
property to theLAYER
object and add Tile and Framebuffer to the render parameter to make it accessible to the custom layer. Alternatively, you can add an optional new function such as.renderToTile
toCustomLayerInterface
.// render_to_texture.ts /** * lookup table which layers should rendered to texture */ const LAYERS: { [keyof in StyleLayer['type']]?: boolean } = { + custom: true, background: true, fill: true, line: true, raster: true, hillshade: true };
The function of
painter.renderLayer(painter, painter.style.sourceCaches[layer.source], layer, coords, options);
does not seem to have a big problem because the function that handles the custom layer is working properly.However, the
coords
parameter is notundefined
. so must be passed to the custom layer.Beta Was this translation helpful? Give feedback.
All reactions