Search Unity

simulating a reflective floor

Discussion in 'Editor & General Support' started by ratamorph, Nov 13, 2007.

  1. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    I´m trying to simulate a reflective floor, right now I´m using the script for realtime cubemaping in the documentation found in here..

    http://unity3d.com/support/documentation/ScriptReference/Camera.RenderToCubemap.html

    The problem I have is that the reflection seems to ignore the walls or other obstructing geometry. The reflections happen but I can see relfections that happen in other rooms. Maybe I´m not understanding correctly what this script should do.
     
  2. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    For a reflective floor you want to use some other script similar to the water. I think there is one on the wiki called mirror reflection or something.

    Render to Cubemap should be used for reflective objects like vehicles or other things like that.
     
  3. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    I think I understand my problem a little better now, I´m using a cubemap, the cubemap wraps around the object in this case a plane that represents the floor, but the cubemap never changes since I´m never moving the plane...

    Anyone have any idea how to make a reflective floor?, I tried the mirror shader + script but that one doesn´t seem to recieve any shadows and I need shadows...
     
    mmKokotang likes this.
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Like Yoggy says, you want planar reflections. E.g. MirrorReflection2 thing on the wiki.

    The shader would need to be turned into fully pixel-lit one to receive shadows. Or try the trick I posted here, where one material is pixel lit and receives shadows, and mirror would add reflections on top.
     
  5. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    Probably the easiest way is to modify the mirror reflection shader to receive shadows. You would take the first step on that by downloading the built in shaders and looking at how they do it.

    Another way is to make a copy of your room geometry and invert it along the Y axis at ground level, then use a transparent shader on the floor.
     
  6. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    Thanks for the replys guys! I'll give those a try.
     
  7. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    That worked like a charm, thanks a lot guys!!!!
     
  8. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    An offtopic suggestion: can you please use smaller avatar image? Otherwise we'll have to enforce the smaller limit, because right now your avatar of about 350x350 pixels really hurts thread readability.
     
  9. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    Opps sorry, I didn´t realized how huge the image was up until now, I just put it up...., I´ll find a smaller one.
     
  10. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    Ok, it works for the most part the shadows and reflections show up if my floor is in the default layer, if I put the floor in the water layer I lose the shadows. If I add water (I´m adding day light water) the reflection stops working or works partially...
     
  11. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    Quick question.

    By default this was a perfect mirror, but I would like to have the mirrored image to appear a lot darker.

    So I changed "white" to "grey" and found that it was allready a lot darker, but could somebody please help me a little to help the shader below to even be DARKER? Like instead of white I would prefer rgb(50,50,50) fully opaque to be the base color.

    Sorry, but I'm absolutely a big ZERO when it comes to shaders


    Shader "FX/Mirror Reflection" {
    Properties {
    _MainTex ("Base (RGB)", 2D) = "grey" {}
    _ReflectionTex ("Reflection", 2D) = "grey" { TexGen ObjectLinear }
    }

    // two texture cards: full thing
    Subshader {
    Pass {
    SetTexture[_MainTex] { combine texture }
    SetTexture[_ReflectionTex] { matrix [_ProjMatrix] combine texture * previous }
    }
    }

    // fallback: just main texture
    Subshader {
    Pass {
    SetTexture [_MainTex] { combine texture }
    }
    }

    }
     
  12. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    The "white" or "grey" just indicate which one-color texture to use when no texture at all is assigned. If you assign some real texture, you can have real textured reflective floor, and not just "white" or "grey".
     
  13. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    Ah great, then I'll experiment with that.

    Thanks,

    Bart
     
  14. nm8shun

    nm8shun

    Joined:
    Jul 14, 2007
    Posts:
    476
    Is there a way to turn the reflectivity down? Right now, I've got a texture, but the reflective floor is too reflective; too glossy. Can I reduce it so that it looks like my floor is slightly reflective rather than a mirror with painted wood slats ghosted on the surface?

    I've looked through both the .cs and the shader, and can't quite figure where to adjust for that....
     
  15. nm8shun

    nm8shun

    Joined:
    Jul 14, 2007
    Posts:
    476
  16. abul_ooz

    abul_ooz

    Joined:
    Aug 23, 2009
    Posts:
    12
    "The shader would need to be turned into fully pixel-lit one to receive shadows. "


    how do u do that? i have unity pro

    i selected shader and i got "per-pixel lit, cast shadows, render queue"etc. but they are all greyed out.

    "open compiled shader" does nothing

    what am i doing wrong?
     
  17. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    I want to use StrumpyShaderEditor to generate my own shader based upon the reflection texture generated by wiki.unity3d.com/index.php/MirrorReflection3.

    But I don´t know how to setup the nodes.
    Can anyone help me here?

    $StrumpyPlaneReflectionGraph.jpg
     

    Attached Files:

    Last edited: Jul 25, 2013
  18. vuthang

    vuthang

    Joined:
    Mar 7, 2017
    Posts:
    50