vcti-shader-fringe
The fringe colormap shader feature: the fragment-stage math that turns a value into a colour.
Overview
A fringe plot colours a 3D model by the values at its nodes and elements.
Turning each fragment's value into an RGBA colour is what vcti-shader-fringe
does.
A colormap here is a list of bands. Each band covers a value range and carries the colours across it: one at each end, interpolated linearly or logarithmically, or the same colour at both ends for a flat band. Bands for below-range, above-range and missing values complete the list, so every value a fragment can hold lands in one. Three more colours stand in when none does — the value is NaN, it falls outside the list, or its band cannot be evaluated.
Which variant you build depends on the data. Continuous results — a displacement
magnitude, a von Mises stress — are floats and use Colormap. Categories — a
material id, a part number — are exact integers and use DiscreteColormap,
which keeps ids distinct up to 2³¹; carrying them as floats merges neighbouring
values above 2²⁴.
The package ships the Slang module a shader imports, the specs a build step emits, and the same lookup written in Python — which the tests diff the shader against, and which a legend renderer can call so its colours match the model. Nothing here compiles or runs a shader.
Installation
pip install vcti-shader-fringe
Requires Python 3.12, 3.13, or 3.14, matching vcti-shader-base, and so does
the test extra. Only the gl extra — the GL binding the shader tests need to
execute anything — is narrower in practice: on 3.14 it builds moderngl's
glcontext from source for want of a cp314 wheel, so those tests are run on 3.12
or 3.13.
In requirements.txt
vcti-shader-fringe>=2.0.0
In pyproject.toml dependencies
dependencies = [
"vcti-shader-fringe>=2.0.0",
]
Quick Start
What the feature is
from vcti.shader.fringe import DEFINITION, SLANG_DIR, ValueType, fragment_uniforms
DEFINITION.id # 'fringe'
DEFINITION.role # StageRole.FRAGMENT
DEFINITION.capabilities # ('fringe-float', 'fringe-int') — one per variant
DEFINITION.slang_modules # ('colormap.slang',) — a shader does `import colormap;`
SLANG_DIR # pass to the compiler as an import search path
[u.name for u in fragment_uniforms(ValueType.FLOAT)]
# ['u_bandBounds', 'u_numBands', 'u_lowerColors', 'u_upperColors',
# 'u_interpModes', 'u_interpSteps', 'u_nanColor', 'u_uncoveredColor',
# 'u_errorColor']
[u.name for u in fragment_uniforms(ValueType.INT)]
# ['u_bandBounds', 'u_numBands', 'u_bandColors', 'u_uncoveredColor']
A continuous colormap
linear_bands() turns bounds and a palette into ramped bands;
with_edge_bands() frames them so the list covers the whole number line:
from vcti.shader.fringe import Colormap, linear_bands, with_edge_bands
PALETTE = [(0.0, 0.26, 0.62, 1.0), (0.65, 0.84, 0.85, 1.0), (0.6, 0.0, 0.0, 1.0)]
GREY = (0.83, 0.83, 0.83, 1.0)
colormap = Colormap(
with_edge_bands(
linear_bands([0.0, 1.0, 2.0], PALETTE), # one colour per bound
below_color=PALETTE[0],
above_color=PALETTE[-1],
no_value_color=GREY,
no_value_lower=1e30,
)
)
colormap.validate() # raises ValueError on a gap, overlap, or bad log bound
constant_bands() gives banded contours — one colour per band, so it takes one
fewer colour than linear_bands() does. A band is flat when both its colours
are the same, which is all constant_bands() builds.
A discrete colormap
from vcti.shader.fringe import DiscreteBand, DiscreteColormap, category_bands
materials = DiscreteColormap(category_bands([STEEL, ALUMINIUM, COPPER]))
by_id = DiscreteColormap(( # raw solver ids, in ranges
DiscreteBand(1_000_000, 2_000_000, STEEL),
DiscreteBand(2_000_000, 3_000_000, ALUMINIUM),
))
Looking up a colour
fringe_color() is the Python version of the shipped Slang lookup:
from vcti.shader.fringe import fringe_color, fringe_color_int
# The colormap built above spans 0 to 2, ramping through PALETTE.
assert fringe_color(0.0, colormap) == PALETTE[0] # the first bound exactly
assert fringe_color(1.0, colormap) == PALETTE[1] # the middle bound
assert fringe_color(-1.0, colormap) == PALETTE[0] # below it, from the edge band
assert fringe_color(3.402823466e38, colormap) == GREY # the no-value sentinel
assert fringe_color(float("nan"), colormap) == colormap.nan_color
assert fringe_color_int(1_500_000, by_id) == STEEL # the category path
Those are assertions rather than comments because tests/test_docs.py executes
every block on this page: a claim that stops holding fails the suite instead of
misleading a reader.
Handing it to the GPU
colormap.uniforms()
# {'u_bandBounds': [(-inf, 0.0), (0.0, 10.0), ...], 'u_numBands': 5, ...}
Arrays are padded to MAX_BANDS; the shader reads only the first u_numBands.
Key API
| Name | What it is |
|---|---|
DEFINITION |
the ShaderDefinition the feature declares itself with |
SLANG_DIR |
the installed slang/ directory — an import search path |
fragment_uniforms(kind) |
the uniforms a shader declares, per variant |
fragment_inputs(kind) |
the vertex attribute the integer variant reads |
fragment_outputs() |
the fragColor output the feature writes |
ValueType |
FLOAT or INT — which variant a shader is built for |
Band |
one half-open range, its two colours, and its interpolation mode |
Colormap |
a band list, three fallback colours, and an optional step count |
DiscreteBand |
one half-open range of integer categories and its colour |
DiscreteColormap |
a band list and the colour for a category none holds |
Colormap.validate() |
raises on a gap, an overlap, or a log band reaching zero |
Colormap.uniforms() |
the {uniform: value} mapping, padded to MAX_BANDS |
linear_bands() |
bounds + one colour each → ramped bands |
constant_bands() |
bounds + one colour per band → flat bands |
category_bands() |
one band per consecutive integer category |
with_edge_bands() |
frames authored bands with below/above/no-value |
fringe_color(value, colormap) |
the colour a fragment takes — same result as the shader |
fringe_color_int(value, colormap) |
the same, for integer categories |
band_color(), band_parameter() |
the same, for a single band already in hand |
InterpMode |
LINEAR or LOG |
INTERP_MODES |
the same as a name-to-number map, as published on the spec |
MAX_BANDS |
band-array capacity, shared with the Slang module |
colormap.slang publishes applyFringe, applyFringeInt and
fringeBandColor. All take every value as an argument — nothing in the module
reads a uniform, so a shipped shader and the test probes run the same code from
different sources.
Dependencies
vcti-shader-base— theShaderDefinitionrecord and the spec types, itself zero-dependency.
Nothing else at runtime. vcti-shader-compiler and numpy are test-only:
the tests run the shader on a GPU and compare it against the Python version,
but declaring the feature needs neither.
Documentation
| If you want to… | Read |
|---|---|
| Get started using the package | Quick Start above |
| Build the colormaps a viewer actually ships | docs/patterns.md |
| Understand the colour model and the decisions behind it | docs/design.md |
| Navigate or modify the source | docs/source-guide.md |
Metadata
Release files for vcti-shader-fringe 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vcti_shader_fringe-2.0.0.tar.gz | 44.9 kB | With provenance | Details for vcti_shader_fringe-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vcti_shader_fringe-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for vcti_shader_fringe-2.0.0-py3-none-any.whl |
Total release size: 67.0 kB
Release files / vcti_shader_fringe-2.0.0.tar.gz
| Download URL | vcti_shader_fringe-2.0.0.tar.gz |
|---|---|
| Size | 44.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e57ccb418c8af14e01eddd9596d9b240d5fba48672407183d26375c5b1f0a4c5
|
|
BLAKE2b-256 checksum How to use checksums |
9e552089adaaba0470c55b3a012feaa25339be2b5ac5012ae875bba7d5ebe90c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logRelease files / vcti_shader_fringe-2.0.0-py3-none-any.whl
| Download URL | vcti_shader_fringe-2.0.0-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
33a87999789226b32c0c76c94307e4f3b0ba9feb80273848a16faac745bff6ae
|
|
BLAKE2b-256 checksum How to use checksums |
fd3efe5ed613eb93095c7a3b1c9cf701abc98ba504763f104979f269317e45d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logSecurity for vcti-shader-fringe 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for vcti_shader_fringe-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.