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

Baking texture on animations from blender

Discussion in 'Animation' started by iamthwee, Mar 2, 2016.

  1. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Hi Guys,

    I have a bit of a problem, not sure how to solve it. I have set up my animations in blender using bones. I thought I could just bring it into unity mark as static bake the lightmap then unmark and play animations.

    However, I can't, as in play mode the mesh/model is completely black and only illluminates when a dynamic light is shone on it - Problem.

    Am I doing something wrong.

    A work around is to parent the baked mesh to the animated one, and then hide the animated one. But it seems so tedious- or animate inside unity which is unfathomable!

    Any help appreciated!
     
  2. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Anyone? Surely someone has tried to do this?!
     
  3. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    anyone
     
  4. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,433
    I have a hard time understanding what you are trying to achieve. Maybe a screenshot would help. I have a strong impression that you are trying to do something which is very impractical and not designed to be done this way. It seems to be more of a baking question, which has better chances of replies in the global illumination subforum I guess. Maybe a mod can move the thread there if s/he agrees.

    Baking is designed for stuff that never will move. If you have an animated mesh and want to bake some lighting into the texture, then that's not a job for the Unity baker. If it's possible at all, it isn't practical. If you have a mesh that is rigged and animated, like a character or an animated environment prop like a corpse dangling on a noose (you're making a horror game, right?), and for artistic reasons you want to bake some lighting into the albedo map (which in a strict PBR workflow I assume is not always recommended, since you handle an albedo map and not a diffuse map), you should do that in blender or another texture related program. Use Unity baking for static environment assets, use Blender baking for animated meshes.

    Now, I'm sure there are plenty of issues and edge cases like for example you want to have your dangling corpse mesh in a corner where it is partially hit by light and partially in shadow and it looks weird because the realtime lights that you have light the corpse mesh differently than the baked lighting in that corner should. I'm not sure there even is a solution for that at all. The things that I'd google is "reflection probe" and "light probe". Not sure if the "mixed" mode setting for lights would be even related to this, but afaik this feature has been broken for a long time, just so you know.
     
  5. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Thanks for the reply, that's given me a few ideas to investigate.

    Basically, I know this sounds really pedantic but I have a door which looks nice when lightmapped in unity marked as static. The door I've animated in blender to open and close using two bones. Unfortunately animated meshes don't have lightmaps and only illuminate when I shine a real time light on it.

    Now, it seems reflection probes solves this issue, but it isn't nearly half as good as the light mapped one. And unfortunately baking outside of unity in blender, although possible will look different as the lighting is significantly different under cycles, and I would need to bake the door and the corridor to make sure the shadow match. In short it is a no go, especially as baking a room scene in blender takes so long.

    The solutions are as I see.

    1) Use light probes and make do with a less aesthetic light map.
    2) Bake the texture onto the door in unity, but animate within unity. This is probably the easiest as it is purely an open and close mechanism, even though I hate animating in unity.
    3) Yet to try... bake the door as static, but bring the animated rig in, and then hide the animated rig and parent the lightmapped one to the animate rig.
     
  6. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,433
    Or 4) try to find a lighting setup that doesn't need baking. You can do a lot with clever manual placement of lights and good post FX like SSAO and bloom.

    The core problem you face is that you bake light at all, and baked stuff doesn't look right when it isn't completely static. I'd really like to see a screenshot of the scene in question. I might be able to make better suggestions then.

    The dynamic GI that sonicether is working on may or may not be a solution for you (I'm leaning towards not being a solution because thin moving objects like a door wouldn't voxelize well).
     
    iamthwee likes this.
  7. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    4) Is a great point, but real time lighting is also expensive. With the baked version I can play full screen with great FPS, not so much with the dynamic lighting one, and it looks worse. Here are two shots one baked and one dynamic. Oddly the SAME materials have been applied but the material color looks completely different color and is missing the extra something the baked shadows produce.

    I can confirm that step 3) works for me, yes it is a bit fiddly, but at least I can avoid animating in unity. I just parent the baked mesh to the armature and hide the mesh renderer of the animated one.

    Baked
    baked.jpg

    Dynamic
    dynamic.jpg
     
  8. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,433
    You can't just flick a switch, turn off baking and expect the dynamic lighting to look remotely the same. That's the same incorrect expectation (just coming from the opposite direction) that some mobile devs have, who would want the baker to just bake the dynamic lighting in place with the click of a button and do nothing else.

    You need to make a lot of tweaks to get something that works for the specific lighting model. If you switch between baked and dynamic light only, I'd expect you have to tweak every lamp in the scene and possible also adjust SSAO and scene lighting settings.

    Such a corridor scene might make a nice example for our Unity vs UE4 thread here:
    http://forum.unity3d.com/threads/ph...-rendering-between-unity-and-unreal-4.262181/

    Maybe post it there and ask for advice on how to best solve this situation.

    About the performance though, a dynamic light imho should not drag down framerate all of a sudden. Sounds to me like either your mac has really lowend performance or something is wrong with either Unity or with what you are doing. Sure, it has a cost, but I've done experiments with many dynamic lights without issues on a GTX 670 (which admittadly is more of high to mid-tier graphics card).

    What kind of performance do you see playing games with dynamic lighting on your mac? I have the suspicion that you're possibly hitting a wall because of a low-end GPU in your computer.
     
    theANMATOR2b and iamthwee like this.
  9. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Yeah you have a point, remember I'm running a mac mini, which has it's own onboard graphics chipset and no dedicated one like in imacs, additionally, to get a similar feel in dynamic mode, I probably had a ridiculously large image stack, SSAO, DOF, dust storm, which slowed down the framerate etc.

    There definitely is a take away and that is to get real time and baked working seamlessly involves quite a bit of work. I understand now why most people just do the whole dynamic lighting thing.

    If you think my corridor scene is good enough I will post the file in the unreal vs unity thread thanks it means a lot coming from a good CGI artist like yourself.
     
    Martin_H likes this.