Home Technical Talk

Ambient occlusion question

polycounter lvl 8
Offline / Send Message
danshewan polycounter lvl 8
Okay, so I'm texturing an object with the intention of importing it into Unreal. Right now, I have only completed the diffuse map in Photoshop, and applied it to the object in Max. Would I be correct in applying the AO map within the diffuse color map? Is it ever applied elsewhere? I don't have any issues with the concept of AO, or the settings involved, just the baking part, I guess. AO gets baked into the diffuse, right?

Whenever I see an impressive object in someone's portfolio, for instance, the three maps usually supplied or pictured are diffuse, specular and normal - hence my assumption that AO gets baked into the diffuse. Am I right, or do I need to sit in the corner and think about what I've done?

Apologies for any noob-related hilarity that this question may provoke.

Replies

  • Ben Apuna
    Yeah for Unreal, go for it, layer it onto your diffuse.

    If your object had a lot of stacked UVs and needed a different UV layout to get a nice AO onto it, you would need to keep it as a separate texture (or stick it in a alpha channel) and blend it onto your diffuse, etc... in Unreal using the material editor.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Here's my take on this issue. If your engine supports AO as a seperate bitmap/channel then don't add it in your diffuse. I'm not used to working with UE, but is there a way to multiply this into your ambient lighting? If so then that's probably what you want to be doing.

    [ame]http://www.youtube.com/watch?v=iTCq-bE9urE[/ame]

    BTW. There was just a similar thread like this just a week ago or so. DS.
  • pior
    Offline / Send Message
    pior grand marshal polycounter
    Kodde, remember that an 'AO' pass can simulate lighting for sure, but it also very helpful as a base to find where dirt or dust should accumulate on an object. So simply not putting any of it on a texture can be quite a problem, as it will make the object most likely look like shiny factory new plastic.
  • danshewan
    Offline / Send Message
    danshewan polycounter lvl 8
    Thanks for the replies, guys. For now, I think I'll just keep it in the Diffuse map. I haven't really worked much with lighting in UE3 (or Max, for that matter), so for now I'll just incorporate it into my textures and worry about lighting in-engine as and when it presents itself, and once I'm a little more confident.

    Thanks again. :)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Pior> Most definitely.
    But in that case you are using the AO pass as a mask for something else you are trying to achieve, such as dirt in cavities, etc. But yeah, I agree. Using the AO as a mask for dirt/dust/whatever in your diffuse is helpful.

    The original intention of the ambient occlusion was to occlude ambient. In other words, define where ambient lighting should hit and where not to hit.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    I was preparing some examples regarding this, here's some examples.

    aoexample.jpg
  • Blaizer
    Offline / Send Message
    Blaizer polycounter
    AO maps, curvature maps, etc. are very helpful to give models volume, not only dirt. Without a smooth AO applied on the diffuse, a normal map model is like flat when lights kills the fake effect.

    Realtime AO is still very expensive to compute for graphics cards, and a good prerendered/fixed AO map is very soft like to don't appreciate any noise.
  • SHEPEIRO
    Offline / Send Message
    SHEPEIRO polycounter lvl 17
    i agree with kodde- use it to mask the ambient lighting in your scene alot and mask the directional a tiny bit, use this in conjunction with two directional ambients (up and down, making down sky colour and weakish and up ground colour and somewhere inbetween the strenghs of you direct and your down) and you will get pretty good results without the use of fancy screen spaced stuff
  • commander_keen
    Offline / Send Message
    commander_keen polycounter lvl 18
    Unless your shader is doing something other than just multiplying your AO then there is no reason to put it in a separate texture/channel. Its just a waste of memory and texture sample.
  • Rick Stirling
    Offline / Send Message
    Rick Stirling polycounter lvl 18
    Unless your shader is doing something other than just multiplying your AO then there is no reason to put it in a separate texture/channel. Its just a waste of memory and texture sample.

    +1

    Also, prebaking is fine for objects that don't move, but you want to be careful on dynamic/deforming objects
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Just thinking out loud here, haven't really got a chance to test this theory. But what if the color texture already has a pretty dark/near black texture?

    Then multiplying the AO into the diffuse won't amplify the dark effect that much. In that case you ought to benefit more from multiplying a separate AO map into the ambient lighting as it will kill the ambient lighting on certain areas and thereby keeping the final result dark?

    Pre baking it into color would produce black areas on the texture, which would later be hit by the ambient lighting and produce a semi-grey look?


    Diffuse Texture * Diffuse Lighting + Ambient Lighting * Ambient Occlusion, just using one channel as an example
    0.1 * 0.0 + 0.3 * 0.0 = 0.0 (pitch black)

    (Diffuse Texture * Ambient Occlusion) * Diffuse Lighting + Ambient Lighting, just using one channel as an example
    (0.1 * 0.0) * 0.0 + 0.3 = 0.3 (semi grey)

    Might be totally off here, this is quite new to me :)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    I think what I'm trying to say is that with ao pre-multiplied into the diffuse texture can you ever achieve a perfect black color if you have a global ambient light that is lighting everything a wee bit?
  • Shogun3d
    Offline / Send Message
    Shogun3d polycounter lvl 12
    kodde wrote: »
    I think what I'm trying to say is that with ao pre-multiplied into the diffuse texture can you ever achieve a perfect black color if you have a global ambient light that is lighting everything a wee bit?

    No because the AO would derive from your diffuse map, adding a global ambient light just brightens it all up, doesn't affect contrast.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Edit.

    Now I'm just confused. Are you agreeing with me kaburan? Is my light equation above correct?

    If it is correct then my Maya viewport differs from this theory. Having a Lambert with a pitch black color and adding ambient color value doesn't change anything in my viewport. Maybe the ambient color isn't the same as a ambient light in a game engine?
  • Ben Apuna
    @kodde

    In Unreal adding in a ambient light will brighten everything which as you say kills all the pure blacks. Yes by pre-multiplying an AO map over a diffuse map or whatever in Photoshop will not allow you to use the AO map as a ambient light occlusion map.

    From my limited material editor knowledge there isn't a way to link the AO map to occlude an ambient light in the map. Though maybe by using a cube map for ambient light + some lerps + an if node..., or maybe a inverted light vector node... sigh so many things to experiment with and not enough time, lol.

    In the Why so Blue thread on page 3 there is some talk about how Valve has implemented something similar to what you are saying we should be trying to do.

    For right now I think at least as far as Unreal is concerned I'm guessing using an AO map as it really should be used would be somewhat expensive for performance, though I'm not an expert on the subject and could be totally wrong about it. :poly136: If someone knows a way I'd love to see an AO map implemented "properly" in Unreal.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Ben> Ah I see.

    Well I have a talented programmer co-worker who is prototyping 3D-features and he demonstrated how the AO "should be used" for me. :) And I gotta say it does look sweet. But I think as you pointed out it does take a performance hit, but we're on pretty pimp hardware. Not sure how big of a performance hit though.

    Edit.
    Thanks for that link btw. MoP is talking about the exact same thing I'm trying to say. He even has more nice examples than me T_T
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    Your rendering formula is wrong. It's really: diffuse texture * lighting where lighting is the sum of all lights: diffuse texture * (direct lighting + ambient lighting) and if you have ao: diffuse texture * (direct lighting + (ambient lighting * AO) ) . It's not expensive at all depending on the rendering style, forward rendering it adds a single multiply to the shader which is nothing. Deferred lighting, the ambient light would need to read 1 more texture. The same with deferred lighting, unless you write out 2 light buffers, one for direct and one for ambient.
Sign In or Register to comment.