โ† All examples

godot shaders

Screen-space glass refraction with dispersion

Transparent glass that bends the scene behind it by offsetting the screen texture with the view-space normal, splits the colour channels for dispersion, blurs with mip levels for frosted glass, and adds a Fresnel rim and tint.

Recorded render of Screen-space glass refraction with dispersion

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • component.json
  • demo.tscn
  • glass_refraction.gdshader
  • inspect_shader.py
  • material.tres
  • preview.png
  • test_package.py
  • verification/native.json

How it works

Shader type
spatial
Render modes
unshaded, cull_back, depth_draw_always, shadows_disabled
Parameters
screen_texture (sampler2D), tint (vec4 = 0.85, 0.95, 1, 1), refraction_strength (float = 0.08), dispersion (float = 0.25), frost (float = 0), fresnel_power (float = 4), fresnel_strength (float = 0.6), reflection_color (vec4 = 0.9, 0.95, 1, 1) and 1 more
Result
A clear sphere that magnifies and bends the scene behind it with coloured fringes at the edges.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/glass_refraction/

Recorded checks

godot 4.7.2.stable.official.ed1daf0bf

  • contract_static
  • engine_run
  • engine_log_clean
  • shader_in_scene
  • capture_written
  • render_not_uniform
  • shader_changes_pixels

Limits to consider

Screen-space: objects outside the screen or in front of the glass cannot be refracted, and edges of the screen clamp. Other transparent objects are not in the screen copy. The reflection is a flat colour, not the environment. Unshaded, so scene lights add no highlight.