I posted this in another thread but it was suggested I create a specific thread for it. Last week I released my open source SSR component for Unity 5 and wrote a lengthy article about it’s implementation.
Can this or SSR in general be used for window reflections or mirror reflections?
I’m fiddling with an arch viz scene in Unity trying to get some insight into the new shaders and graphical features of Unity 5 and the ugliest thing in my scene at the moment are the windows. If it’s dark outside and light inside an apartment you would expect the windows to act like mirrors, but no matter how I tweak the SSR component I can’t get the windows to look at all like real windows.
One issue seems to be that immediately when I change a material from opaque to transparent most, if not all, reflections go away immediately. Another issue is that the ray distance or something is way too short. I would expect to be able to see the entire room in the window reflection, but I can barely see the objects standing right next to the window, the rest is just seemingly grey fog.
I know this isn’t all that related to SSR, but I needed to subscribe to this thread and it’s at least somewhat related.
SSR won’t work for objects that are outside the camera frustrum, or behind the camera… so if you want to do a mirror or a super reflective window they won’t reflect anything with SSR when looking at them head-on. You would need to also use planar reflections for these objects… at least for the mirror. Glass isn’t anywhere near as reflective as a mirror is though, and really you should only be able to see defined reflection in it from extreme angles…
Ahh, obviously. Completely forgot about the screen space part of it all.
I guess there isn’t any games with properly reflecting windows then? That’s probably why all the Unreal Engine 4 arch viz demos decide to go for completely white overexposed windows as if you’re looking through a camera with fixed exposure. I really don’t want that though, I want everything to be dynamic.
Guess I will have to look at some of the more recent AAA games to see if they do anything to try and get seemingly realistic reflecting windows.
But thanks for the reply. At least I won’t waste any more time trying to get this to work. I’ll see if I can at least simulate some sort of usable reflections with reflection probes.
I very much disagree with your opinion about the reflectivity of glass though. Just google “Window reflection” and you’ll see that glass is extremely reflective and behaves exactly like a mirror if one side is lit and the other side is dark. I.e. like one-way mirrors in interrogation rooms. But as a human you’re also able to either focus through the window or on the reflections, which is not easy to simulate in a game setting I guess.
Well certainly, real life light and object properties are vastly more complex than anything we can simulate in a game or real-time environment However in general “glass” does follow typical rules for reflectance as other dielectric objects do. The more direct the facing angle of the glass (in relation to your viewpoint) the less reflective it will appear to be overall, whereas the more extreme the angle becomes the more reflective it becomes.
This reflectance property doesn’t really change if the environment beyond the glass becomes dark… but this is a complex subject and you’re right human perception probably complicates it all.
A nice physically-based exposure control would certainly help the issue, but I haven’t seen an adequate one in Unity, and trying to get the built-in auto tonemapper to do this for you is an exercise in futility.
Your idea of using a box-projected reflection probe would probably work fine. Though I still think planar reflection system would work best.
Incidentally, it occurs to me that you might want to look into “carpaint” shaders, as they often also address windshield glass as well…
But this doesn’t preclude SSR and this system by kode80 from being important… a good SSR system, combined with more specific(planar or box-projected) reflections complement each other very nicely. Personally I’ll be looking at integrating this into almost all the projects I do from here on out…
When it comes to proper mirror-like surfaces, planar reflections will definitely give you the best quality but add a lot of complexity if you want to balance performance - especially if you’re looking to have lots of windows and/or have a highly complex scene to begin with. Reflection probes are almost certainly your best bet here and if you look at even the latest AAA games are what every one resorts to for windows (often at comically low resolution at that). Unfortunately SSR doesn’t work very well with transparencies since transparent materials are rendered in a forward pass and SSR needs the deferred info to work.
Currently yes, although it’s a one line code change to switch that to use the roughness value if that works better for your project (use the alpha component rather than specular power from the GBuffer texture).
Not difficult at all, the only requirement is that you’re using deferred rendering. The only tie to the standard shader is using specular/smoothness to affect reflection blending/blur. You can easily remove all references to spec/smooth and replace them with your own implementation. For alpha, just remove the specular part (it’ll still fade reflections based on distance to screen edge, iteration count etc.) and then either remove the blur pass altogether or use some other property in your implementation to control it.