My issue is that the baking process just wont complete. I have a medium sized terrain (1000X1000), with 3 textures and dozen rock meshes. Everything set to static, one directional light is the only light source. im making a mobile VR game so I need baked lights as realtime is not supported on most android phones. Baking just wont complete. Gets stuck on “12/16 bake indirect”. left my computer on overnight with sleep mode disabled, woke up in the morning to a million errors in the console “stack overflow exception”… wtf is going on? baking was much easier in previous versions of unity (don’t remember which version I was using, probably some version of Unity 4). it was working fine… from what i understand they changed light mapping engine from Beast to Enlighten? WHy? don’t fix it if it aint broke. Im sure im not the only one having this issue.
What to do? Any tips/workarounds?
There are several steps you need to take to reduce the bake time, or to even have Enlighten finish.
-
First and foremost, turn off pre-computed real time global illumination. You will not be able to use it on a phone, especially not for VR, and it only costs you bake time.
-
Next, drastically reduce the baked lightmap resolution. I’m talking 3-4 instead of the default 40. You can go up from there once you have a completed bake and need more detail, but start low.
-
Make sure the lightmap scale of the terrain is very low - it should be 0.01 by default, definitely don’t go any higher than that.
-
Finally, don’t just lightmap everything. Take out any objects smaller than a couple of dozen centimeters. They will not contribute much to the final look of the lightmap, but they will eat up a whole lot of baking time. This requires the most manual work, but it will make a big impact.
1 Like
Not sure if im doing something wrong, but if I turn off pre-computer GI, ambient lighting gets disabled, as does the bounce intensity of my directional light. This makes for a completely different looking scene which I cannot use for my game. is it possible to re enable at least ambient lighting with pre0computer GI disabled?
so turning baked resolution down from 60 to 20 did the trick. the lightmaps have been baked. im happy it worked but definitely not a commercially ready result. will have to do some tweaking and try on a more powerful pc. the problem now however, is that my terrain material is gone! textures and shadows are fine, but i have no material. I worked hard to get the material properties perfect for this sunset scene, and the material makes a huge difference in visual quality. SO my question is… is it possible to enable material with baked lighting?
Glad to hear the baking completed. About the bounce intensity: yes, this is something tied to global illumination, which is all about light bouncing. Ambient light however does not get disabled, but if you had a high bounce intensity, you would have pretty much the same effect. Try increasing the intensity of your ambient light instead. Precomputed real time GI has a pretty significant CPU overhead, and as I said, I would advise against using it in mobile VR - at least thoroughly profile it first on your target devices.
I’m not entirely sure what you mean by “my material is gone”. If you mean that there are no more normal and specular details, then this can be changed in the lightmap settings. If you change it to “directional specular” you will have better looking baked materials, but this setting is not supported on lower end hardware. I reckon that phones which can run VR should not be affected though, but you would have to check to be sure.
interestingly, counter to what you are telling me, turning off pre computed realtime GI disables ambient lighting in my scene, regardless of whether ambient is se to custom color or skybox.
also, turning on directional specular gives me a warning that directional specular light-mapping cannot be decoded on SM2 hardware, or while using GLES2.
whats exactly is SM2 hardware?
I believe GLES2 is the graphics rendering software for the phone’s GPU. How can I check whether my phone is using GLES2 or GLES3? I have a Nexus 5 with android version 6.0 but I am targeting Daydream compatible phones, which will have GLES3 or above.
EDIT: I have 2 versions of the same project, one targeted at PC Oculus rift, with realtime shadows, and the other targeted mobile, with baked light maps. In the realtime shadwos version of the project, turning off realtime GI does NOT disable ambient lighting. ambient lighting only gets disabled by turning off realtime GI in the baked version of the project. DO you know why this may be? or maybe its just a bug that can be fixed by tweaking some graphics settings?
Ambient light is definitely separate to pre computed real time global illumination. Can you post a screen shot of your lighting panel so I can see what exactly is going on there?
As for SM2 hardware, SM stands for Shader Model. “Shader Model” is a standard that defines what hardware should be capable of doing in terms of real time graphics. We are currently at SM5, so SM2 is pretty dated by PC standards, but probably still common place for mobiles.
Screen1: No light source in the scene. all lighting is Baked. Precomputed GI is enabled, ambient lighting is set to a very low, but visible amount. Just enough to add some visibility to unlit objects.
Screen 2: the ONLY difference here is that Pre computed GI is disabled, and ambient lights are not working. i probably should have increased the ambient light quantity for this example to show you the difference, but I hope you can still tell that there is no ambient lighting in this pic.
Now the interesting thing is that if I use realtime lights rather than light-maps, ambient lighting functions regardless of whether precomputed GI is turned on or off. As confusing as this is, its actually not a problem for me because I opted to keep Pre-computed realtime GI checked, since it does not seem to have any effect on performance.
Im actually having another issue now. I did as you said and enabled directional specular under General GI, which makes the terrain shine (I have a material applied to the terrain). this shine does not show in the editor, but I can see it in my android build. the discrepancy between what is shown in the editor and on the android build caused me to make about 20 builds earlier today to find ideal settings. The ONLY problem I have now is that when DIrectional Specular is selected instead of non-directional under General GI, there is a visible and ugly crease right on the border between shadows and illuminated areas of the lightmap. I cant take a screen shot of it because this effect is not apparent in the editor, but is apparent on 2 different Phones.
I finally got real time shadows to work on android, but it takes too much of a toll on performance so it is out of the question, especially since I would need a massive shadow distance to see these huge terrain shadows. LIghtmapping truly is a more elegant solution. Once i get home to my powerful gaming computer, Ill try to render a higher quality lightmap. The only issue is trying to get directional specular to work without showing that weird shiny crease along terrain shadows. Any help is much appreciated. If you have suggestions on how to take a screenshot of the game from android, let me know. Thank you.
When you disable real time GI, ambient lighting mode gets switched to baked automatically. You need to rebake your lighting to see the baked ambient light.
As for seams, this is likely a lightmap UV problem. In your scene view, select “UV charts” as your display mode, and take a look at the areas where you see seams on your phone. You can also take screen shots on your phone directly - it should be pressing volume down and power button simultaneously by default.
here are screenshots from my phone. Note the stereoscopic image is for VR purposes
Screenshot #1: General GI is set to “non-directional”. terrain look OK. All shadows are baked.
Screenshot #2: General GI is set to “directional specular”. this s what it looks like on the phone, though on the editor, it looks exactly as screenshot #1. notice in this image, there is a yellow seam at the borders of all the terrain shadows, cast by the terrain. again all shadows are baked.
Have a look at the Directionality view mode in the Editor and some of the other view modes, they can help you figure out what is contributing to the light seam.
That yellow border seems to be related whenever a surface is affected by both a baked light and a bouncing light. I got that effect on many assets’ baked light in my project. It’s especially present when the the smoothness is above 0.5 and when an object is affected by at least 1 direct light and 2 bouncing (indirect) light.
It’s as if the edge of the shadows get slightly cropped, leaving a slight line of blurred map pixel as lighter than they are supposed.
This worked for me. Thanks for posting!