유리 렌즈

Glass

도형 아래의 콘텐츠를 굴절시키고 가장자리에 빛을 더해 유리 렌즈처럼 보이게 합니다.

다른 이름: GlassGlass lensRefractive glass

WebGPU 를 지원하는 브라우저에서 움직입니다

이 기기에서는 데모를 그리지 못해 정지 화면을 보여 줍니다

React
// WebGPU 를 지원하는 브라우저에서만 그립니다.
// /samples/… 는 이 사이트의 샘플 파일입니다. 내 프로젝트의 이미지·영상 경로로 바꾸세요.
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
<!-- WebGPU 를 지원하는 브라우저에서만 그립니다. -->
<!-- /samples/… 는 이 사이트의 샘플 파일입니다. 내 프로젝트의 이미지·영상 경로로 바꾸세요. -->
<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
<!-- WebGPU 를 지원하는 브라우저에서만 그립니다. -->
<!-- /samples/… 는 이 사이트의 샘플 파일입니다. 내 프로젝트의 이미지·영상 경로로 바꾸세요. -->
<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
// WebGPU 를 지원하는 브라우저에서만 그립니다.
// /samples/… 는 이 사이트의 샘플 파일입니다. 내 프로젝트의 이미지·영상 경로로 바꾸세요.
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
// WebGPU 를 지원하는 브라우저에서만 그립니다.
// /samples/… 는 이 사이트의 샘플 파일입니다. 내 프로젝트의 이미지·영상 경로로 바꾸세요.
// <canvas id="canvas" style="width:100%;height:320px"></canvas> 가 페이지에 있어야 한다
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

값을 바꾸면 위 데모와 코드 탭에 바로 반영됩니다. 설명은 라이브러리 레지스트리의 영어 원문(MIT)입니다.

이름값기본값범위·선택지설명(원문)
originOrigin코드에서 지정center—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
shapeShape코드에서 지정{"type":"sphere3D","radius":0.35}—Serialized shape configuration (JSON)
shapeSdfUrlshapeSdfUrl코드에서 지정—URL to a pre-generated SDF .bin file — when non-empty, activates SVG mode and triggers a shader recompile
shapeTypeshapeType코드에서 지정—Active SDF shape type — triggers recompile when shape is switched. When empty, derived from shape JSON at mount time.

모든 컴포넌트 공통: blendMode · opacity · visible · maskSource/maskType · boundingBox · id

투명한 유리 조각을 화면 위에 올린 듯, 아래 이미지가 가장자리에서 휘어 보입니다. 유리 테두리의 은은한 빛도 함께 표현합니다.

`refraction`을 높이면 가장자리 굴절이 강해지고, `blur`를 올리면 맑은 유리가 뿌옇게 흐려집니다. `thickness`는 굴절이 안쪽으로 들어오는 깊이를, `aberration`은 색이 갈라지는 정도를 조절합니다.

아래에 이미지나 도형처럼 굴절될 콘텐츠를 먼저 놓아야 효과가 보입니다. 배경이 단순하면 유리 윤곽이 잘 읽히고, 작은 글자 위에서는 굴절과 흐림이 가독성을 해칠 수 있습니다.

언제 쓰나

이미지 카드의 유리 렌즈, 배경을 비트는 버튼, 빛나는 로고 테두리에 어울립니다. 아래 콘텐츠가 거의 없거나 작은 글자를 정확히 읽어야 하는 곳에는 피하세요.

페이지로 열기 ↗