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.
| Argument | Type | Required | Description |
|---|---|---|---|
type | String | Yes | the WGSL type, e.g. u32 |
name | String | Yes |
addBuiltinOutput
Add a builtin output, e.g. @builtin(position) Position, to the shader's output struct.
| Argument | Type | Required | Description |
|---|---|---|---|
type | String | Yes | the WGSL type, e.g. vec4<f32> |
name | String | Yes |
addOutput
Add a location output to the shader's output struct.
| Argument | Type | Required | Description |
|---|---|---|---|
type | String | Yes | the WGSL type, e.g. vec4<f32> |
name | String | Yes | |
interpolation | String | No | the WGSL interpolation qualifier |
extend
Method used to decorate a given object (publicAPI+model) with vtkWebGPUShaderDescription characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IWebGPUShaderDescriptionInitialValues | No | (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.
| Argument | Type | Required | Description |
|---|---|---|---|
name | String | Yes |
newInstance
Method used to create a new instance of vtkWebGPUShaderDescription.
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IWebGPUShaderDescriptionInitialValues | No | for 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.
| Argument | Type | Required | Description |
|---|---|---|---|
priorStage | vtkWebGPUShaderDescription | Yes | the preceding shader stage |
vertexInput | vtkWebGPUVertexInput | No |
setCode
Set the WGSL source of the shader.
| Argument | Type | Required | Description |
|---|---|---|---|
code | String | Yes |
setHash
Set the hash identifying the shader source.
| Argument | Type | Required | Description |
|---|---|---|---|
hash | String | Yes |
setType
Set the shader stage this description is for.
| Argument | Type | Required | Description |
|---|---|---|---|
type | WebGPUShaderType | Yes |