Skip to main content

vcti-shader-derive

The derived-value shader feature: the fragment-stage math that reduces a multi-component result to one scalar.

Overview

A CAE solver reports vectors and tensors — a displacement per node, a stress tensor per element. A colormap needs a single number. Turning one into the other is what vcti-shader-derive does, on the GPU, at draw time: given a stress tensor it produces von Mises, or a principal, or the xy component, and the fringe feature colours whatever comes out.

Doing it in the shader rather than ahead of it is the point. The result buffer is uploaded once, and switching from von Mises to max principal, or from one component order to another, sets a uniform — no re-upload, no CPU pass, no rebuilt shader.

The package ships one Slang module per data family:

Family Components What it derives
scalar 1 identity, absolute, unit conversions
vector 3 components, magnitude
dof6 6 translational and rotational components and magnitudes
symtensor 6 components, mean, von Mises, equivalent strain, principals, max shear, intensity, deviatoric principals

Around that math the package declares two things: the specs saying what each family needs supplied — which attributes, which uniforms — and the ShaderDefinition saying what the feature is. Both are plain data. Nothing here compiles or runs a shader; a build step does that, using what this package declares.

The math also exists on the CPU, in vcti-derived, which is where value ranges, legends and exports get the same numbers. Two implementations can disagree, so the test suite runs every dispatch case of every family headlessly on a real GPU — through the compiler's render_readback — and diffs it against the catalog. That is test machinery, and it ships with the source, not with the package.

Installation

pip install vcti-shader-derive

Requires Python 3.12, 3.13, or 3.14, matching vcti-shader-base and vcti-derived. Nothing native is built on that path, and nothing native is built by [test] either — only the [gl] extra pulls a GL binding, and only on 3.14 does that compile from source for want of a cp314 wheel.

In requirements.txt

vcti-shader-derive>=2.0.0

In pyproject.toml dependencies

dependencies = [
    "vcti-shader-derive>=2.0.0",
]

Quick Start

What the feature is

from vcti.shader.derive import DEFINITION

DEFINITION.id, DEFINITION.role.value      # ('derive', 'fragment')
DEFINITION.capabilities                   # ('scalar', 'vector', 'dof6', 'symtensor')
len(DEFINITION.slang_modules)             # 4 — one per family

DEFINITION is built at import, so importing the package is all it takes to have one. Its capabilities are one tag per data family, not one for the feature: a shader over a stress tensor takes different inputs from one over a displacement vector, and the two are not interchangeable, so a build step selects on the family it has data for.

Which derived types a family offers

Every derived type a family can produce is a case of one u_derivedType integer, and the table is built from the vcti-derived catalog rather than listed here:

from vcti.derived import DataFamily
from vcti.shader.derive import build_dispatch_table

cases = build_dispatch_table()[DataFamily.SYMTENSOR]
[(c.value, c.name) for c in cases][:4]
# [(0, 'xx'), (1, 'yy'), (2, 'zz'), (3, 'xy')]

next(c for c in cases if c.name == "von_mises").value    # 7 — write this to u_derivedType

Not everything in the catalog is here. A derived type ships as a GPU case only if it produces a scalar and all of its parameters have defaults — so principal directions and traction vectors are absent, because there is nothing to colour and a plane normal is field data rather than a uniform.

These integers are a wire contract. They are compiled into the switch in each .slang, written into built shaders, and stored by whatever selected one, so they are append-only. The value is vcti-derived's dispatch_id, declared upstream and read here rather than assigned, so a catalog reordering renumbers nothing; tests/test_dispatch.py pins the whole table as a cross-check that the declared values still match the Slang this package ships.

What its math needs supplied

Pick a family, and the specs follow from it:

from vcti.shader.derive import (
    component_order_uniform, derived_type_uniform, parameter_uniforms, result_attributes,
)

[(a.name, a.type, a.semantic) for a in result_attributes(DataFamily.SYMTENSOR)]
# [('a_result0', 'vec3', 'result.0'), ('a_result1', 'vec3', 'result.1')]

component_order_uniform(DataFamily.SYMTENSOR).gl_type          # 'int[6]'
derived_type_uniform({c.name: c.value for c in cases}).name      # 'u_derivedType'
[u.name for u in parameter_uniforms(p for c in cases for p in c.parameters)]
# ['u_nu'] — equivalent strain's Poisson ratio, the family's one parameter

