GlslLibrary

class GlslLibrary(val name: String, val code: String, val dependencies: List<GlslLibrary> = emptyList())(source)

GLSL code that is shared by shade styles, compute styles and dynamic parameters: functions, constants, structs and macros, such as noise functions. Styles and GLSL parameters and functions declare the libraries they use, the code of a library is emitted once in every shader stage that reads one of its names, after the libraries in dependencies and before the preamble of the style.

Libraries are identified by name: libraries with the same name and code are emitted once, libraries with the same name and other code are an error. The names a library declares are not namespaced, they should be unique, for example by prefixing them with the name of the library. Library code is emitted before the shade style language values (c_) are defined in some shaders, it should not read them.

val hash = glslLibrary("hash", "float hash_21(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }")
val style = shadeStyle {
libraries += hash
fragmentTransform = "x_fill.rgb = vec3(hash_21(c_boundsPosition.xy));"
}

Constructors

Link copied to clipboard
constructor(name: String, code: String, dependencies: List<GlslLibrary> = emptyList())

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun toString(): String