Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 beta is now available for download.
    Dismiss Notice

Nekativ's Standard PBR Realtime Stereo Planar Reflections

Discussion in 'General Graphics' started by Nekativ, Jul 22, 2017.

  1. Nekativ

    Nekativ

    Joined:
    Jun 30, 2017
    Posts:
    8
    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
    Example1.jpg

    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.
     

    Attached Files:

    Last edited: Jul 23, 2017
    Argenzio, Mauri and scvnathan like this.
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    966
    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:
    FINES_Cam11A.jpg
     
  3. Nekativ

    Nekativ

    Joined:
    Jun 30, 2017
    Posts:
    8
    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.
     
  4. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    966
    Yes, two depth buffers actually. The one of the main render and the one of the reflected render.
     
  5. Argenzio

    Argenzio

    Joined:
    Apr 27, 2014
    Posts:
    185
    Hello
    Thank you for this! Really it's a life saver!
    Support for single pass would be awesome.
    Thank you again for sharing
    Regards