ShadersModule

The ShadersModule exposes APIs to create Visual Shaders using JavaScript.

Properties

This module exposes no properties.

Methods

MethodDescription

blend

blend(src: ShaderSignal, dest: ShaderSignal, {"mode": Shaders.BlendMode}): ShaderSignal

Blends two colors with the specified blending mode.

colorSpaceConvert

colorSpaceConvert(color: ShaderSignal, {"inColorSpace": Shaders.ColorSpace, "outColorSpace": Shaders.ColorSpace}): ShaderSignal

Converts a color from the input color space to the output colorspace.

composition

composition(f: ShaderSignal, g: ShaderSignal): ShaderSignal

Returns a signal for the shader composition of the two given functions (e.g. texture and a transform).

derivative

derivative(val: ShaderSignal, {"derivativeType": Shaders.DerivativeType}): ShaderSignal

Returns a signal for the specified shader derivative of the given signal.

fallback

fallback(main: ShaderSignal, fallback: ShaderSignal): ShaderSignal

Forwards the main input if present, otherwise uses fallback.

fragmentStage

fragmentStage(val: ShaderSignal): ShaderSignal

Places the subsequent computation on val to the fragment stage.

functionScalar

functionScalar(): ShaderSignal functionVec2(): ShaderSignal functionVec3(): ShaderSignal functionVec4(): ShaderSignal

Returns a signal for the identity function over the specified type.

functionVec2

functionScalar(): ShaderSignal functionVec2(): ShaderSignal functionVec3(): ShaderSignal functionVec4(): ShaderSignal

Returns a signal for the identity function over the specified type.

functionVec3

functionScalar(): ShaderSignal functionVec2(): ShaderSignal functionVec3(): ShaderSignal functionVec4(): ShaderSignal

Returns a signal for the identity function over the specified type.

functionVec4

functionScalar(): ShaderSignal functionVec2(): ShaderSignal functionVec3(): ShaderSignal functionVec4(): ShaderSignal

Returns a signal for the identity function over the specified type.

gradient

gradient({"type": Shaders.GradientType}): ShaderSignal

Returns a signal for the specified gradient.

sdfAnnular

