Back to Help
Shader Parameters
You can add and remove any shader parameter from any shader in ShaderScope. ShaderScope uses Apple's own Metal compiler, so any valid Metal Shader Language should function properly.
Data type and address space are important when connecting a shader input to a shader parameter, so be sure to check the type to which an input can be connected by hovering over its connector
(the circle on its lower edge) and viewing its tooltip. Also note the address-of (&) prefix for the names of numeric shader parameters you'd like to feed a numeric or time-based value.
When it comes to interoperability with ShaderScope's user interface functionality there are some things to consider:
-
ShaderScope uses Apple's Model IO to operate on 3D model files, so when connecting those to a shader parameter that parameter should be of the data type that specifies Model IO attributes.
By default that type is the VertexIn type, which ties Model IO attributes 1-5 to variables in that struct. You can see the code for this struct preceding the shader code in each render
pipeline state, and you can even rename it and edit it if you'd like. Be aware that all 3D model data is passed to your shaders through those attributes when editing them.
-
The [[stage_in]] specifier can be used where appropriate, and you will see its use in many of the starter vertex and fragment shaders in ShaderScope, typically to denote vertex buffer data
in the former and interpolated vertex data from the rasterizer in the latter.
-
When choosing you buffer numbers for [[buffer(#)]] parameter notation, note that ShaderScope passes the uniforms that it needs and any scene lights you've added using three of these
numbers, so be careful not to duplicate them. These are all in the shader parameter code so you can see what they are, and ShaderScope will show a compilation error if you accidentally repeat one.
Back to Help