Transparent material behind material with refraction is not visible

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Whypay

I have created a SpatialMaterial with refraction.

Behind that material is a material with transparent flag (using png texture).

The transparent material is not visible, if behind the material with refraction.

Is it possible to make the transparent material visible somehow?

Thanks.

:bust_in_silhouette: Reply From: SIsilicon

Quick answer:
No.

Long answer:
To understand why this wouldn’t work, you have to understand Godot’s rendering pipeline. In 3D, the first objects Godot renderers are ones with a solid material, i.e. materials that neither-

  1. Are transparent.
  2. Use the temporary screen buffer.

These solid objects are the ones that get rendered into this screen buffer, which by the way is the same texture available in a shader as SCREEN_TEXTURE.

It is this texture that SpatialMaterials use to render the refraction effect. So they don’t actually blend with the background like transparent materials normally would.
So with all these facts we can now come to a conclusion. Since transparent objects don’t get captured in the screen buffer, they will not show up in a refraction.