sdfAnnular(sdf: ShaderSignal, width: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape made annular (ring-like) by the specified width.

sdfCircle

sdfCircle(center: ShaderSignal, radius: ShaderSignal): ShaderSignal

Returns a signal for circle SDF shape.

sdfComplement

sdfComplement(sdf: ShaderSignal): ShaderSignal

Returns a signal of the complement of the given SDF shape.

sdfDifference

sdfDifference(sdf1: ShaderSignal, sdf2: ShaderSignal): ShaderSignal

Returns a signal of the difference of the two given SDF shapes.

sdfEllipse

sdfEllipse(center: ShaderSignal, halfSize: ShaderSignal): ShaderSignal

Returns a signal for ellipse SDF shape.

sdfFlip

sdfFlip(sdf: ShaderSignal, offset: ShaderSignal, normal: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape flipped around the plane given by the offset an normal.

sdfHalfPlane

sdfHalfPlane(offset: ShaderSignal, normal: ShaderSignal): ShaderSignal

Returns a signal for half-plane SDF shape.

sdfIntersection

sdfIntersection(sdf1: ShaderSignal, sdf2: ShaderSignal): ShaderSignal

Returns a signal of the intersection of the two given SDF shapes.

sdfLine

sdfLine(offset: ShaderSignal, normal: ShaderSignal, halfSize: ShaderSignal): ShaderSignal

Returns a signal for line SDF shape.

sdfMix

sdfMix(sdf1: ShaderSignal, sdf2: ShaderSignal, alpha: ShaderSignal): ShaderSignal

Returns a signal of the linear interpolation of the two given SDF shapes, modulated by alpha.

sdfPolygon

sdfPolygon(center: ShaderSignal, radius: ShaderSignal, numSides: ShaderSignal, {"sdfVariant": Shaders.SdfVariant}): ShaderSignal

Returns a signal for polygon SDF shape.

sdfRectangle

sdfRectangle(center: ShaderSignal, halfSize: ShaderSignal, {"sdfVariant": Shaders.SdfVariant}): ShaderSignal

Returns a signal for rectangle SDF shape.

sdfRepeat

sdfRepeat(sdf: ShaderSignal, pivot: ShaderSignal, size: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape's grid repetition. Shape should be centered at pivot and fit within the given size.

sdfRotation

sdfRotation(sdf: ShaderSignal, pivot: ShaderSignal, angle: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape rotated around the given pivot by the given angle.

sdfRotationalRepeat

sdfRotationalRepeat(sdf: ShaderSignal, pivot: ShaderSignal, radius: ShaderSignal, numTimes: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape's rotational repetition numTimes at the given radius. Shape should be centered at pivot and fit within the angular sector defined by numTimes at the given radius.

sdfRound

sdfRound(sdf: ShaderSignal, radius: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape rounded by the specified radius.

sdfScale

sdfScale(sdf: ShaderSignal, pivot: ShaderSignal, size: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape scaled around the given pivot by the given size.

sdfShear

sdfShear(sdf: ShaderSignal, pivot: ShaderSignal, shear: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape scaled around the given pivot by the given shear amount.

sdfSmoothDifference

sdfSmoothDifference(sdf1: ShaderSignal, sdf2: ShaderSignal, K: ShaderSignal): ShaderSignal

Returns a signal of the smooth difference of the two given SDF shapes, modulated by K.

sdfSmoothIntersection

sdfSmoothIntersection(sdf1: ShaderSignal, sdf2: ShaderSignal, K: ShaderSignal): ShaderSignal

Returns a signal of the smooth intersection of the two given SDF shapes, modulated by K.

sdfSmoothUnion

sdfSmoothUnion(sdf1: ShaderSignal, sdf2: ShaderSignal, K: ShaderSignal): ShaderSignal

Returns a signal of the smooth union of the two given SDF shapes, modulated by K.

sdfStar

sdfStar(center: ShaderSignal, radius1: ShaderSignal, radius2: ShaderSignal, numSides: ShaderSignal): ShaderSignal

Returns a signal for polygon SDF shape.

sdfTranslation

sdfTranslation(sdf: ShaderSignal, offset: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape translated by the given offset.

SdfTwist

sdfTwist(sdf: ShaderSignal, pivot: ShaderSignal, twist: ShaderSignal): ShaderSignal

Returns a signal of the given SDF shape twisted around the pivot by the given amount.

sdfUnion

sdfUnion(sdf1: ShaderSignal, sdf2: ShaderSignal): ShaderSignal

Returns a signal of the union of the two given SDF shapes.

textureSampler

textureSampler(texture: ShaderSignal, uv: ShaderSignal): ShaderSignal

Samples the given texture at the specified uv coordinates.

textureTransform

textureTransform(texture: ShaderSignal, transform: ShaderSignal): ShaderSignal

Transforms the given texture with the specified Mat3 transform.

vertexAttribute

vertexAttribute({"variableName": Shaders.VertexAttribute}): ShaderSignal

Returns a signal for the specified vertex attribute.

vertexTransform

vertexTransform({"variableName": Shaders.BuiltinUniform}): ShaderSignal

Returns a signal for the specified vertex transform.

Classes

This module exposes no classes.

Enums

EnumDescription

BlendMode

The BlendMode enum describes the blending mode.

BuiltinUniform

The BuiltinUniform enum describes the bultin shader uniforms.

ColorSpace

The ColorSpace enum describes the color space.

DerivativeType

The DerivativeType enum describes the shader derivative type.

GradientType

The GradientType enum describes the type of the shader gradient.

SdfVariant

The SdfVariant enum describes the SDF variant.

VertexAttribute

The VertexAttribute enum describes the bultin vertex attributes.