backends.wgsl.ShaderParameter

backends.wgsl.ShaderParameter(name, offset, components, value, free, depends=())

One design parameter’s place in the generated uniform buffer.

Attributes

Name Type Description
name str The parameter’s name — a free parameter’s declared name, or a fixed parameter’s node.attribute path. The same names :func:cadjoint.extract_parameters returns.
offset int Byte offset into the uniform buffer. Always a multiple of :data:PARAMETER_SLOT_BYTES.
components int How many floats the parameter occupies (1-4); the rest of its 16-byte slot is padding.
value tuple[float, …] The parameter’s current value, as a list of floats.
free bool Whether it is a free (named, optimizable) parameter.
depends tuple[str, …] For a slot derived from the parameters (a culling box), the names of the slots it was computed from; empty otherwise.

Methods

Name Description
as_dict This entry as a plain JSON-serializable dict.

as_dict

backends.wgsl.ShaderParameter.as_dict()

This entry as a plain JSON-serializable dict.

A value component that is not finite travels as null. JSON has no NaN — Python’s encoder writes a bare NaN that no strict parser, the browser’s JSON.parse included, will read — and these are not rare: a Material that leaves its physical properties unset (density, conductivity, Young’s modulus …) carries a NaN in every one of them, so almost every scene has some.

The null is not a substitution. Whoever packs the buffer turns it back into a NaN, because a NaN is what the literal form inlines into the same slot; the two forms must render the same image, and that includes agreeing about the values nobody supplied.