Remix.run Logo
explosion-s 4 days ago

I made something similar to this with WebGL shaders (the benefit being it works across browsers): https://real-glass.vercel.app - The tricky thing for me was making it refract real HTML elements behind

kubeio 4 days ago | parent | next [-]

I considered WebGL, and I agree—a shader is more performant for real-time effects.

But WebGL comes with drawbacks:

- You need JS code running before anything shows up.

- Shaders can’t directly manipulate the DOM render. To make refraction work, you’d have to re-render everything into a canvas—which isn’t really “the web” anymore.

With the SVG/CSS approach, you can pre-render the displacement map (at build time or on the backend) and get the refraction visible on the very first frame. Plus, it integrates cleanly with existing, traditional UIs.

That said, this approach could definitely be improved. Ideally we’d have shader-like features in the SVG Filter spec (there was a proposal, but it seems abandoned). There are some matrix operations available in SVG Filters, but they’re limited—and for my first blog post I wanted to focus more on pedagogy, art, and technique than heavy optimization.

kkkqkqkqkqlqlql 4 days ago | parent [-]

I'm on mobile and your site works much better than the WebGL one.

Lorin 4 days ago | parent | prev | next [-]

What is causing the ghosting/delay when moving the glass over text?

kaptainscarlet 4 days ago | parent [-]

probably shaders are compiling and initialising on every drag movement

cycomanic 4 days ago | parent | prev | next [-]

Cool this looks like it even has dispersion, i.e. colors separate at the edge of the glass element.

lagrange77 4 days ago | parent [-]

https://en.wikipedia.org/wiki/Chromatic_aberration

?

cycomanic 3 days ago | parent [-]

Yes chromatic abberation is caused by dispersion.

lagrange77 3 days ago | parent [-]

Damn, outnerded.

IshKebab 4 days ago | parent | prev | next [-]

Looks nice! It's too slow to actually use though. Op's is much smoother.

qzio 4 days ago | parent | next [-]

It's the opposite on my macbook pro/chrome computer... the OP is unusable, but the webGL version is super smooth

kaptainscarlet 4 days ago | parent [-]

it's extremely quick on my M3 Mac too.

thisOtterBeGood 4 days ago | parent | prev [-]

Not over here. As far as I understand Op's solution does not utilize a gpu.

freehorse 4 days ago | parent [-]

I actually see gpu utilisation in OP's website when I move things (m3 pro), but this other solution shows much less gpu utilisation (prob more efficient?).

davidmurdoch 4 days ago | parent | prev [-]

Impressive!