Search Unity

Planar Reflection Problems.

Discussion in 'General Graphics' started by Ravel, Aug 2, 2015.

  1. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Hello, I'm trying to get planar reflections to work on non planar surfaces, such as wet roads etc.
    Currently I'm doing everything "right" by book, the probe is set underneath the camera and there is a ray that detects the ground height. But there is a huge issue, there seem to be distorted normals everywhere and nothing seems to help, maybe there is a need for a custom surface shader?

    Here have a look, this is a screen captured in Unity:
    Unity Ground Reflection.JPG
    As you can see the reflections are messy allover the place and I had to use Box Projection to get them a little better. But it's a limitation in general.

    And here is a screen of how it should look like:
    gMotor Groud Reflection.JPG

    Any ideas on what's the case here? My own thought is that there's something to do with normals
     
  2. Jason-Nash

    Jason-Nash

    Joined:
    Apr 30, 2014
    Posts:
    20
    hi.
    In the first picture: are all of the three lanes a single mesh?
     
  3. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Yes the whole road is a single mesh, otherwise the box projection would not properly apply, because the box size is (10,10,10)
     
  4. Jason-Nash

    Jason-Nash

    Joined:
    Apr 30, 2014
    Posts:
    20
    Why don't you use screen space reflections?
     
    ImpossibleRobert likes this.
  5. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    Becuase they have their own limitations. And mainly they use to much resources, I prefeer to use cubemaps.
     
  6. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    After messing with some shader magic I'm 100% positive that it's all up to the normals, now I have to figure out what exactly must happen with the normals... normal directions to be exact, when I forced the normals direction up like this
    Code (CSharp):
    1.  
    2.             void vert(inout appdata_full v, out Input o)
    3.             {
    4.                 UNITY_INITIALIZE_OUTPUT(Input, o);
    5.                    float3 normalDirection = float3(0,1,0);
    6.                  v.normal = normalDirection;
    7.                }
    I was able to get perfectly planar reflections, meaning that there were usual clipping issues, like with Mirror script. So yeah I think it's shader related!
    :