UnityRef is currently in early development. Some features may be incomplete and/or not functioning.

UNITYREF

Your Pit Stop For Solving ANYTHING in Unity

graphics

[URP] Fix Glass Material Transparency and Refraction

Solution

graphicsrenderingshaderslightingvisualsoptimization

Unity 2021.3.x - Unity 6.3.x

Published 20 days ago

Issue

 When attempting to render glass with transparency in Unity's Universal Render Pipeline, the desired visual effect, particularly when using a transparent base color texture alongside metallic and roughness maps, may not be achieved. This often results in glass appearing as a flat semi-transparent gray or failing to distort the background correctly compared to high-fidelity rendering environments.

Explanation

To properly render transparent glass within the Universal Render Pipeline, it is essential to isolate your glass material from other materials applied to your model. This ensures that transparency and Refraction properties can be managed distinctly.

  1. In the Project window, locate and select the active URP Asset (found in the Graphics settings).
  2. Under the General tab, ensure the Opaque Texture option is checked. This allows your glass material to sample the scene color for Refraction.
  3. Open the Material inspector for your glass. Set the Surface Type to Transparent and the Blending Mode to Alpha.
  4. Scroll down to the Surface Inputs and ensure Refraction is enabled. Adjust the Distortion and Index of Refraction values to achieve the desired physical accuracy.
  5. If using Shader Graph, ensure the Screen Space Refraction node is utilized to sample the Scene Color properly.

Additional Tips:

  • Use a Smoothness value close to 1.0 to ensure the Refraction isn’t blurred by micro-surface detail.
  • For high-performance mobile projects, consider using a simple Alpha Blend without Refraction if the Opaque Texture pass is too costly.
  • Ensure your model’s mesh has properly calculated normals; inverted normals will cause the Refraction to distort inward rather than outward.

TL;DR

To achieve proper glass transparency within Universal Render Pipeline, the glass material must be separated from other materials, and Refraction must be enabled within the URP Asset settings to leverage the Opaque Texture for realistic distortion.


Related Posts Haven't quite found a solution to your problem? We think these posts might help you.

Content inspired by a Unity discussion post.