Fluted Glass
Free
Turns an image into streaked, ribbed glass with controls for flute shape, distortion, blur, shadows, highlights, and margins. Adapted from Fluted Glass by Paper Shaders (shaders.paper.design) under the Apache 2.0 license.
Code
Usage
<ShaderFlutedGlass
backgroundColor="#000000"
highlightColor="#ffffff"
shadowColor="#000000"
backgroundOpacity={0}
distortionShape="prism"
fluteShape="lines"
imageSrc="https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=1600&h=1200&fit=crop"
glassBlur={0}
glassMarginBottom={0}
distortionStrength={0.5}
edgeGrain={0}
edgeDistortion={0.25}
fluteAngle={0}
fluteSize={0.5}
grainOverlay={0}
highlightStrength={0.1}
glassMarginLeft={0}
glassMarginRight={0}
shadowStrength={0.25}
textureShift={0}
fluteStretch={0}
glassMarginTop={0}
graphicScale={1}
graphicRotation={0}
graphicOffsetX={0}
graphicOffsetY={0}
/>Props
| prop | type | default | description |
|---|---|---|---|
imageSrc | string | required | Image URL. The URL must be same-origin or served with CORS headers. |
imageAlt | string | required | Alternative text for the image. Pass an empty string for a decorative image. |
imageWidth | number | 1600 | Image width in pixels. Sets the aspect ratio with imageHeight. Defaults to 1600. |
imageHeight | number | 1200 | Image height in pixels. Sets the aspect ratio with imageWidth. Defaults to 1200. |
backgroundColor | string | #000000 | Color behind the image, visible where the glass pushes the image away. Accepts any CSS color. |
backgroundOpacity | number | 0 | Opacity of the background color. Range 0 to 1. |
shadowColor | string | #000000 | Shadow color. Needs shadows above 0. Accepts any CSS color. |
highlightColor | string | #ffffff | Highlight stroke color. Needs highlights above 0. Accepts any CSS color. |
shadowStrength | number | 0.25 | Shadow gradient that follows each flute. Range 0 to 1. |
highlightStrength | number | 0.1 | Thin strokes along each flute. They also smooth small grids. Range 0 to 1. |
fluteSize | number | 0.5 | Size of the flute grid. Range 0 to 1. |
fluteShape | "lines" | "linesIrregular" | "wave" | "zigzag" | "pattern" | lines | Shape of the flute grid. |
fluteAngle | number | 0 | Direction of the flutes in degrees. Range 0 to 180. |
distortionShape | "prism" | "lens" | "contour" | "cascade" | "flat" | prism | Shape of the distortion inside each flute. |
distortionStrength | number | 0.5 | Strength of the distortion inside each flute. Range 0 to 1. |
textureShift | number | 0 | Moves the image across the flutes. Needs distortion above 0. Range -1 to 1. |
fluteStretch | number | 0 | Extra distortion along the flute lines. Range 0 to 1. |
glassBlur | number | 0 | Blur along the flutes, stronger near the edges. Range 0 to 1. |
edgeDistortion | number | 0.25 | Glass distortion and softness at the image edges. Range 0 to 1. |
glassMarginLeft | number | 0 | Distance from the left edge to the glass. Range 0 to 1. |
glassMarginRight | number | 0 | Distance from the right edge to the glass. Range 0 to 1. |
glassMarginTop | number | 0 | Distance from the top edge to the glass. Range 0 to 1. |
glassMarginBottom | number | 0 | Distance from the bottom edge to the glass. Range 0 to 1. |
edgeGrain | number | 0 | Grain that breaks up the flute edges. Needs distortion above 0. Range 0 to 1. |
grainOverlay | number | 0 | Black and white grain added over the result. Range 0 to 1. |
graphicScale | number | 1 | Overall zoom level of the graphic. |
graphicRotation | number | 0 | Rotation of the graphic in degrees. |
graphicOffsetX | number | 0 | Horizontal offset of the graphic center. |
graphicOffsetY | number | 0 | Vertical offset of the graphic center. |
graphicFit | "none" | "contain" | "cover" | cover | How the graphic fits the box. |
opacity | number | 1 | Sets the opacity of the whole block, including the fallback image. |
maxDpr | number | 1.5 | Caps device pixel ratio for sharper output without runaway GPU cost. |
