Nekativ's Standard PBR Realtime Stereo Planar Reflections

Here is my chance to give a little bit back to a helpful community.

This is an extension to the standard shader to support realtime planar reflections for objects on a specific layer. The realtime reflections are combined with the reflections from the reflection probe. The reflections are properly distorted by the normal map and will have the proper roughness from the smooth map and smoothness slider.

Basically, apply the script to the floor or tabletop, select this shader over standard, and everything should act as if you are using the standard shader only now you have realtime reflections from the objects on your desired layer.

Smooth>LessSmooth>LeastSmooth

The brief backstory is you shouldn’t use deferred rendering with VR since VR looks terrible without MSAA and the performance cost is too high. This leaves out using SSR since it is not compatible with forward rendering mode.
As a result of the above limitation, all dynamic objects appear to be floating especially in situations where the dynamic object is not casting dynamic shadows because it’s in an occluded area. Ambient Occlusion could help alleviate this effect however the cost for AO is too high in combination with super sampling.
This solution helps improves immersion a lot. As for performance in VR, I am at 120fps with SS at 2 in my Vive with a full scene. I have a Gforce GTX 1070.

I am calling this version 0.9 until I can address the following shortcomings:

-I would like to add single-pass support, right now it is multi-pass only for VR

-The convolution on the planar reflection is simple Gaussian blur, I would like to explore making this more like the specular convolution in the cube maps, however I have more to learn on this subject and I am not sure if it really matters.

-I would like to add an extendable list in the inspector for “PlanarReflections.cs” that will contain the specific materials you want “PlanarReflections.cs” to send the reflection texture it is generating too. This will help with managing several instances of “PlanarReflections.cs” on multiple surfaces.

If you have any additional ideas, please let me know and I will implement it if I am able.

I am happy to have this picked apart by those that know more. So please if you have any insight on how to make this better please let me know.

3155480–239976–Nekativ_PlanarReflections_0.9.zip (9.03 KB)

4 Likes

I already looked into this and came to the conclusion that Gaussian is actually a very good approximation. The thing you are missing is that the actual amount of blur of the reflection also greatly depends on the distance between the reflecting and reflected surfaces. (The same actually goes for the effect the normal map has.)

When you are using multiple blur levels, the advantage of Gaussian is that it can be stacked. Apart from rounding and sampling differences a blur with deviation 3 on top of a blur with deviation 4 is the same as a single blur with deviation 5.

Where the floor reflects the book case is a good example of the variation in blur here:
3156947--240130--FINES_Cam11A.jpg

Very nice.

Do you use the depth map of a texture to determine how blurry something should be based on the distance from the reflective surface?

Also I have briefly read about utilizing fourier transforms to achieve a faster more effective blur however I haven’t looked into it past reading that statement.

1 Like

Yes, two depth buffers actually. The one of the main render and the one of the reflected render.

1 Like

Hello
Thank you for this! Really it’s a life saver!
Support for single pass would be awesome.
Thank you again for sharing
Regards

Hi Nekativ,

Had to change line 105 to float4 in shader for it to work in Unity 2018.
Works great, understandably it takes a decent performance hit when i’m using it on 3 mirrors (car with rearview mirrors)

What would it take for it to work in single pass?

I’ve tried 3 different solutions for mirrors in VR and yours is the only one i could get to work.

Thanks!

Thanks for the information, I will go ahead and update the shader. Perhaps I should put this up on github…

I will look back into adding single pass support, hopefully the API has evolved more.

I’m on a project that’s well into development (so I couldn’t just swap to hdrp and use the new planar probes) and I wanted dynamic reflections on the shiny floors in vr, this works perfectly. Thank you so much.