Glass

유리 렌즈

A glass lens that refracts content beneath a custom shape and adds a soft luminous edge.

Also known as: GlassGlass lensRefractive glass

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, Glass, ImageTexture } from 'shaders/react'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: 320 }} disableTelemetry>
      <ImageTexture
        objectFit="cover"
        url="/samples/photo.jpg" />
      <Glass />
    </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, Glass, ImageTexture } from 'shaders/vue'
</script>

<template>
  <Shader style="width: 100%; height: 320px" :disable-telemetry="true">
    <ImageTexture
      object-fit="cover"
      url="/samples/photo.jpg"/>
    <Glass/>
  </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, Glass, ImageTexture } from 'shaders/svelte'
</script>

<Shader style="width: 100%; height: 320px" disableTelemetry>
  <ImageTexture
    objectFit="cover"
    url="/samples/photo.jpg" />
  <Glass />
</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, Glass, ImageTexture } from 'shaders/solid'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: '320px' }} disableTelemetry>
      <ImageTexture
        objectFit="cover"
        url="/samples/photo.jpg" />
      <Glass />
    </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: 'Glass',
    }
  ]
}, { disableTelemetry: true })

Props · Glass

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 glass shape
scaleScale10.1 – 3 (step 0.01)Scale of the glass shape (1 = default size)
rotationRotation00 – 360 (step 1)Rotation of the glass shape in degrees
cutoutCutoutfalse—Cut out the alpha outside the glass shape
refractionRefraction10 – 2 (step 0.01)Lens refraction — how aggressively the edges warp content beneath (0 = none, 1 = max)
edgeSoftnessEdge Softness0.10 – 1 (step 0.01)Edge softness — higher values give a wider, softer fade at the glass boundary
blurBlur00 – 20 (step 0.1)Frosted blur amount — 0 = clear glass, higher = frosted/diffuse
thicknessThickness0.20 – 1 (step 0.01)Glass depth — how far inward from the edge the refraction extends
aberrationAberration0.50 – 1 (step 0.01)Chromatic aberration — splits RGB channels along the refraction vector
innerZoomInner Zoom10.5 – 3 (step 0.01)Inner zoom level — magnifies content seen through the glass
lightAngleLight Angle3000 – 360 (step 1)Light angle in degrees
highlightHighlight0.050 – 2 (step 0.01)Directional edge highlight — bright rim on the light-facing boundary
highlightColorHighlight Color#ffffff—Color of the directional edge highlight and specular glint
highlightSoftnessHighlight Softness0.50 – 1 (step 0.01)Specular highlight softness
fresnelFresnel0.10 – 1 (step 0.01)Fresnel rim glow — a soft luminous halo around the glass boundary
fresnelSoftnessFresnel Softness0.10 – 1 (step 0.01)Fresnel rim width — higher values spread the glow further inward
fresnelColorFresnel Color#ffffff—Color of the fresnel rim glow
tintColorTint Color#ffffff—Color tint applied to the internal directional gradient
tintIntensityTint Intensity00 – 1 (step 0.01)Intensity of the color tint applied to the glass 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 — when non-empty, activates SVG mode and triggers a shader recompile
shapeTypeshapeTypeSet in code—Active SDF shape type — triggers recompile when shape is switched. When empty, derived from shape JSON at mount time.

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

It looks like a clear glass piece placed over the screen: the content beneath bends near its edge, with a soft gleam around the rim.

Raise `refraction` for stronger edge warping and `blur` to turn clear glass into a diffuse surface. `thickness` controls how far refraction reaches inward, while `aberration` increases color separation.

Place an image or shape underneath so there is something to refract. A simple background keeps the glass outline readable; avoid putting it over small text, which can become hard to read.

When to use

Use it for glassy image cards, buttons that bend their backdrop, or luminous logo edges. Avoid it when there is little content underneath or small text must remain crisp.

Open as page ↗