Skip to content

ShaderDescription ​

Introduction ​

The WGSL source of one shader stage, along with the inputs and outputs that are substituted into it.

Methods ​

addBuiltinInput ​

Add a builtin input, e.g. @builtin(vertex_index) vertexIndex, to the shader's input struct.

ArgumentTypeRequiredDescription
typeStringYesthe WGSL type, e.g. u32
nameStringYes

addBuiltinOutput ​

Add a builtin output, e.g. @builtin(position) Position, to the shader's output struct.

ArgumentTypeRequiredDescription
typeStringYesthe WGSL type, e.g. vec4<f32>
nameStringYes

addOutput ​

Add a location output to the shader's output struct.

ArgumentTypeRequiredDescription
typeStringYesthe WGSL type, e.g. vec4<f32>
nameStringYes
interpolationStringNothe WGSL interpolation qualifier

extend ​

Method used to decorate a given object (publicAPI+model) with vtkWebGPUShaderDescription characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIWebGPUShaderDescriptionInitialValuesNo(default: {})

getCode ​

Get the WGSL source of the shader.

getHash ​

Get the hash identifying the shader source.

getOutputInterpolations ​

Get a copy of the interpolation qualifiers of the location outputs. An entry is undefined when the output was added without one.

getOutputInterpolationsByReference ​

Get the interpolation qualifiers of the location outputs without copying them.

getOutputNames ​

Get a copy of the names of the location outputs.

getOutputNamesByReference ​

Get the names of the location outputs without copying them.

getOutputTypes ​

Get a copy of the WGSL types of the location outputs.

getOutputTypesByReference ​

Get the WGSL types of the location outputs without copying them.

getType ​

Get the shader stage this description is for.

hasOutput ​

Check whether an output of that name was already added.

ArgumentTypeRequiredDescription
nameStringYes

newInstance ​

Method used to create a new instance of vtkWebGPUShaderDescription.

ArgumentTypeRequiredDescription
initialValuesIWebGPUShaderDescriptionInitialValuesNofor pre-setting some of its content

replaceShaderCode ​

Substitute the IOStructs tokens of the code with the input and output structs of this stage. The inputs are taken from the outputs of the prior stage and, when provided, from the vertex input.

ArgumentTypeRequiredDescription
priorStagevtkWebGPUShaderDescriptionYesthe preceding shader stage
vertexInputvtkWebGPUVertexInputNo

setCode ​

Set the WGSL source of the shader.

ArgumentTypeRequiredDescription
codeStringYes

setHash ​

Set the hash identifying the shader source.

ArgumentTypeRequiredDescription
hashStringYes

setType ​

Set the shader stage this description is for.

ArgumentTypeRequiredDescription
typeWebGPUShaderTypeYes