Crystal

크리스털 렌즈

A faceted crystal lens that refracts and disperses content beneath it.

Also known as: CrystalDiamond crystalCrystal lens

Moves in browsers that support WebGPU

This device could not render the demo — showing a still

React
// Renders only in browsers with WebGPU.
// /samples/… are this site’s sample files — point them at your own image or video.
import { Shader, Crystal, ImageTexture } from 'shaders/react'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: 320 }} disableTelemetry>
      <ImageTexture
        objectFit="cover"
        url="/samples/photo.jpg" />
      <Crystal />
    </Shader>
  )
}
Vue
<!-- Renders only in browsers with WebGPU. -->
<!-- /samples/… are this site’s sample files — point them at your own image or video. -->
<script setup lang="ts">
import { Shader, Crystal, ImageTexture } from 'shaders/vue'
</script>

<template>
  <Shader style="width: 100%; height: 320px" :disable-telemetry="true">
    <ImageTexture
      object-fit="cover"
      url="/samples/photo.jpg"/>
    <Crystal/>
  </Shader>
</template>
Svelte
<!-- Renders only in browsers with WebGPU. -->
<!-- /samples/… are this site’s sample files — point them at your own image or video. -->
<script>
  import { Shader, Crystal, ImageTexture } from 'shaders/svelte'
</script>

<Shader style="width: 100%; height: 320px" disableTelemetry>
  <ImageTexture
    objectFit="cover"
    url="/samples/photo.jpg" />
  <Crystal />
</Shader>
Solid
// Renders only in browsers with WebGPU.
// /samples/… are this site’s sample files — point them at your own image or video.
import { Shader, Crystal, ImageTexture } from 'shaders/solid'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: '320px' }} disableTelemetry>
      <ImageTexture
        objectFit="cover"
        url="/samples/photo.jpg" />
      <Crystal />
    </Shader>
  )
}
JavaScript
// Renders only in browsers with WebGPU.
// /samples/… are this site’s sample files — point them at your own image or video.
// expects <canvas id="canvas" style="width:100%;height:320px"></canvas> on the page
import { createShader } from 'shaders/js'

const shader = await createShader(document.getElementById("canvas"), {
  components: [
    {
      type: 'ImageTexture',
      props: {
        objectFit: 'cover',
        url: '/samples/photo.jpg',
      },
    },
    {
      type: 'Crystal',
    }
  ]
}, { disableTelemetry: true })

Props · Crystal

Changes apply to the demo above and to the code tabs. Descriptions come from the library registry (MIT).

NameValueDefaultRange / optionsDescription
originOriginSet in codecenter—Reference edge the center position is measured from (center default). Lets you pin the shape relative to a corner or the canvas centre.
centerCenter
x0.5y0.5
{"x":0.5,"y":0.5}x, y: 0 – 1Center position of the crystal shape
scaleScale10.1 – 3 (step 0.01)Scale of the crystal shape (1 = default size)
rotationRotation00 – 360 (step 1)Rotation of the crystal shape in degrees
cutoutCutoutfalse—Cut out alpha outside the crystal shape
refractionRefraction0.50 – 3 (step 0.01)How strongly the crystal refracts content beneath
dispersionDispersion0.50 – 2 (step 0.01)Prismatic rainbow dispersion — splits light into spectral colors
facetsFacets53 – 24 (step 1)Symmetry order — how many times the facet pattern repeats around the center
fresnelFresnel0.050 – 1 (step 0.01)Fresnel rim glow intensity around the crystal boundary
fresnelSoftnessFresnel Softness10 – 2 (step 0.01)Fresnel rim width — higher values spread the glow further inward
fresnelColorFresnel Color#ffffff—Color of the fresnel rim glow
edgeSoftnessEdge Softness00 – 1 (step 0.01)Softness of the crystal boundary edge
innerZoomInner Zoom1.50.5 – 3 (step 0.01)Magnification of content seen through the crystal
lightAngleLight Angle2700 – 360 (step 1)Light direction angle in degrees
highlightsHighlights0.50 – 2 (step 0.01)Additive brightness on light-facing facets — never darkens
shadowsShadows0.30 – 1 (step 0.01)Darkening on shadow-facing facets — never brightens
brightnessBrightness1.20.5 – 3 (step 0.01)Overall crystal brightness — higher values push facets toward brilliant white
tintColorTint Color#e8e0ff—Crystal body tint color
tintIntensityTint Intensity00 – 1 (step 0.01)How much tint color is applied to the crystal interior
tintPreserveLuminosityPreserve Luminositytrue—Preserve original brightness when tinting
shapeShapeSet in code{"type":"sphere3D","radius":0.35}—Serialized shape configuration (JSON)
shapeSdfUrlshapeSdfUrlSet in code—URL to a pre-generated SDF .bin file
shapeTypeshapeTypeSet in code—Active SDF shape type

Every component also takes blendMode · opacity · visible · maskSource/maskType · boundingBox · id

It feels like looking through a cut gemstone: the image beneath bends across angular facets, and highlights split into spectral colors.

Raise `refraction` for stronger warping of the content below; `dispersion` increases rainbow separation. `facets` changes how many times the facet pattern repeats around the center, while `brightness` sets overall brilliance. Raise `tintIntensity` to add interior color.

Place an image or shape underneath so there is something for the lens to refract. Distinct forms make the effect easier to see; small text or a busy screen may become unreadable.

When to use

Use it for a jewel-like lens, a premium card accent, or a brief light transition. Avoid it over small body text or imagery that must stay undistorted.

Open as page ↗