How to simulate a crystal surface?
by Jettelly
Published |
Share
Learn how to fake crystal and glass effects using shader tricks - no ray tracing needed. Covered in detail in Chapter 4 of the Godot Shaders Bible. Get the book early at a discount!
When it comes to rendering convincing crystal or glass surfaces, most developers immediately think of ray tracing, and for good reason. Ray tracing allows us to simulate light bouncing and refracting through translucent materials with stunning realism. However, this technique comes at a high computational cost and is still impractical for most mobile devices and lightweight games. That said, it’s only a matter of time before such effects become mainstream, even on entry-level GPUs.

But what if you want that crystal-like look today, without relying on expensive rendering techniques?

The answer lies in shader tricks.

In the following example, we’ve combined multiple shader techniques to simulate the illusion of refraction, reflection, and glitter - without a single ray being traced.

As you can see, the effect is broken into multiple layers, each carefully crafted to fake complex lighting behavior:

  • Refraction: Rather than calculating how light bends through the surface, we simply distort the UV coordinates based on the camera view direction and a depth approximation. This gives the illusion of bending light as it passes through the crystal.

  • Reflection: Instead of environment mapping or screen-space reflections, we use a matcap texture. By adding a subtle glitter based on the normals' divergence, we enhance the surface detail. This is rendered in a second pass to give it extra depth.

Despite these being “fakes,” the final result is surprisingly convincing:
Learn How It's Done, Step-by-Step
This technique (and many more like it) will be fully covered in Chapter 4 of the upcoming update to the Godot Shaders Bible, our in-depth book for artists and developers working with Godot.

Whether you’re new to shaders or looking to push the limits of what Godot can render, this book is designed to help you master everything from surface tricks like this one to complex lighting models, all explained with real examples and code you can use from a math perspective.

👉 Get the book in development now at a discount and be among the first to receive the new chapters as they’re released.
Jettelly wishes you success in your professional career! Did you find an error? No worries! Write to us at [email protected], and we'll fix it!

Subscribe to our newsletter to stay up to date with our latest offers

© 2024 Jettelly. All rights reserved. Made with ❤️ in Toronto, Canada