Use of Light Probes

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

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).

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?

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

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).

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.

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

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?

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.

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

2 Likes

Sounds great … looking forward to it.

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?

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!

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.

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.

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?

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.

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.