// deck.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors export default `\ #version 300 es #define SHADER_NAME triangle-layer-fragment-shader precision highp float; uniform sampler2D weightsTexture; uniform sampler2D colorTexture; in vec2 vTexCoords; in float vIntensityMin; in float vIntensityMax; out vec4 fragColor; vec4 getLinearColor(float value) { float factor = clamp(value * vIntensityMax, 0., 1.); vec4 color = texture(colorTexture, vec2(factor, 0.5)); color.a *= min(value * vIntensityMin, 1.0); return color; } void main(void) { vec4 weights = texture(weightsTexture, vTexCoords); float weight = weights.r; if (triangle.aggregationMode > 0.5) { weight /= max(1.0, weights.a); } // discard pixels with 0 weight. if (weight <= 0.) { discard; } vec4 linearColor = getLinearColor(weight); linearColor.a *= layer.opacity; fragColor = linearColor; } `;