Taking on a glass shader

Glass will an important material for the buildings, specially the ones from the “elite” – normal buildings will be shacks. So I was shopping for a great glass shader and I found Crystal Glass from qq.d.y. This set of shaders is great and easy to use, except for two major problems

  1. They do not react to Global Illumination which is a big issue in a environment with day/night cycles.
  2. They do not support an opacity map to simulate dirt. In one word, they are too clean.

The great thing about these shaders is that they are using SSR (Screen Space Reflections) that are way faster than using planar reflections. No need to render your scene to a camera.

I copied the logic of the shader in a classic surface shader from Unity, and used the _Main slot to get my opacity map, I added Cull Off to get my opacity map on both side of the glass, and that was it.

 

Now I have a great glass shader that is working really fast and is very realistic, it also follow the sun lighting as you can see in the pictures. This shader will be all over the place on the Elite buildings.

Here you can see the SSR reflections at work.

Here you can see the reflections + opacity + Global illumination.

Here you can see the screen space refraction. Yes refraction not reflection.

And here is what is looks in the night, with the reflection of the lightnings from the inside, thanks to the double sided mode.

Some more example at different time of the day.

And here are the pictures of the Generator once finished . Note that I use sub surface scattering for the tubes inside, and a rainbow glass shader for the ball. I also use an Ivy generator.

I have given up using Procedural Lightning because it is way too slow. It was eating some 20% of the game! I ended up using Connect Electricity that I map on a sphere, it takes 0% and has a close look.

And here it is in a video so that you can see it animated.

 

 

Author TheWolf
Published
Categories Research & Dev
Views 1939