MSFCustomRasterTileLayer

Objective-C


@interface MSFCustomRasterTileLayer : MSFRasterTileLayer

Swift

class MSFCustomRasterTileLayer : MSFRasterTileLayer

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.

  • Constructs a CustomRasterTileLayer object from a raster data source.

    Declaration

    Objective-C

    - (id)initWithDataSource:(MSFTileDataSource *)dataSource;

    Swift

    init!(dataSource: MSFTileDataSource!)

    Parameters

    dataSource

    The raster data source from which this layer loads data.

  • Returns the custom fragment shader source.

    Declaration

    Objective-C

    - (NSString *)getShaderSource;

    Swift

    func getShaderSource() -> String!

    Return Value

    The shader source. Empty means the default passthrough (outputs the raw tile).

  • 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.

    Declaration

    Objective-C

    - (void)setShaderSource:(NSString *)shaderSource;

    Swift

    func setShaderSource(_ shaderSource: String!)

    Parameters

    shaderSource

    The GLSL shader source.

  • Undocumented

    Declaration

    Objective-C

    -(void)dealloc;

    Swift

    func dealloc()