modifyShaders {rgl2gltf} | R Documentation |
Edit shader code
Description
This function applies specified edits to shader code to support new functions.
Usage
modifyShaders(shaders, mod, ...)
Arguments
shaders |
A list of shaders, e.g. as produced by |
mod |
Either a character value naming a built-in set of mods (currently just |
... |
Optional arguments; all will be passed to any functions
in |
Details
The mods
argument is organized in a nested list.
The top level can contain
vertexShader
andfragmentShader
components.Each of those is a list of changes to apply to that shader.
Each change is a list with
old
andnew
entries.The
old
entry is used as a "fixed" pattern to select one or more lines from the shader to be replaced. Multiple matches are allowed, but they shouldn't overlap. Changes will be applied in the order specified, so take care that a pattern doesn't match new text from an earlier change.The
new
entry contains the replacement. It can either be a character vector or a function that returns a character vector. If it is a function, it will be passed the...
argument.See
rgl2gltf:::shaderChanges
for the built-in modifications.
Value
A new shader object incorporating the edits.