Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Reflection Probes best practices?

Discussion in 'Unity 5 Pre-order Beta' started by LaneFox, Oct 30, 2014.

  1. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Thats the fix for simple square shaped rooms, but have we got a good solution for L, + or curved rooms/halls?

    Seems like the general idea would be to blend the probes, but you can get some very obvious seams doing this. Not sure if it has changed, but this was the case in an earlier post:



    It seems to really start boiling down to hit and miss tests with how your GameObjects are divided in conjunction with probe placement which would make for some really difficult workflows.

    Thoughts?
     
  2. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    I wonder if I should have my pivot points dead center for the models that I make probes for... because the reflections are really messed up and I have a room that is a perfect square. I guess I will not be using reflection probes and wait for SSRR.
     
    Last edited: Feb 26, 2015
  3. Thiago-Crawford

    Thiago-Crawford

    Joined:
    Jan 7, 2013
    Posts:
    92
    Hi, I have a similar issue with interior hallways. This may be a bit of a "wild" idea here... but can't you make a custom polyshapemap? (ie a cubemap of a different shape, like an L).

    So you make a 3D L for your hallway, bring it into Unity. Attach a "polymap" component to it, it bakes the reflection data (or realtime if possible) based on each face and voila. No matter what shape your environment is, we can get some approximately accurate reflection!

    I'm not familiar enough to know if there are technical reasons this cannot be done, but I can't think of why not? Please "enlighten" me :D

    Thanks
     
  4. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    When it comes to reflection probes, we're pretty much at the mercy of what Unity gives us :\
     
  5. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    Not to be a smartass but when it comes to the whole Unity engine we are pretty much at the mercy of what unity gives us. ;)
     
  6. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    For your l-shaped setup, you want to place 3 probes. One in each corridor and one in the centerpiece.
    You also want to split your room in 3 parts. So each one gets a probe.

    And then of course, the seam between probes is solved with roughness / normal maps. Which makes it invisible. See the example shot i made when using a metallic surface. We have the exact same setup in our upcoming samples, and it solves it very well.

    I suggest you try these steps
    1. Make the room into 3 parts. Hallway - Center - Hallway. With 3 probes.
    2. Use the metallic material I put in the example project. It is not tiling and not made for your geometry but should get the point across of how when you actually have a metallic surface everything is fine...


    So that worked pretty well for us and demo project for it will be coming up soon. But you can also take the approach of what they do in RememberMe. Basically they just use one active probe for the whole scene.

    You can use the ReflectionProbe.BlendCubemap function to blend cubemaps together at runtime, so that you basically have a point of interest and based on that point of interest you blend all your cubemaps.

    In RememberMe this technique works well, but of course as with all realtime techniques you choose a technique based on the looks you want to achieve and how you create your art for it.

    You can do this with a simple script based system that does it for you.
     
    Last edited: Feb 26, 2015
  7. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Also as I said for Deferred rendering on PC level hardware our plan is to support SSR in the future with builtin image effects (some are also available on the asset store for now) but we want to have it builtin in upcoming 5.x release.

    And also per pixel probe blending. But those only really make sense on PC level hardware and when using deferred rendering.
     
  8. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    How is it going with those btw?
     
  9. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    @the_motionblur Well that's not always the case, for example shaders, including full screen effects, we can do whatever we want with them. Also, all the character controller and camera scripts, you can write your own... I mean I could start listing all sorts of things where we're not at their mercy.

    @Joachim_Ante I think it's fair to say that most of the people in this thread probably only care about PC level hardware. I for one couldn't give a monkey's about any of the other levels of hardware. I find it seriously annoying every time I read that you guys have made a decision based on mobile hardware restrictions. I understand that you have to cater for whatever's bringing in the money, but when I look at what people actually make for mobiles, it mostly seems to be 2D or very cartoony stuff, not something that needs serious reflections etc.
     
    Weendie-Games and shkar-noori like this.
  10. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Interesting, I'll give it a whirl. The floor probably is unrealistically reflective in my example, so I'll try some more practical materials and revisit the scene.

    Thanks
     
  11. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    I have managed to match the bounding box to the cube in my scene, but the reflection is STILL messed up... the whole room turns blue as if it is rendering the skybox outside the scene.
     
  12. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Screenshot 2015-02-26 11.07.58.png

    This is the mess I am dealing with right now... For the reflection probe, I am using baked mode which is good for now as I am tweaking lighting, but once I get the lighting to way I like it, I will bake it in... But this is mess is horrible and it matches the bounding box exactly.
     
  13. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Can't make out anything from that screenshot because of that material you've got on the walls.
    Try recreating that room in an empty scene and use simpler materials to make sure your problem is not somewhere else.
    RP2.jpg
    Reflections are not super perfect at every angle, but I think it works pretty great.
     
  14. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    I must be doing something wrong in my setup... because I keep getting messed up reflections... I also switched to Unity standard materials to see if I get the same issues... Screenshot 2015-02-26 13.08.53.png
     
  15. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Wait, is your room separated into pieces.. such as planes for walls?
     
  16. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Yeah, I used default Unity cubes to build the scene.

    Do you think it might be related to UV mapping?
     
    Last edited: Feb 26, 2015
  17. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    That's why it's working :(... I used a cube from Modo to create my cornell box with the normals flipped...
     
  18. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    It shouldn't even matter tbh. My UVs are very clean and unless I have to separate the UV shells that would be the DUMBEST fix I've ever heard
     
  19. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    It's your box smoothing group i believe, Try to overide it from Unity.
    In the Import settings set the Normal to Calculate and the smoothing angle to 45.
     
  20. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    That seems to fix it. Yay... I just created a smoothing group in Modo and PRESTO!! Now it looks delicious... still waiting on SSRR :) But good to know that something simple as a smoothing group could mess up my probes... now I can use them for objects that are static... When I build level geometry, I will have to be careful about how I place objects and probes... especially awkward shapes like stairs.

    I am also using LXO format to ease the level design process...

    I LOVE THIS!

    Screenshot 2015-02-26 13.57.00.png
     
    blueivy likes this.
  21. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    have you tried to slightly overlap the probes a bit?
     
  22. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Glad you've fixed it!
    I don't exactly understand though, how a smoothing group can affect reflections.
     
    KRGraphics likes this.
  23. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Same, but I will just go with it :)
     
  24. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    The smoothing group changes the normals of the mesh, the way you had it previously, the normals all pointed towards the center of the box, even near the edges and corners, the way you have it now, the normals for each plane face directly off the plane orthogonally. Reflections bounce the light based on the normal.

    Basically before it was treating your box like a very poor approximation to a sphere. Does that make any sense?
     
    Devil_Inside and DanSuperGP like this.
  25. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    That should have clicked, but i am glad I fixed it. :)
     
    DanSuperGP likes this.
  26. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    @Neputune. Great to hear you figured it out with the normals!

    @LaneFox: Did you try seperating in 3 sections? Would be great to get an update if that solved it for you.

    Btw. are you using RC3 or the RC3+ build Alex Lian just posted?
     
    KRGraphics likes this.
  27. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    I think in the documentation for reflection probes, I would mention this. And I think you could overlap the boxes just a slight to fix your seams, or hide the seam with a "separator" mesh...

    Also, Joachim, the reflections look MUCH better now with the textures applied! That is the key to get realistic surfaces
     
  28. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Just built this scene for iOS and Android.
    1. On android it looked almost fine (except that I had to readjust all the specular values on materials). The main issue with the reflections, is that they looked like the room was actually twice as large, so there was probably some issues with projections.
    2. On iOS I also had to readjust all the specular values on materials, but it still was a mess, both material properties and reflections.
    RP3.jpg
     
  29. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    You probably want to turn off texture compression. PVRTC can be brutal in terms of quality in some cases.
     
  30. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Also on mobile box projection is currently not supported for performance reasons.

    On mobile I would suggest you go with more rough surfaces and normal maps.
     
  31. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Thanks for a quick reply. I'll try switching compression off and post my results.

    As for box projection, not that I need it, just curious, will it ever make it's way on mobile?
     
  32. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    You can enable it already, if you make your own shader. Which is quite easy. you just #define UNITY_SPECCUBE_BOX_PROJECTION in your surface shader which does the PBS.

    It's really more a question of if it is a good idea performance wise on the hardware you are targeting. Which of course also depends on the type of content you are doing, how big your scene is, minimum spec. We go with what is sensible for most, but with shaders it's a good idea to make your own surface shader specifically optimized to what you need in your game when the defaults don't fit your specifc needs.
     
  33. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Hey Joachim, is there a way to turn off texture compression on the probes or are they already uncompressed full 32bit exrs?
     
  34. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    @Joachim_Ante
    Ok, I've removed compression from the tiled diffuse and normal map, and rebuilt for iOS and Android again.
    Editor - built platform is set to iOS, everything looks ok.
    Room0.jpg

    Android - everything looks OK, except for reflections. Box projection doesn't work on mobile, so it looks just like the editor when box projection is switched off.
    Room1.jpg

    iOS OpenGL ES 2.0 - I don't know what happened here. All the materials are way off, everything is super reflective and there seems to be no diffuse map. Also the reflections, unlike the Android version are distorted and broken. Room2.jpg

    iOS OpenGL ES 3.0 and Metal - I don't know what happened here either. No normal maps and no reflections at all.
    Room3.jpg
     
  35. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Can someone please try an iOS build, both metal and opengl es 2.0, and either confirm or deny what I'm seeing?
     
  36. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Did you actually turn off compression on the cubemap?
    In the lighting window turn off "Compressed" under the BakedGI tab.
     
    KRGraphics likes this.
  37. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Yes, compression was turned off.
     
  38. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    How do you actually do this? :)
     
  39. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    I should probably mention that I was building for iOS using Unity Cloud Build, if that makes any difference.
    I don't have a Mac, so I can't build it directly. I'm attaching the Assets and ProjectSettings folder to this post if anyone want's to try building it directly.
     

    Attached Files: