s2maps-gpu - v0.18.0
    Preparing search index...

    Interface HillshadeStyle

    Hillshade Style Guide

    [See LayerStyleBase]

    • name: the name of the layer, useful for sorting a layer on insert or for removal
    • source: the name of the source whose data this layer will use
    • layer: the source's layer. Defaults to "default" for JSON data
    • minzoom: the minimum zoom level at which the layer will be visible
    • maxzoom: the maximum zoom level at which the layer will be visible
    • filter: [See Filter] a filter function to filter out features from the source layer
    • lch: use LCH coloring instead of RGB. Useful for color changing when the new color is very different from the old one
    • visible: whether the layer is visible or not
    • metadata: additional metadata. Used by style generators
    • opacity: the opacity of the hillshade. Choose between [0, 1], or pull out the value using a Property.
    • azimuth: the azimuth of the sun's position casting the light in degrees [0, 360]. Input a number or pull out the value using a Property.
    • altitude: the altitude of the raster in degrees [0, 90]. Input a number or pull out the value using a Property.
    • shadowColor: Color of the shadows. Input either a string pull out the value using a Property.
    • highlightColor: Color of the highlights. Input either a string pull out the value using a Property.
    • accentColor: Color of the accents. Input either a string pull out the value using a Property.
    • fadeDuration: The time it takes for each raster tile to fade in and out of view in milliseconds
    • unpack: Descriptor to help the GPU know how to unpack the incoming RGBA data into a f32.
    interface HillshadeStyle {
        accentColor?: string | Property<string>;
        altitude?: number | Property<number>;
        azimuth?: number | Property<number>;
        fadeDuration?: number;
        filter?: Filter;
        highlightColor?: string | Property<string>;
        layer?: string;
        lch?: boolean;
        maxzoom?: number;
        metadata?: unknown;
        minzoom?: number;
        name?: string;
        opacity?: number | Property<number>;
        shadowColor?: string | Property<string>;
        source?: string;
        type: "hillshade";
        unpack?: UnpackDefinition;
        visible?: boolean;
    }

    Hierarchy (View Summary)

    Index

    Properties

    accentColor?: string | Property<string>

    A LAYOUT Property.

    "#000"

    ex.

    { "accentColor": "rgba(240, 2, 5, 1)" }
    

    ex.

    { "accentColor": { "inputValue": { "key": "accent", "fallback": "black" } } }
    
    • inputValue: [See InputValue] access value in feature properties
    • dataCondition: [See DataCondition] filter based on feature property conditions
    • dataRange: [See DataRange] filter based on feature property ranges
    • inputRange: [See InputRange] filter based on map conditions like "zoom", "lon", "lat", "angle", or "pitch"
    • featureState: [See FeatureState] filter based on feature state
    • fallback: if all else fails, use this value. A value of string itself or pull from feature properties using Property
    altitude?: number | Property<number>

    A LAYOUT Property.

    45

    ex.

    { "altitude": 45 }
    

    ex.

    { "altitude": { "inputValue": { "key": "alt", "fallback": 45 } } }
    
    • inputValue: [See InputValue] access value in feature properties
    • dataCondition: [See DataCondition] filter based on feature property conditions
    • dataRange: [See DataRange] filter based on feature property ranges
    • inputRange: [See InputRange] filter based on map conditions like "zoom", "lon", "lat", "angle", or "pitch"
    • featureState: [See FeatureState] filter based on feature state
    • fallback: if all else fails, use this value. A value of number itself or pull from feature properties using Property
    azimuth?: number | Property<number>

    A LAYOUT Property.

    315

    ex.

    { "azimuth": 115 }
    

    ex.

    { "azimuth": { "inputValue": { "key": "az", "fallback": 0 } } }
    
    • inputValue: [See InputValue] access value in feature properties
    • dataCondition: [See DataCondition] filter based on feature property conditions
    • dataRange: [See DataRange] filter based on feature property ranges
    • inputRange: [See InputRange] filter based on map conditions like "zoom", "lon", "lat", "angle", or "pitch"
    • featureState: [See FeatureState] filter based on feature state
    • fallback: if all else fails, use this value. A value of number itself or pull from feature properties using Property
    fadeDuration?: number

    The duration of the fade in milliseconds. Defaults to 300

    filter?: Filter

    A filter function to filter out features from the source layer.

    example:

    "filter": { "key": "class", "comparator": "==", "value": "ocean" }
    

    another example:

    "filter": {
    "or": [
    { "key": "class", "comparator": "==", "value": "ocean" },
    { "key": "class", "comparator": "==", "value": "bay" }
    ]
    }

    another example:

    "filter": {
    "and": [
    { "key": "class", "comparator": "==", "value": "ocean" },
    { "key": "size", "comparator": "==", "value": "large" },
    { "key": "type", "comparator": "!=", "value": "pacific" }
    ]
    }
    highlightColor?: string | Property<string>

    A LAYOUT Property.

    "#fff"

    ex.

    { "highlightColor": "rgba(240, 2, 5, 1)" }
    

    ex.

    { "highlightColor": { "inputValue": { "key": "accent", "fallback": "white" } } }
    
    • inputValue: [See InputValue] access value in feature properties
    • dataCondition: [See DataCondition] filter based on feature property conditions
    • dataRange: [See DataRange] filter based on feature property ranges
    • inputRange: [See InputRange] filter based on map conditions like "zoom", "lon", "lat", "angle", or "pitch"
    • featureState: [See FeatureState] filter based on feature state
    • fallback: if all else fails, use this value. A value of string itself or pull from feature properties using Property
    layer?: string

    The source's layer. Default for JSON data

    lch?: boolean

    Use LCH coloring instead of RGB. Useful for color changing when the new color is very different from the old one

    maxzoom?: number

    The maximum zoom level at which the layer will be visible

    metadata?: unknown

    Additional metadata. Used by style generators.

    minzoom?: number

    The minimum zoom level at which the layer will be visible

    name?: string

    The name of the layer - useful for sorting a layer on insert or for removal

    opacity?: number | Property<number>

    A LAYOUT Property.

    1

    ex.

    { "opacity": 0.5 }
    

    ex.

    { "opacity": { "inputValue": { "key": "opacity", "fallback": 1 } } }
    
    • inputValue: [See InputValue] access value in feature properties
    • dataCondition: [See DataCondition] filter based on feature property conditions
    • dataRange: [See DataRange] filter based on feature property ranges
    • inputRange: [See InputRange] filter based on map conditions like "zoom", "lon", "lat", "angle", or "pitch"
    • featureState: [See FeatureState] filter based on feature state
    • fallback: if all else fails, use this value. A value of number itself or pull from feature properties using Property
    shadowColor?: string | Property<string>

    A LAYOUT Property.

    "#000"

    ex.

    { "shadowColor": "rgba(240, 2, 5, 1)" }
    

    ex.

    { "shadowColor": { "inputValue": { "key": "shadow", "fallback": "black" } } }
    
    • inputValue: [See InputValue] access value in feature properties
    • dataCondition: [See DataCondition] filter based on feature property conditions
    • dataRange: [See DataRange] filter based on feature property ranges
    • inputRange: [See InputRange] filter based on map conditions like "zoom", "lon", "lat", "angle", or "pitch"
    • featureState: [See FeatureState] filter based on feature state
    • fallback: if all else fails, use this value. A value of string itself or pull from feature properties using Property
    source?: string

    The source used to generate the layer

    type: "hillshade"

    Hillshade Style Guide

    [See LayerStyleBase]

    • name: the name of the layer, useful for sorting a layer on insert or for removal
    • source: the name of the source whose data this layer will use
    • layer: the source's layer. Defaults to "default" for JSON data
    • minzoom: the minimum zoom level at which the layer will be visible
    • maxzoom: the maximum zoom level at which the layer will be visible
    • filter: [See Filter] a filter function to filter out features from the source layer
    • lch: use LCH coloring instead of RGB. Useful for color changing when the new color is very different from the old one
    • visible: whether the layer is visible or not
    • metadata: additional metadata. Used by style generators
    • opacity: the opacity of the hillshade. Choose between [0, 1], or pull out the value using a Property.
    • azimuth: the azimuth of the sun's position casting the light in degrees [0, 360]. Input a number or pull out the value using a Property.
    • altitude: the altitude of the raster in degrees [0, 90]. Input a number or pull out the value using a Property.
    • shadowColor: Color of the shadows. Input either a string pull out the value using a Property.
    • highlightColor: Color of the highlights. Input either a string pull out the value using a Property.
    • accentColor: Color of the accents. Input either a string pull out the value using a Property.
    • fadeDuration: The time it takes for each raster tile to fade in and out of view in milliseconds
    • unpack: [See UnpackDefinition] Descriptor to help the GPU know how to unpack the incoming RGBA data into a f32.

    A property to unpack the hillshade data via the GPU.

    The formula used by the GPU is as follow: (color.r * rMultiplier + color.g * gMultiplier + color.b * bMultiplier + color.a * aMultiplier) * zFactor + offset

    The WebGPU code is as follows:

    fn getElevation(
    uv: vec2<f32>,
    ) -> f32 {
    var color = textureSample(demTexture, imageSampler, uv);
    return (
    (
    color.r * unpack.rMultiplier +
    color.g * unpack.gMultiplier +
    color.b * unpack.bMultiplier +
    color.a * unpack.aMultiplier
    ) * unpack.zFactor
    ) + unpack.offset;
    }

    (Mapbox encoding):

    {
    "offset": -10000,
    "zFactor": 0.1,
    "aMultiplier": 0,
    "bMultiplier": 1,
    "gMultiplier": 256,
    "rMultiplier": 65536 // 256 * 256
    }

    Should you need to use terrarium data, you can copy paste the following values:

    {
    // (color.r * 256. + color.g + color.b / 256.) - 32768.;
    "offset": -32768,
    "zFactor": 1,
    "aMultiplier": 0,
    "bMultiplier": 0.00390625, // 1 / 256
    "gMultiplier": 1,
    "rMultiplier": 256
    }
    visible?: boolean

    Whether the layer is visible or not