Home Unity

Bake AO but not lights

polycounter lvl 11
Offline / Send Message
MainManiac polycounter lvl 11
Im using unity free and id like to bake my scenes AO but not my light so that lights can be turned on/off but AO is visible when they're on


basically can I only bake AO and then set it to multiply and not ignore light?

Replies

  • Ark
    Offline / Send Message
    Ark polycounter lvl 11
    Why would you want to do that? If anything I would want it to be doing the opposite, easing of the AO in dark scenes so its blends better in darker areas and avoids that cell-shaded look.
  • MainManiac
    Offline / Send Message
    MainManiac polycounter lvl 11
    Im using a flashlight in the game and the entire scene is dark, but I want the area hit by flashlight to have baked ao in it

    So I basically want the lightmaps multiplied onto the diffuse rather than used as lightmaps
  • LoTekK
    Offline / Send Message
    LoTekK polycounter lvl 17
    I haven't touched Free in a while, but in the lightmap baking options, you should be able to switch from "Dual Lightmaps" to "Single Lightmap" (or something along those lines). Single lightmap basically should give you what you're looking for.
  • Farfarer
    We don't get dual lightmaps in Free :P That's blending between baked lightmaps and dynamic lighting based on distance.

    But yes, you should be able to bake AO. You'd have to set up a custom shader if you want an AO map and a lightmap, though. Perhaps do it in another app and bake it to the vertex colour? Would be a little cheaper.

    But AO should not affect a torch light by any discernible amount. A torch is not ambient light.
  • MainManiac
    Offline / Send Message
    MainManiac polycounter lvl 11
    You know how when you bake the lighting the info goes into the textures and you can add lights yet they still don't effect the scene? I want to bake ao but still have dynamic lights work.

    I turned the ambient light all the way up to white to bake the ao and then when I turned it back down to pitch black alot of the baked objects were still illuminated. If there was a way to set the baked ao into a diffuse multiply or something itd be what I want. Pretty much the same thing as baking AO maps in xnormal but for an entire scene at once
  • Farfarer
    You'd have to bake it like that, yeah. Then write a custom shader that takes the lightmap you've baked, multiply it over the diffuse and then add any dynamic lights you want.

    By default, lightmapped objects' materials won't get affected by dynamic lights because they're lightmapped and therefore don't need to - the shader just bypasses the dynamic lights entirely.

    It's possible to write your own that handles lightmaps and dynamic lights, though.
  • MainManiac
    Offline / Send Message
    MainManiac polycounter lvl 11
    Ah I have no experience with shader writing ugh
  • Brendan
    Offline / Send Message
    Brendan polycounter lvl 8
    frell wrote: »
    You know how when you bake the lighting the info goes into the textures and you can add lights yet they still don't effect the scene? I want to bake ao but still have dynamic lights work.

    I turned the ambient light all the way up to white to bake the ao and then when I turned it back down to pitch black alot of the baked objects were still illuminated. If there was a way to set the baked ao into a diffuse multiply or something itd be what I want. Pretty much the same thing as baking AO maps in xnormal but for an entire scene at once

    Lightmapping covers over the diffuse at a higher level, usually resulting in the shader reverting to the 'fallback'.


    Essentially you end up with diffuse x (8 x lightmap)
    meaning your original diffuse in it's 0-1 range, by a lightmap with a range of 0-8.


    If you want usable maps, you'll need to create the UV2 yourself instead of creating it while importing. Some sort of atlas is usually helpful here.

    Then grab the baked lightmap, convert it to something useful (NOT .exr)for application to your UV1-based textures.
  • Volantk
    Offline / Send Message
    Volantk polycounter lvl 11
    It's not exactly what you asked about, but I think a variation of the method described in this blog post could maybe be applied to your problem.

    http://rockandroald.net/wordpress/clean-lightmaps-for-interior-visualisations/
  • tobeeffle
    Offline / Send Message
    tobeeffle polycounter lvl 5
    Hi,

    On your project and on your mesh in, dont put "create uv for lightmapped". Do your lightmap as an AO and check the raw file (if i remembered) in your folder.
    Open photoshop and copy it to your diffuse model. It will be exactly the same uv so you can put it in multiply normaly.
    Reimport your diffuse in unity, clear your lightmap, you have your AO on your objects and you can lightmap after as you want.
    You have the possibility to use lightmap shader in unity (in others). This shader takes a map for lighting in its slot. I test it with lightmap done in max but i think it will be the same result. This shader auto bake your lightmap to your diffuse.
    Do your AO, copy and rename your lightmap result put it in the slot on your lightmap shader. Do another lightmap as you want.
    I think that, if you want an AO and lightmap after you should create differents UV as brendan say.
Sign In or Register to comment.