Diorama

Made for a big screen.

This site is one 3D scene, built for a computer: a wide window and a mouse. Open dioramajs.dev on a desktop or a laptop to see it.This site is one 3D scene, built for a wide window. Make this one wider, or open dioramajs.dev on a larger screen.

GitHub

DioramaDocs

GlslShader interface

Default export of a `?shader` import.

View as Markdown
import type { GlslShader } from '@dioramajs/diorama/glsl'

build needs nothing but three/tsl.

interface GlslShader<P extends ParamSpec = ParamSpec>

Members

NameTypeDescription
readonly animate'hover' | 'input' | 'visible'

Frame policy of the effect.

readonly animateFromPragmaboolean

Whether animate comes from a pragma rather than the inputs it reads.

readonly bleednumber

Extra space around the box, CSS px.

readonly colorSpace'srgb' | 'linear'

Colour space of its output.

readonly dialect'three' | 'glsl3' | 'shadertoy'

GLSL flavour the source was written in.

readonly externalsreadonly string[]

Prototypes the caller provides through functions.

readonly filestring

Source file.

readonly mediaboolean

Whether it reads the element's image.

readonly namestring

Effect name, from the file name or the pragma.

readonly paramsP

Params of the effect, from param: uniforms.

readonly presence?'fade' | 'custom'

// @diorama presence=fade|custom.

readonly reducedMotion?'static' | 'off'

// @diorama reducedMotion=static|off.

readonly segmentsnumber

Plane segments per side, for position stages.

readonly stage'uv' | 'color' | 'position'

What the shader changes: the UV, the colour or the vertex position.

readonly textures{ [uniform: string]: string }

URLs from // @texture ./file pragmas, by uniform name.

readonly uniforms{ [name: string]: UniformInfo }

Uniforms by GLSL name.

readonly varyings{ [name: string]: GlslType }

Varyings this stage reads (fragment) or writes (vertex), besides uv.

readonly when?When

// @diorama when=…: media query the page must match, hover for (hover: hover).

readonly writesreadonly string[]

Varyings a vertex shader writes.

build
build(scope: ShaderScope): Node

Runs on every material build. Returns vec2 for uv, vec4 for color, vec3 for position.

Also exported from @dioramajs/glsl.

Defined in packages/glsl/src/types.ts.