Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Lighting of an object which has an inside and outside part.

Discussion in 'General Graphics' started by Aberdyne, Jul 8, 2015.

  1. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    I'm currently trying to get my head around an issue we have with our project targeting iPad Air. We needed several switchable environments to affect the outside of an object (composed of many sub-objects) as well as its inside, keeping things as realistic as possible with the limited number of resources we have on the target. Also the object has moving parts, which added to the fact we need switchable environments rules out baking lightmaps...

    In that spirit I set up different environments with a single directional light in each and for which I baked a custom type reflection probe. By leaving the object at the same location in the scene and only activating/deactivating the environments the result is pretty convincing for the outside.

    For the inside though, it depends. This is our issue. There are objects inside which should receive directional lighting and reflect outside environment, those are quite convincing. We only added a point light inside to get more lighting as we found it was a bit dark (in a way simulating bouncing light). However some elements which must be in shadow turns out to pick up the reflection from the probe (which is expected of course). In some environments it's okay, but some which have brighter grounds make inside objects look very odd (receiving light from the bottom while they shouldn't, since this light is supposed to be blocked out by the object itself).

    I thought about using another reflection probe for the inside, but it would be difficult to avoid bleeding on objects that are meant to receive their reflection from the env probe. As the object has many small parts that can change/move things are difficult to anchor to a particular probe.

    Another suggested idea was to use light probes. However I don't think our setup is a good match for those but I may be wrong.

    Anyone has some other tricks to suggest? Thank you very much.
     
  2. OllyNicholson

    OllyNicholson

    Unity Technologies

    Joined:
    Jun 17, 2011
    Posts:
    142
    'a picture says a thousand words' but going from your description it sounds like you simply need to edit the update frequency for the reflection probes and their corresponding bounding boxes and spread them around the interior in the right configuration. Obviously targeting ipad air has performance considerations so you may wish to profile if your scene has a lot of other stuff going on.
     
  3. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    Thank you for your answer. Yes you're right... but I'm afraid I can't show you pictures (at least here), that's a pity because I don't know if I was clear enough. I'll Ask how far can I go into describing the object though.

    Actually the reflection probe I use for each environment is custom PRE-baked, not realtime. So this is really the cubemap generated that cause problems for some parts inside... I'm searching for workarounds.

    The probe is meant to affect the outside (reflection mainly), but also the inside, because there are holes in the object that let light in from the outside... The shape is quite complicated to match with bounding boxes also if I were to use several of them inside. I would appreciate to have much more control with anchoring and blending. As you said I'm afraid for performance... we're quite high definition here.
     
    Last edited: Jul 9, 2015
  4. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    One possebility is to use 2 different reflection probes at the same time. On for the parts in shadow, one for the parts in light, and blend between them based on the shadow?
     
  5. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    Thank you Zicandar. That was actually one of my ideas... and yes, I suppose that could have worked... if the shape of my object wasn't so different than a cube. My main concern is to get the effect only on the parts that need to be in shadow. Do you think using multiple reflection probes with smaller bounding box will have a big impact on performance? I guess I will have to try.

    Meanwhile I tried to deactivate reflection probes altogether and play around with light probes and illuminate things by hand, however wrong that feels... this is far from perfect but the result is more consistent than with the current reflections... I'm quite skeptical of the usefulness of this technique in my use case though.
     
    Last edited: Jul 13, 2015
  6. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Unless you also have objects outside, the shape shouldn't be that much of an issue, remember you can always assign the probes by hand!
     
  7. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    As I tried to explain above - and as OllyNicholson said "a picture says a thousand words"... but I'm kind of restricted on that as I already mentionned, sorry for that - I have objects outside (basically a surface facing outward) that must be visible from outside and reflect the environment. Then I have objects inside (surface facing inward), some reflective, others not (standard shader will anyway pick up colors from reflection to some degree, right?). Finally, I have objects inside contained in the volume created. Most objects can move or change and have convoluted shapes.

    I can try anchoring to a different reflection probe as you said. Too bad we cannot assign more than one probe and we cannot tweak blending weights... anyway I'll give it a try as my current solution "not to use reflection probe at all" can easily be converted to "use another reflection probe instead"... except in the first case I don't eat up memory.

    Thanks so far.
     
    Last edited: Jul 13, 2015
  8. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Well, UNITY uses more then one probe per object, and with scripts and custom shaders that shouldn't be to hard.
    As for detecting where on the objects they reflect "holes" in the "shell", well, depending on the size of the holes, you COULD bake a cubemap at pretty low res per object, and use that to blend between the 2 custom probes you have created :)
     
  9. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    Ok, I see what you mean for the custom shader part, but not for the second part though... ?

    I was writing a little script that will bake a (cubemap for the) reflection probe for the inside (which Type is set to "Realtime", Refresh Mode set to "Via scripting") whenever a major change occurs (env change, things changing inside, ...). The probe WILL impact every object that has its Mesh Renderer's property "Reflection probes" set to "Blend probes", BUT I can disable the inside reflection probe when viewing from the outside (camera out of a bounding box or something).
     
    Last edited: Jul 14, 2015