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 getShaders.

mod

Either a character value naming a built-in set of mods (currently just "skins"), or a list of mods as described in the Details section.

...

Optional arguments; all will be passed to any functions in mods.

Details

The mods argument is organized in a nested list.

  1. The top level can contain vertexShader and fragmentShader components.

  2. Each of those is a list of changes to apply to that shader.

  3. Each change is a list with old and new entries.

  4. 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.

  5. 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.


[Package rgl2gltf version 1.0.3 Index]