glslFunction
inline fun <T> glslFunction(arguments: String, code: String, libraries: List<GlslLibrary> = emptyList(), parameters: StyleParameters.() -> Unit = {}): GlslFunction(source)
A GLSL function that returns a T, with arguments, a GLSL parameter list such as vec2 p. code is an expression or a function body with return that can call the functions of libraries, parameters sets the parameters the code reads. Shade style code calls it as p_<name>(arguments), which makes shade styles that take functions, such as signed distance functions:
parameter("shape", glslFunction<Double>("vec2 p", "length(p - 0.5) - p_radius") {
parameter("radius", 0.25)
})
// in the shade style: float d = p_shape(c_boundsPosition.xy);Content copied to clipboard