2
\$\begingroup\$

I have an issue in Unity where my trees are black and it seems to be due to the fact that I'm using baked lighting in my scene. Luckily, it seems that I'm not the only one who's experienced this. I found a post on the unity3d subreddit which goes into more detail about basically the same problem. I'll repost it here for convenience:

So, I have some custom trees using the "Nature/Tree Soft Occlusion" shaders and they looked great before baking a lightmap. However, now that I have baked the lightmap, the trees have turned black. Or rather, when I tried baking with the trees set to static, they turned invisible, and now that Ive tried without, they're black. Also, they're not casting shadows.

Anyone know how to fix this issue? Perhaps I need to use light probes?

http://imgur.com/a/21At5 --> before and after (fyi the bark is not using the nature/occlusion shader. The shader definitely seems to be the root of the issue, but Im just not sure how to fix it without using a different shader)

Ultimately, the author of this post eventually "solved" his problem by just switching to realtime lighting instead of baked lighting. Unfortunately, this is not an option for me. However, the author did receive some useful comments before giving up.

One of the comments asks if the leaves have properly laid out UVs. The commenter goes on to say that the leaves all need to have their own unique space in the UV grid. I think this makes sense because I enabled the Generate Lightmap UVs option on my tree model in Unity. But it did nothing. The author apparently also had no luck with that option.

In any case, Maya was suggested (among other software) to check these leaves' UVs. Unfortunately, I've never used Maya and I absolutely can't make heads or tails out of it. I'm just using a borrowed copy from a friend so I've never gone through any tutorials or anything for it. I'm just trying to check this one thing, but I am really at a loss.

EDIT:

According to some comments from DMGregory, he suggests that since trees get spawned and varied dynamically, there's no single mesh to pull apart and check its UVs. His logic seems to make sense, so perhaps Maya is not the solution that I'm looking for. Now, though I'm having trouble with figuring out how to get my tree shaders to work with lightmapping. Details are in the comments.

\$\endgroup\$
  • \$\begingroup\$ I don't think Maya will help you here. Since the trees get spawned & varied dynamically in the engine, there's no single mesh you can pull apart to check its UVs. You can try examining the lightmaps generated by Unity though. If the probem occurs specifically with this one shader, it might simply be that the shader does not have/generate variants that work with lightmapping, and you might need to modify it to handle this case. \$\endgroup\$ – DMGregory May 24 '18 at 11:26
  • \$\begingroup\$ @DMGregory It seems that the bark material is using a shader called Nature/Tree Soft Occlusion Bark and the branch material is using a shader called Nature/Tree Soft Occlusion Leaves. Both of these shaders say unity_builtin_extra at the bottom of the Project window when I select them, so I guess they must be from Unity. How can I check if these shaders have / generate variants that work with lightmapping? I would have thought that if they're from Unity, they'd do this out-of-the-box. I'm also not sure whether I can edit them since they're from Unity. \$\endgroup\$ – GDP2 May 24 '18 at 17:12
0
\$\begingroup\$

I went ahead and used mixed lighting instead of baked lighting. The performance is not as high, but it's acceptable for my purposes. I had still had lightmaps enabled on the terrain, but the coloration seemed to be corrected after using mixed lighting on the sun for some reason.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.