getShaderColorFromString
[r, g, b, a] tuple where each channel is in the 0–1 range. This is the format expected by shader vec4 color uniforms.
Supported input formats
| Format | Example |
|---|---|
| 3-digit hex | '#f0f' |
| 6-digit hex | '#6366f1' |
| 8-digit hex (with alpha) | '#6366f1cc' |
rgb() | 'rgb(99, 102, 241)' |
rgba() | 'rgba(99, 102, 241, 0.8)' |
hsl() | 'hsl(239, 84%, 67%)' |
hsla() | 'hsla(239, 84%, 67%, 0.8)' |
[r, g, b] array | [0.39, 0.40, 0.95] (already normalized) |
[r, g, b, a] array | [0.39, 0.40, 0.95, 1] (already normalized) |
undefined or an unrecognized format, the function returns [0, 0, 0, 1] (opaque black) and logs a console error.
Usage
With ShaderMount (vanilla)
With React components
The built-in React shader components callgetShaderColorFromString internally on all color props, so you can pass CSS strings directly:
getShaderColorFromString yourself when using ShaderMount directly or building a custom shader.
getShaderNoiseTexture
HTMLImageElement preloaded with a grayscale noise texture (a tileable PNG encoded as a base64 data URL). This texture is used internally by several shaders for grain and noise effects.
Returns undefined when called in a server-side rendering environment (i.e. when window is not available).
Usage
The image is returned immediately with
img.src set to the data URL. Browsers typically decode data URL images synchronously, but you should ensure the image is fully loaded before using it as a shader uniform. If you pass it to ShaderMount before it’s loaded, the library will throw an error indicating the image must be fully loaded.emptyPixel
ShaderMount when a string uniform is an empty string.
Usage
UseemptyPixel as a placeholder to keep your shader valid before a real image loads: