Download

[WIP] Improved Glass Material

Working on our FPS project - Triptych - and a marketplace kit of glassware - I met a pretty unpleasant problem. That is, glass material didn’t work as expected. Especially the specularity on translucent materials. Here I’ll post my progress on finding a workaround.

The progress so far:

The actual glass material:
glassmat7-1.png

Result:
bb4bff3d9ba9423da06a809d3e2ae6c359cf8dd1.jpeg

A fresnel mirror for the model:
3ddf969351002c3227f18de573cc322430e0d532.png

Result:
7fe1ee997384bd0041c7eb6e3ae84230c3591d05.jpeg

Combined approach:
d57b62c1ef035215e166ffed16d3eaebddc1b9ab.jpeg

First, let’s understand how glass material works in real life. Being an almost completely transparent material, it’s not opacity that makes it seen. Here’s a reference image to figure it out:

http://www.homeshopcatalogue.co.uk/catalogue/images/Rock-Glass-E049.jpg

As we can see, the albedo color and opacity have a minimal role here and can be safely ignored. We see glass via these factors:

Refraction
Surface specularity
Surface receives shadows

I handled the refraction on my setup the standard way, might go more in depth later though:

Glassmat1.png

Seeing how the translucent blend mode didn’t handle the results I needed, I tried the masked blend mode and fed a fresnel into the input. Here’s how that turned out:

Glassmat2.jpg

(fyi, the Fresnel phenomenon is that non-metallic surfaces turn into a perfect mirror when viewed from an angle close to 180 degrees). So basically this is a step in the right direction though causes specularity to affect the shadows. And the material still lacks “substance”, and the masked blend mode doesn’t support refraction.

So I decided to combine both approaches - use two instances of the same mesh with different materials - one to handle the specularity, one - the refraction and opacity. Doesn’t look much, but definitely better:

Glassmat3.jpg

I’ll keep you updated on my progress, and whether I find a better approach than placing two instances of the same mesh at the same location - which is a bit “dirty”, if you ask me.

Good Work! Love this!

Here’s the full shader network used to calculate glass specularity via Fresnel effect:

3ddf969351002c3227f18de573cc322430e0d532.png

As you can see, I used the xnormal-baked AO map to emphasize the shape of the glass - and it’s an useful tool to manipulate reflections.

Thanks mate :slight_smile: I saw many people had a question with this. Just trying to help and share thoughts.

There is word that Translucent specularity is handled in 4.8; but how it is done - it’s yet to be seen.

Sorry, had wrong image for shader network; fixed it now.

Both meshes side by side, to compare: the fresnel reflections are handled by the one on the left, and the standard glass material handling the refraction is on the right.

61d32ab04e335a5604dcc3cfc3ba804556fcee16.jpeg

The combined approach yields better results; but still far from perfection I’m afraid.

Remember to set the Fresnel mesh not to cast shadows; or else reflective parts will affect dynamic shadows, which isn’t exactly how you’d expect your material to work. Self-shadowing only is another possible choice.

Updated the first post to reflect the progress so far.

After some fine-tuning, here’s what my materials started to look like - a lot more acceptable and more surface, though now it has a bit of “milkiness” when exposed to light directly.

Glassmat9_zpsclfom5v4.png

Try using the Advanced Lighting Map from the starter content, glass relies on reflections and transparency to look good, and this starter map is a bit too bare.

I want it to look good in any lighting condition :slight_smile: that’s why I’m using this map. It’s about getting the physics right. But thanks for the advice.

When I finish the shading I’ll try to get the shadows and caustics.

Before rolling in the next version, here’s a bit of advice - DO NOT BAKE AO MAPS. Generate them from the normal map. Because the inside of the model is going to look awful. Also, a curvature map would be fun to play with, to map the reflections.