Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Use of Light Probes

Discussion in 'Windows' started by Rajmahal, Jul 27, 2014.

  1. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hi,

    Sorry to post this here as it's not technically a Windows 8 / Windows Phone specific question but this seems to be the only forum where I'm able to get any kind of response. I'm trying to use Light Probes in my Windows Phone game. Once I've set them up and baked all the lights in the scene, should I have the lights that I want to shine on dynamic game objects / meshes set to "Auto", "Realtime only" or "Baked Only". It seems to only affect them if I set it to "Auto" ... but is this good from a performance perspective on a mobile platform? Is this method actually making use of the Light Probes?

    Raj
     
  2. zuzzu

    zuzzu

    Joined:
    Feb 2, 2013
    Posts:
    404
    On mobiles you can't use dual lightmaps so:

    "Auto" and "Baked Only" - light is baked on static objects
    "Realtime Only" - light is dynamic on all objects

    All of this will happen only if your shader will allow it, so things may vary between shaders. For example "Mobile Diffuse" doesn't allow for baked and dynamic lights at the same time (I think).
     
  3. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    I used directional lightmaps as my setting while baking. It seems that when the various lights in the scene are set to auto, then they do shine onto dynamic objects (which are using mobile diffuse sharers). Would that be because of the light probes?
     
  4. zuzzu

    zuzzu

    Joined:
    Feb 2, 2013
    Posts:
    404
    Ah, you were asking about probes, sorry. If you have placed them into the scene then yes. Probes are also baked on "Auto" and "Baked Only" afaik.

    That what you see may also be just dynamic point light lighting. To make use of light probes you have to:
    - Place probes in the scene
    - Bake them in the Beast
    - Select the option "use light probes" in the renderer component of your object
     
  5. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Okay ... so yes, I have done those things. So is it safe then to set all the lights in my scene to "Baked Only" now that I've baked Light Probes? Because to be honest, I don't really notice the baked light affecting the dynamic objects when I do this. So it makes me think I've done something wrong. The baked lights only affect the dynamic objects if I set the lights in the scene to "Auto" (and possibly "real time only" ... haven't tried that).
     
  6. zuzzu

    zuzzu

    Joined:
    Feb 2, 2013
    Posts:
    404
    You can select your light and move it around. If lighting on your objects won't change and will remain static that will mean that your objects correctly use probes instead of dynamic lighting. If it will change, probes are not used and you had to do something wrong.
     
  7. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    800
    Hi Rajmahal
    a couple of things that'd help others diagnose your issue here -
    1. screen shot of your setup including probes - could be that you don't have enough probes, or they aren't setup in a preferable grid formation - we could advise
    2. let us know what shaders you're using - are they custom or built-in? as zuzzu mentions this could be a factor.
    Let us know any other details of your setup we'd be happy to help

    Cheers
    Will
     
  8. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hi Will, thanks for the reply.

    Here is a screen shot of an example level that also shows the light map settings. As I'm doing this for a Windows Phone game, I'm using Vertex Lit Rendering.

    lightmap sample by raj_dhillon, on Flickr

    Regarding shaders, I'm using the standard mobile diffuse and mobile bumped diffuse shaders.

    I'm going through the manual again and I'm wondering if it's related to my settings. Can Light Probes actually work in Vertex Lit rendering with Direcitonal Lightmap baking? Do they require some other rendering mode or dual lightmap baking?
     
  9. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Finally figured it out. I hadn't actually baked the probes. I thought that Unity did the probe baking at the same time as the light baking (provided there are probes in the scene). I didn't realize this was a separate step. All is well. Thanks again for looking into it.
     
  10. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    800
    Hey Rajmahal

    great news! we were kind of stumped! as it should all work! So one thing to mention here is that in Unity 5x we'll have background baking processes so users like yourself won't run into probe-lems like this..

    All the best of luck with your game!

    Will
     
    filibis and GibTreaty like this.
  11. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Sounds great ... looking forward to it.
     
  12. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    I noticed that light probes don't seem to work with Directional or Single Baking if the rendering mode is set to Vertex Lit. Is that by design? If so, is it generally okay to have a mobile game use forward rendering if Light probes and Light Baking is used in place of normal lights? I set the lights in the scene to baked only so there are no dynamic shadows, which I'm okay with. Performance seems okay on a Lumia 920 though it does get quite hot ... though I think that phone gets hot with a lot of games. Is this good practice for mobile development?
     
  13. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    Hey Rajmahal,

    You're right that light probes are currently not set in the Vertex Lit render loop. That render loop is supposed to be the simplest possible thing and light probes didn't make the cut there. You can safely use the forward render loop, especially if you're using baked only lights.

    Light probes will be baked regardless of which option in the bake button you hit: "Bake Scene", "Bake Selected" or "Bake Probes".

    A grid structure is not the recommended way. The preferred way is one that uses the fewest probes, but captures all the required lighting changes. A grid is not a bad start though.

    Cheers!
     
  14. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Thanks ... I'll look into tweaking it in a later update. Seems to work fine now. What are the downsides of using a grid? Is it a performance hit or does it just take up more RAM during runtime? The game seems to run fine even on low memory devices for Windows Phone 8 so I may leave it at that if it's just taking up memory. However, if it's a draw call, CPU usage hit then I'll definitely update the spread of probes.

    I've set up my game with Forward rendering and only use baked lighting for my scene lights. I have some occasional realtime lights that pop in and out of use during gameplay and it all seems to run very smoothly. I'm actually really impressed with the kind of graphics I'm able to get running smoothly on low memory windows phones. Good job, Unity team.
     
  15. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    It's memory usage mostly. The more probes you have the more tetrahedrons there are to traverse to find the matching one for a given renderer using light probes. That traversal typically happens only at startup as the renderers cache the last tetrahedron they were in and if they just move to a neighboring one, finding that out is fast.
     
  16. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    thanks ... my main concern is battery drain and the device heating up during gameplay. Would reducing the probes have any significant impact on that? Is that mostly due to draw calls?
     
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    In my experience, that happens due to CPU usage. You'd have to profile to find out the reason.

    Note: these phones do heat up quickly, even when only browsing the web.
     
  18. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Thanks ... you're right. It might just be the phones. Going to test on Android and see if they also heat up a lot or not. Profiler seems to look pretty good. I only see spikes when I instantiate a new enemy into the scene.