Three things are worth knowing about that.

Results arrive packed. Multi-component data goes into vec3 attributes — ceil(n / 3) of them, zero-padded — because a vertex attribute is at most four components wide and a six-component tensor does not fit in one. The scalar family is the exception and uses a single float.

Component order is a uniform, not a repack. u_componentOrder maps each canonical slot to the lane the host actually packed it into, mirroring vcti-derived's ComponentOrder. A solver that writes (xx, xy, yy, …) is drawn by setting six integers rather than by rewriting the buffer.

Parameters are uniforms too. A defaultable parameter — equivalent strain's nu, an affine conversion's scale and offset — becomes u_<name>, so the derived type stays one dispatch case instead of one shader per value.

Building a shader from it

This package does not compile anything, so the last step belongs to a build step:

# 1. Give the compiler somewhere to resolve `import derive_symtensor;` from.
include_dirs = [DEFINITION.slang_dir]

# 2. Merge this feature's specs with a vertex-stage feature's.
attributes = vertex_attributes(stage) + result_attributes(family)

slang_dir is the field with teeth: the .slang files install inside this package, so only this package can resolve where they are.


Dependencies

  • vcti-shader-base — the zero-dependency vocabulary this feature declares itself with (ShaderDefinition, StageRole, AttributeSpec, UniformSpec).
  • vcti-derived — the catalog of derived fields. Unlike its sibling features, derive cannot describe itself without a second dependency: the dispatch table, the capability tags and the contract builders are all read off the catalog at import. The feature is a mirror of that catalog's GPU-supported subset, and the dependency is what keeps the mirror from drifting.

The rest are test-only — needed to run the shader, not to declare the feature, and split across two extras:

  • [test] — vcti-shader-compiler>=3.0, whose render_readback the suite drives to run the emitted math headlessly. The test module imports the compiler at module scope, so without it the tests fail to collect rather than skip — which is why it sits here and not under [gl].
  • [gl] — vcti-shader-compiler[gl], the GL binding that makes the probes actually run. Every shader package defines a gl extra meaning "what I need to execute shaders"; ci-shader.yml installs .[test,gl] on that contract.

Without [gl] the probe tests skip and everything else passes, which is the right default: compiling a GL binding is a cost only the machines that run shaders should pay.

Nothing that combines, selects, or discovers features: a feature declares itself and stops there.


Documentation

If you want to… Read
Get started using the package Quick Start above
Understand the derived-value model and the design decisions docs/design.md
Navigate or modify the source, including the Slang docs/source-guide.md

The full API reference is generated from the source docstrings and published in the unified VCollab docs.

Metadata

Release files for vcti-shader-derive 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vcti-shader-derive 2.0.0
File Size Uploaded Provenance Actions
vcti_shader_derive-2.0.0.tar.gz 30.7 kB With provenance Details for vcti_shader_derive-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vcti-shader-derive 2.0.0
File Interpreter ABI Platform Actions
vcti_shader_derive-2.0.0-py3-none-any.whl Python 3 none any Details for vcti_shader_derive-2.0.0-py3-none-any.whl

Total release size: 48.1 kB

Release files / vcti_shader_derive-2.0.0.tar.gz

Download URL vcti_shader_derive-2.0.0.tar.gz
Size 30.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9e56c3d16971ce3d8a7603d2f86b142d247f5b069f74aafdd67a0d54fe77bab3
BLAKE2b-256 checksum
How to use checksums
d26d74fce9727b618f16cbaf0126930093c984539cc8cc3c7a63e6558b141891
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 6, 2026.

Transparency log

Release files / vcti_shader_derive-2.0.0-py3-none-any.whl

Download URL vcti_shader_derive-2.0.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f82876b3be0e1d14db3ecf28a0c55d4f381edc5cc8ae734413e9509bfd64db21
BLAKE2b-256 checksum
How to use checksums
9e707be7657549aa422acd227ac0de37b148608657c9cb2ac48f41f71ba701ff
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 6, 2026.

Transparency log

Security for vcti-shader-derive 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.

Select from 2 files

Attestation for vcti_shader_derive-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 6, 2026.

Transparency log

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

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page