Principled BSDF shader for glass - gray artifacts

Hi, I’m quite new to blender and 3D modelling so go easy with the complexity of replies! I’m learning about the principled BSDF shader and trying to replicate the glass BSDF shader in a test with two cubes.
The only changes I’ve made to the default shader node settings are reducing the roughness to 0 in both, setting the transmission to 1 for the principled, and amending the base color for the principled to pure white. The two results look similar, but I am getting some strange gray artifacts on the principled shader result - the left hand side cube in the image. What is causing this?

Unfortunately as I’m a new user I can’t upload the blend file itself. But its quite simple, two default size cubes on a plane, with a single sun light, and material shaders as described above.

Thanks,
Pete.

Does this look like your problem?


(left cube is principled shader, right is glass)

My initial thought of what is happening was that it was z-fighting. This is when you have geometry perfectly intersecting with other geometry. As it turns out, it is highly likely this is your issue too. In your case, the cube’s underside is perfectly aligned with the ground, causing weird effects as at that point between them, at it could be glass or the ground. The grey colour comes from the surrounding environment which both yours and mine is set to grey.
So, it is not the principled shader causing it, or any shader for that matter. It is the cubes themselves. If you move the cubes just a tiny bit in the vertical direction, you should notice that the effect disappears.

Here is a different render showing what happens if you move the cubes slightly:

1 Like

Hi, thanks for looking at this for me. The discrepancy between the two cubes is definitely due to this z fighting with the glass shader cube base evaluating as below the plane and the principled above the plane. If I move them both up or down then they both behave the same with no grey below, and grey above.

So my follow-on question is where the grey is coming from and how to stop it. I understand about the discrepancy, but don’t understand why it reflects (?) the background when the base of the cube is any distance above the plane, and doesn’t reflect it when its slightly below.

I didn’t even know the world had a colour or that it affected the model ! I tried looked at the world settings and tried removing the background or changing its colour and strength but obviously that ends up with black or other colours in that grey region. How do you stop this happening for the case where the cube base is above the plane? I suspect this is a dumb question and blindingly obvious, or will be when someone explains it!

Thanks, Pete.

I believe it is because of internal reflection. Because of the light inside the cube of glass is sometimes at a shallower angle, it reflects internally rather than escaping. It shouldn’t be stopped if you want realism as it does happen a lot in real life too. It’s what gives diamond gems their brilliance and underwater surfaces the correct reflected look.

The world is a light source too. If you make it black or set the brightness to 0, it is the same as being in a completely enclosed room. You can bring in lamps, e.g. a sun lamp as you probably are using, but the light will only come from one direction - emitted from the lamp itself.
The grey environment for you is exactly what it is. A little bit of light is being emitted from the surroundings, not just the lamp objects or the sun, and is what gives shadows a lighter appearence just like in real life. Our atmosphere or nearby objects reflect and scatters light, making shadows brigher. In an airless environment like the moon, there is no such atmosphere, so the light really only comes from the sun directly, giving almost black shadows.
This too is important for realism. If you want to use lighting from a real-world enviromnent, I recommend using a HDRI as the texture of the surrounding environment. It would give better results.

1 Like

Hi, I’ve added a HDRI for the world, but I still get a really strong solid colour reflection of the background over the bottom quarter of the cube and on the top surface. Your image doesn’t seem to have either of these issues. The base of my cube base is currently just above the base plane. If I move the base so it is just below the base plane then the bottom colouring disappears, but the top remains. I am now allowed to upload files, so I’ve attached my blend file and the HDR file I used (from HDR labs).
Road_to_MonumentValley_Ref.hdr (3.6 MB)principled glass test.blend (634.3 KB)

I compared my render settings to the one in your image and tried setting all values the same as yours but that didn’t change anything. Would it be possible to get a copy of your blend file and HDR to load up and play with on my blender?

Thanks, Pete.

I’ve been looking at different real glass cube photos online and this lower section reflection seems to be a real effect but I can’t say that I understand how the internal reflections end up with this. I suspect it won’t ever be a real issue as I don’t plan to model glass cubes, but fascinating nonetheless! Its just annoying when you can’t figure out why something isn’t behaving as you expected. I think if I can understand the difference in the top reflection between mine and your model my OCD side will be willing to let this go… for now :slight_smile:
Thanks, Pete.

The image I posted eariler without the reflection was when the cube is sunken down a slight bit.

I still went and made a file for you to look at if it helps. (Google Drive link because I currently have some connection issue with this website and uploading doesn’t work)

Blender 2.82.7
Included HDRI is from HDRIHaven and is CC0 https://hdrihaven.com/hdri/?h=secluded_beach

1 Like

I just had a look at your file and I think its just the angle of camera which minimises the effect on your model screenshots. If I move the cam a bit it looks more like mine. Thanks so much for doing this.

I guess the conclusion of this is that if you want to artificially reduce problematic internal reflections then you can sink an object slightly into another, but if you want more realistic reflections then you need a small gap to the adjacent surface.

Thanks again, Pete. :+1:

1 Like