Passing on the knowledge you've collected and pioneered through out your years in the industry is extremely generous and I just wanted to express my gratitude!
Excellent breakdown, always appreciated! Also, don't worry about showing 'crazy expensive' versions, because I work primarily with cinematic content so we can crank it up to 11 :)
Metallness (reflectivity) should be altered based on dot(viewNorm, pixelNorm). Most of the time, when you’re looking straight at the window, you mostly see through it with just subtle reflection, but when looking at a sharp angle you don’t see anything behind the glass, you see 100% reflection. Another thing that went through my mind is, how the brightness in front of / behind the glass affects the intensity of reflection. Like, when looking outside though the window at night, you mostly see your room, because there’s a lot of light in it. But if you turn it off, you mostly see the street regardless of how dark it is. Another example: when looking at the car from the street you see a lot of reflection (because it’s darker inside the car). When looking in the car through the window (daytime) you never see the cars interior reflection. Assuming there are pure glasses without any tint or reflective film In most scenarios you probably don’t need this effect, but in some cases it might make sense and add a lot to the final look.
Strata materials already support rough refraction (background blurring) in UE 5.1. Would be cool to see a full Strata course once it's production ready (probably 5.2 or 5.3) Upd. No, not 5.2, probably 5.3-5.5. And its called Substrate now.
Awesome tutorial sir, Unreal engine user here, is there a way I can make it so objects farther behind the glass are more blurred than the ones very close to it?
nice and helpful video!! I have a question about that, at the time 10:05(unity) and 24:20(unreal engine), it has the same problem that we can’t see a glass object thought another glass,how to fix it
We're sampling a texture to find out what the scene looks like behind the transparent object. That texture is rendered with only the opaque objects in the scene and it's done before the transparent objects have been rendered. That's why a transparent object doesn't show up - because it doesn't yet exist in the scene when the texture is rendered. If you want to see transparent objects through other transparent objects, you'll need to not use this technique, but make your object transparent by setting the alpha or opacity value less than one.
That may be true, you’re right. It wouldn’t look as nice or be accurate at all, but it might be cheaper. So many of these things depend on what your priority is.
I'm using engine version 5.2 and I have refraction disabled by default and it says this: takes in a texture or value that simulates index of refraction of the surface and when I turn on the index of refraction and do everything according to the instructions, then for some reason the glass strongly reflects the mirror and reflects itself, it turns out a recursion. Ie in the window I see the window and transparency at the same time, this is not normal. What to do? Maybe this is because the glass I have is thick? And it is necessary to do one polygon?
Had problems with the UE blurry reflections and then discovered it was because I have the post process volume translucency set to ray tracing. Is it possible to disable that on a particular material?
Great explanation, thank you! What if I want to make a glass that has a more physically plausible specular amount? In Unreal, when you make something less opaque, you also lose the specular component. So, if I have an opacity of 0.1, the total amount of specular I get is multiplied by that value. This shouldn't happen, glass doesn't become less reflective the more transparent it is. Basically, I'd like my glass to reflect say 5% from the front and 100% at grazing angle. What would be some good ways around this issue? Thank you, I love your channel! PS: Would it be possible to read the nearest env probes and use those for "rough refractions" instead of screenspace info?
You can use a Fresnel node for the opacity so that the glass is more opaque at glancing angles. That should be pretty easy. Another thing you could do is create the reflections yourself in the material by sampling a cube map with the reflection vector - and then use the brightness of that reflection to control the opacity as well. The only issue with that is that your reflections wouldn't always match the environment. You'd have to manage that manually.
Regarding using env probes for refraction, I don't recommend that as the results would be VERY inaccurate. You can usually get away with using probes for reflections because it's hard to judge the accuracy of reflections - but with refractions you're looking straight through the object to things on the other side and it's very easy to tell when they don't line up right.
It would be really helpful if you do the same tutorial for Unity - URP. Because URP is more common and creating real looking glass in URP is much more harder than in HDRP.
@@jbttbjtjjtbbtj4865 In the material, connect your texture or value to a One Minus node. This will invert the value so that what used to be white is black and what used to be black is white.
I thought refraction in UE was the inverse of the refraction index. Your glass bends light the wrong way and looks more like a mirage. (There's a bit more wrong with UE's refraction (at least in this setup, I'd like to know how to do things correctly for glass), for example, leave out the Fresnel and you get all kinds of screen space problems. Also, for a plane it should not work as a magnifying glass, but rather give some offsets when looking at objects at a glance, which it does not do correctly.) What is going on with the vanishing object in the Unity project? The one that is not visible through the glass? Also, at first there is very low resolution roughness and reflection, but later on it looks better. Did anything change there?
I have a issue, i wanted to make frozen glass, but also there is other glass behind the frozen glass. In your unreal engine example, when you look at the frozen glass, sphere glass dissapears. How can we show that sphere glass when we look through the frozen glass?
What you're asking for isn't possible to do with this method. I don't think it's doable at all - at least not in real time. It might be possible to do with ray tracing, but it would be really expensive. My recommendation is to make the glass blurry enough that you can't make out details of what's behind it.
Hi, setting the lightning mode to Surface TranslucencyVolume and Surface ForwardShading increases the number of operations on the material drasticly, do you know any way to be able to control this depending on the scalability / quality of material ?
Looking at that instruction count is comparing apples to oranges. The reason for this is that opaque shaders are only rendering the material description to the g buffer, whereas transparent shaders are doing the material description as well as all of the lighting - because they're rendered in the forward pass that happens after the opaque objects are rendered. So the extra instructions you see for transparent objects are the lighting calculations. Lighting is also being done for the opaque objects - but the cost of it doesn't show up in the instruction count - so it's not really a fair comparison.
However, if you want to create a VERY cheap transparent shader in UE, I recommend using one of the techniques in this video: th-cam.com/video/g9npyBv6NII/w-d-xo.html
@@BenCloward wow, thank you for your answer first!But I don't know how to describe it,different Unity versions of the noise algorithm problem? So, can I ask you, what's your versions of unity for car paint?
@@BenCloward Hi Ben, I've already verified that。There is no "hash type" option of my Voronoi node in my unity 2021.3, but not in unity 2023.1 alaph; Thank u again!!!
Passing on the knowledge you've collected and pioneered through out your years in the industry is extremely generous and I just wanted to express my gratitude!
I am just ecstatic! This is the best tutorial on glass shader!! Thanks, Ben!
Excellent breakdown, always appreciated! Also, don't worry about showing 'crazy expensive' versions, because I work primarily with cinematic content so we can crank it up to 11 :)
Metallness (reflectivity) should be altered based on dot(viewNorm, pixelNorm). Most of the time, when you’re looking straight at the window, you mostly see through it with just subtle reflection, but when looking at a sharp angle you don’t see anything behind the glass, you see 100% reflection.
Another thing that went through my mind is, how the brightness in front of / behind the glass affects the intensity of reflection.
Like, when looking outside though the window at night, you mostly see your room, because there’s a lot of light in it. But if you turn it off, you mostly see the street regardless of how dark it is.
Another example: when looking at the car from the street you see a lot of reflection (because it’s darker inside the car). When looking in the car through the window (daytime) you never see the cars interior reflection. Assuming there are pure glasses without any tint or reflective film
In most scenarios you probably don’t need this effect, but in some cases it might make sense and add a lot to the final look.
Oh wow 🥺, that's exactly what I was looking for! especially with the frost glass. I was using a totally wrong approach to it. Thank you!
Strata materials already support rough refraction (background blurring) in UE 5.1.
Would be cool to see a full Strata course once it's production ready (probably 5.2 or 5.3)
Upd. No, not 5.2, probably 5.3-5.5.
And its called Substrate now.
PERFECT TIMING!!!!!
someone needs to start a petition to get epic to add mipmaps for the scene color texture.
Awesome tutorial sir, Unreal engine user here, is there a way I can make it so objects farther behind the glass are more blurred than the ones very close to it?
Yes, you can drive the amount of blur based on the distance between the glass surface and the objects behind it. That's a cool idea!
@@BenCloward could I get pointers on how to do this sir?
nice and helpful video!! I have a question about that, at the time 10:05(unity) and 24:20(unreal engine), it has the same problem that we can’t see a glass object thought another glass,how to fix it
We're sampling a texture to find out what the scene looks like behind the transparent object. That texture is rendered with only the opaque objects in the scene and it's done before the transparent objects have been rendered. That's why a transparent object doesn't show up - because it doesn't yet exist in the scene when the texture is rendered. If you want to see transparent objects through other transparent objects, you'll need to not use this technique, but make your object transparent by setting the alpha or opacity value less than one.
I feel like using a blurry cubemap with parallax occlusion mapping for static scenes in Unreal would yield more performant results.
That may be true, you’re right. It wouldn’t look as nice or be accurate at all, but it might be cheaper. So many of these things depend on what your priority is.
I'm using engine version 5.2 and I have refraction disabled by default and it says this:
takes in a texture or value that simulates index of refraction of the surface
and when I turn on the index of refraction and do everything according to the instructions, then for some reason the glass strongly reflects the mirror and reflects itself, it turns out a recursion. Ie in the window I see the window and transparency at the same time, this is not normal. What to do? Maybe this is because the glass I have is thick? And it is necessary to do one polygon?
for the unity glass shader, if the smoothness is at 90% the reflection image on the glass should not be blurred - what gives?
Had problems with the UE blurry reflections and then discovered it was because I have the post process volume translucency set to ray tracing. Is it possible to disable that on a particular material?
Great explanation, thank you!
What if I want to make a glass that has a more physically plausible specular amount?
In Unreal, when you make something less opaque, you also lose the specular component. So, if I have an opacity of 0.1, the total amount of specular I get is multiplied by that value. This shouldn't happen, glass doesn't become less reflective the more transparent it is.
Basically, I'd like my glass to reflect say 5% from the front and 100% at grazing angle.
What would be some good ways around this issue?
Thank you, I love your channel!
PS: Would it be possible to read the nearest env probes and use those for "rough refractions" instead of screenspace info?
You can use a Fresnel node for the opacity so that the glass is more opaque at glancing angles. That should be pretty easy. Another thing you could do is create the reflections yourself in the material by sampling a cube map with the reflection vector - and then use the brightness of that reflection to control the opacity as well. The only issue with that is that your reflections wouldn't always match the environment. You'd have to manage that manually.
Regarding using env probes for refraction, I don't recommend that as the results would be VERY inaccurate. You can usually get away with using probes for reflections because it's hard to judge the accuracy of reflections - but with refractions you're looking straight through the object to things on the other side and it's very easy to tell when they don't line up right.
@@BenCloward Thank you for your replies, Ben! 🙂
How to add my textures maps on it? I have been trying to import my models from blender to UE, but I don’t know Jack squad about UE.
It would be really helpful if you do the same tutorial for Unity - URP. Because URP is more common and creating real looking glass in URP is much more harder than in HDRP.
Yes, that's a good point. Thanks for the suggestion!
@@BenCloward 👍👍👍
Do you happen to know how to do it?
Is there any chance to create such a glass effect with URP, so it works on mobile devices?
QUESTION: Could you add this to a metahuman or a character so it can look like a glass or water person? Can shaders also be animated?
Yes.
@BenCloward
Hi, i also have a question :
how to invert colors in transparent material so the white will be transparent and the black will show ?
@@BenCloward .
@@BenCloward
Please help. I've been struggling with this for days now
@@jbttbjtjjtbbtj4865 In the material, connect your texture or value to a One Minus node. This will invert the value so that what used to be white is black and what used to be black is white.
what if I want to see the backfaces through my model in the glass? what would I need to do?
I thought refraction in UE was the inverse of the refraction index. Your glass bends light the wrong way and looks more like a mirage. (There's a bit more wrong with UE's refraction (at least in this setup, I'd like to know how to do things correctly for glass), for example, leave out the Fresnel and you get all kinds of screen space problems. Also, for a plane it should not work as a magnifying glass, but rather give some offsets when looking at objects at a glance, which it does not do correctly.)
What is going on with the vanishing object in the Unity project? The one that is not visible through the glass? Also, at first there is very low resolution roughness and reflection, but later on it looks better. Did anything change there?
I am getting the same issues. Also, maybe it works fine in editor view, but once you bump in game it just looks awful lol (UE5.1)
On the note of "cheap version" - I'd love to get some input on achieving effects as cheaply as possible. Like, running on a shrivelled potato cheap.
I have a issue, i wanted to make frozen glass, but also there is other glass behind the frozen glass. In your unreal engine example, when you look at the frozen glass, sphere glass dissapears. How can we show that sphere glass when we look through the frozen glass?
What you're asking for isn't possible to do with this method. I don't think it's doable at all - at least not in real time. It might be possible to do with ray tracing, but it would be really expensive. My recommendation is to make the glass blurry enough that you can't make out details of what's behind it.
Thank you.
You can simulate the lens effect in ue as well but as far as I know you have to use actual raytracing.
Thank you so Much!
Hi, setting the lightning mode to Surface TranslucencyVolume and Surface ForwardShading increases the number of operations on the material drasticly, do you know any way to be able to control this depending on the scalability / quality of material ?
Looking at that instruction count is comparing apples to oranges. The reason for this is that opaque shaders are only rendering the material description to the g buffer, whereas transparent shaders are doing the material description as well as all of the lighting - because they're rendered in the forward pass that happens after the opaque objects are rendered. So the extra instructions you see for transparent objects are the lighting calculations. Lighting is also being done for the opaque objects - but the cost of it doesn't show up in the instruction count - so it's not really a fair comparison.
However, if you want to create a VERY cheap transparent shader in UE, I recommend using one of the techniques in this video: th-cam.com/video/g9npyBv6NII/w-d-xo.html
Hi Ben! Your videos are so great! I learned so much from you,But why is my Voronoi Node style different from yours?
How is it different?
@@BenCloward wow, thank you for your answer first!But I don't know how to describe it,different Unity versions of the noise algorithm problem? So, can I ask you, what's your versions of unity for car paint?
@@tigeryang-vg1tt I'm using 2023.1
@@BenCloward alpha version? ok! I'll try it by 2023.1! Thank u again!!!
@@BenCloward Hi Ben, I've already verified that。There is no "hash type" option of my Voronoi node in my unity 2021.3, but not in unity 2023.1 alaph; Thank u again!!!
hey how is the shader complexity?
very nice !!!
thanks, grate tutorial
Thanks mate
Nice video! How can I reach you? Would like to run an idea by you :)
ben@bencloward.com I don't have a lot of extra time for this sort of thing, but you're welcome to reach out.
no fresnel?
HDRP , not URP so it wont work there