Class CustomRasterTileLayer

Direct Known Subclasses:
HillshadeRasterTileLayer

public class CustomRasterTileLayer extends RasterTileLayer
A raster tile layer that renders each tile through a custom GLSL fragment shader ("filter").
The data source can be any raster TileDataSource - most commonly an RGB-encoded elevation
(terrarium/mapbox) source, but any raster works. This is the general form of
HillshadeRasterTileLayer, which specializes it for DEM data (normal map + hillshade + contours).

The shader must define:
vec4 applyLighting(lowp vec4 color, mediump vec3 normal, mediump vec3 surfaceNormal, mediump float intensity)
and it can use these helpers (injected before it):
getRawColor() - the untouched RGBA texel of the source tile at this fragment
getMapZoom() - the current fractional map zoom (for per-zoom logic)
plus the shared uniforms/varyings vUV (tile uv), uUVScale (texture size) and uBitmap.
It must return a PREMULTIPLIED color (rgb already multiplied by alpha); return alpha 0 where the
output should be transparent so layers below show through.

Note: this class is experimental and may change or even be removed in future SDK versions.
  • Constructor Details

    • CustomRasterTileLayer

      public CustomRasterTileLayer(TileDataSource dataSource)
      Constructs a CustomRasterTileLayer object from a raster data source.
      Parameters:
      dataSource - The raster data source from which this layer loads data.
  • Method Details

    • getShaderSource

      public String getShaderSource()
      Returns the custom fragment shader source.
      Returns:
      The shader source. Empty means the default passthrough (outputs the raw tile).
    • setShaderSource

      public void setShaderSource(String shaderSource)
      Sets the custom fragment shader source (the "filter"). See the class description for the
      required entry point and available helpers. Empty resets to the passthrough shader.
      Parameters:
      shaderSource - The GLSL shader source.