Skip to content

Instantly share code, notes, and snippets.

@divienginesupport
Last active August 7, 2025 07:14
Show Gist options
  • Save divienginesupport/e23bc7b4e08247c4dfb02b4a35cd0800 to your computer and use it in GitHub Desktop.
Save divienginesupport/e23bc7b4e08247c4dfb02b4a35cd0800 to your computer and use it in GitHub Desktop.
Apple Liquid Glass SVG
<svg style="display: none">
<!--
This SVG defines a custom filter for a liquid glass distortion effect.
It should be placed somewhere in your HTML (preferably near the top, such as in the <head> or before closing </body>).
-->
<filter id="de-glass-distortion" x="0%" y="0%" width="100%" height="100%" filterUnits="objectBoundingBox">
<!--
1) Turbulence: Generates a noise texture for the distortion
- `type="fractalNoise"` creates a smoother, cloudy noise
- `baseFrequency` controls the size and density of the noise
- `animate` cycles through different seeds to make the distortion look fluid
-->
<feTurbulence
type="fractalNoise"
baseFrequency="0.01 0.01"
numOctaves="1"
seed="5"
result="turbulence">
<animate attributeName="seed" from="1" to="200" dur="8s" repeatCount="indefinite"/>
</feTurbulence>
<!--
2) Color Mapping: Controls how the noise affects the RGB channels
- This stage adjusts the turbulence so it mainly affects the red channel (used for displacement)
- Green and blue channels are suppressed to reduce distortion in those axes
-->
<feComponentTransfer in="turbulence" result="mapped">
<feFuncR type="gamma" amplitude="1" exponent="10" offset="0.5"/>
<feFuncG type="gamma" amplitude="0" exponent="1" offset="0"/>
<feFuncB type="gamma" amplitude="0" exponent="1" offset="0.5"/>
</feComponentTransfer>
<!--
3) Blur: Softens the turbulence map for smoother distortion
-->
<feGaussianBlur in="turbulence" stdDeviation="3" result="softMap"/>
<!--
4) Lighting: Adds a specular light highlight based on the noise shape
- Simulates light reflecting off a bumpy glass surface
-->
<feSpecularLighting
in="softMap"
surfaceScale="5"
specularConstant="1"
specularExponent="100"
lighting-color="white"
result="specLight">
<fePointLight x="-200" y="-200" z="300"/>
</feSpecularLighting>
<!--
5) Composite: Merges the lighting effect with the noise
-->
<feComposite
in="specLight"
operator="arithmetic"
k1="0" k2="1" k3="1" k4="0"
result="litImage"/>
<!--
6) Displacement: Distorts the original graphic using the noise map
- `scale` controls intensity
- `xChannelSelector="R"` means distortion is driven by the red channel
- `yChannelSelector="G"` uses the (mostly suppressed) green channel
-->
<feDisplacementMap
in="SourceGraphic"
in2="softMap"
scale="150"
xChannelSelector="R"
yChannelSelector="G"/>
</filter>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment