Defold Fake Real Glass

Defold Fake Real Glass

I’m happy to share with you a side project I was working on - porting a great a multipass fake glass effect based on the UnityURP-FakeRealGlass to Defold:

This project reproduces the core ideas from the Unity version:

  • screen-space double refraction
  • a back-face normals/depth pass
  • thickness-based distortion
  • optional local probe reflections
  • optional absorption
  • forward rendering
  • a movable specular light
  • runtime-configurable reflection probe modes and probe size

The repository includes two example Defold collections.

Installation

In order to use FakeRealGlass in your Defold game add project as a Defold library dependency. Don’t forget to fetch the libraries.

Newest version link:

https://github.com/paweljarosz/defold-fake-real-glass/archive/refs/tags/v1.0.zip

Once added, you must require the main Lua module in scripts via:

local fake_real_glass = require("fake_real_glass.fake_real_glass")

Quick Start

The easiest way to integrate this effect into your own project is to:

  1. Use the included fake_real_glass.render with the fake_real_glass.render_script using the fake_real_glass.lua as the reusable render module add-on, or modify your render pipeline to include fake_real_glass add-on (read more in the README).
  2. Use the glass_front.material on your glass models.
  3. Assign the fake_real_glass.script to control parameters of each glass model component.

I wrote a documentation in the repo, hope you’ll find it useful, not only for usage, but also for learning purposes :wink:

22 Likes