Home General Discussion

Why Ambient Occlusion vs Baking Into Diffuse?

Hello, apologies for the potentially "google-able" question.

I'm struggling to understand why AO needs to be it's own map in modern renderers. Is it only relevant for baked lighting in Unity/UE? I know many stylized games or mobile games simply bake this information into the diffuse. Why do platforms with extra processing power opt to keep it separate?

Replies

  • Eric Chadwick
    Options
    Offline / Send Message
    Ambient occlusion texture is used in non-raytraced real-time renderers (called “rasterizers”) to reduce lighting from the ambient lighting environment around the model, wherever there are crevices or overlaps on the model.

    The occlusion is kept separate because it should not affect direct lighting, which is any lighting that comes from strong light sources, for example the sun, a flashlight, etc.

    Raytracers calculate occlusion automatically, as part of global illumination and light bounces. So the ambient occlusion map is typically ignored by them.

    In most rasterizers that support physically based rendering (PBR) the occlusion texture is packed along with two other grayscale textures (roughness and metalness) into a single bitmap, using the R G and B channels. This keeps the material efficient for downloading and for memory usage during rendering.

    So it’s really pretty cheap to include. And it does make a visual difference.
  • Leinad
    Options
    Offline / Send Message
    Leinad polycounter lvl 11
    Q: I'm struggling to understand why AO needs to be it's own map in modern renderers.
    A: It doesn't need to be. There is no hard rule that says you have to do it this one way. Depends on the project needs.

    Q: Is it only relevant for baked lighting in Unity/UE?
    A: It's commonly used to simulate ambient occlusion. Again, no hard rules, I can probably use this ao data to get some sort of cool effect in Unity that is not light related.

    Q: Why do platforms with extra processing power opt to keep it separate?
    A: It gives the user more control and flexibility to use the texture the way that is appropriate for their project.
    In many ways it's similar to how many artists don't merge their source photoshop file layers to more easily edit their files.
    Nothing says you have to use a AO texture a specific way. But if you merged the ao texture data into the diffuse then you would be locking me into a workflow that might not be appropriate for my project needs. By keeping the AO texture separate I give you the option to choose what kind of workflow you want to adopt for handling AO texture data.
  • Alex_J
    Options
    Online / Send Message
    Alex_J grand marshal polycounter
    i might be wrong but in ue5, if you are using lumen, you wouldn't need AO map (not for actual ambient occlussion anyway, it's still useful map for many creative texturing needs)
  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    its still useful with lumen. 

    the lighting solution can only work with geometry so any extra surface information you're adding with textures can't be properly represented. 
  • Eric Chadwick
    Options
    Offline / Send Message
    You may also need occlusion as a separate texture from packed rough-metal, if using a fixed function renderer and the user wants to tile metal-rough but not tile occlusion. glTF renderers typically work this way.
  • iam717
    Options
    Offline / Send Message
    iam717 greentooth
    poopipe said:
    its still useful with lumen. 

    the lighting solution can only work with geometry so any extra surface information you're adding with textures can't be properly represented. 
    Quoted because why not have a conversation on this: Idk if this is "correct" but when i "paint on extra details" like (a square indent), i usually "generate a new AO for these very situations, this should be fine right... using the baked normal map to gen a new AO, turning off all other "edit layers".  I do not see the harm.  Re-reading thread, so we may no longer need Ao in the future with the new lighting system becoming "main" course for lighting?.


    A.?"Raytracers calculate occlusion automatically, as part of global illumination and light bounces. So the ambient occlusion map is typically ignored by them."



  • pior
    Options
    Offline / Send Message
    pior grand marshal polycounter
    "Re-reading thread, so we may no longer need Ao in the future with the new lighting system becoming "main" course for lighting?"

    That's not quite how the renderering pipelines of game engine evolve or get used. It doesn't matter *one bit* if this or that feature gets added (for instance, a renderer having some way to simulate the occlusion of light in crevices) - this is just and always will be a tool in a toolset.

    Even using an engine with the best-of-the-best implementation of realtime AO ever doesn't mean that there can't be benefits in having it also as a texture pass, or even as some of it baked in the diffuse texture. Especially since dirt gathers in cracks ... exactly like an AO pass.

    Just because these 3 things (realtime AO, AO stored as a texture pass, and AO hard-painted into the color pass) are using the same acronym "AO", doesn't mean that one replaces the other.

    It's always the same issue of people taking the name of something technical at face value as opposed to actually experimenting with it and using it for what it is. And that's why it's so important for a team to have experienced artists who are willing to push back against the sometimes dogmatic decisions of techart.
  • Eric Chadwick
    Options
    Offline / Send Message
    Yo you callin me a dog dawg? 
  • pior
    Options
    Offline / Send Message
    pior grand marshal polycounter
    Hehehehe :D 
    You're of the good kind !
  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
    Few things I'd like to add.

    Epic themselves generally suggest using AO textures for small cavities and letting SSAO/SSGI/Lumen/DFAO do their jobs. 

    AO being baked into textures isn't necessarily a bad thing, it can simulate dirt and grime even if you're getting AO elsewhere.



    Often times with textures you got albedo and normal that need to be their own textures, then roughness that can be channel packed, metallic for some textures, and then a left over spot that could be something like AO, a mask, or emissive. AO is just an easy thing to default to.

  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    having a separate AO texture means you can also use tiled textures a tiled texture with baked ambient can look a tad strange. Obviously it modern world of humongous textures it's not as common as it once was it's still useful to have.... other reason could be you want to animate the diffuse again it would look odd if baked in. Theres lots of reason you may want the ambient split from the diffuse.... you may want an effect to wash it out or change it's colour without changing the diffuse.
  • Eric Chadwick
    Options
    Offline / Send Message
    Now that the wiki’s back, I’ve revised the summary for AO to explain this point about separation from diffuse a bit better. Added a section, and a neat diagram. http://wiki.polycount.com/wiki/Ambient_occlusion_map#Ambient_Occlusion_Baked_into_Diffuse


    This is from 2008 using Mental Ray renderer, but same principles still apply for real-time rasterizers.
  • kanga
    Options
    Offline / Send Message
    kanga quad damage
    homsar47 said:
    ...
    I'm struggling to understand why AO needs to be it's own map in modern renderers. ...
    I love having AO as a map and have always baked it out individually. Using it in materials and combining it with diff gives the result a pop which you can also dial in to suit. If you can afford it why not use it?

  • gnoop
    Options
    Offline / Send Message
    gnoop polycounter
    The main difference in between  having separate AO channel vs  having it baked into color texture (albedo/base color )    is that  in typical real-time  render  AO will be seen only inside shadows  or under cloudy overcast lighting.    On directly  illuminated by sun  sides of things  you typically  wouldn't see any AO.  

    It's actually how we see the phenomena in real world too.

    When baked into base color  you will always see it  , at any condition and it's usually gives a bit of naive art look .    

      Still if you want to render some  small and static shadows  from tiny details , like a shadow from  grass blades . or shadows beneath wall stones   it could be in albedo texture  but at the same time  such things can't be too dark and contrast.  Otherwise   in shaded side of such  wall they would look weird . 

    That's why Unreal default shader has specular scalar  input   that you can use instead or together  with AO .  it works not same but similar  and still stay on illuminated side .
  • starcow
    Options
    Offline / Send Message
    starcow polycount sponsor
    Now that the wiki’s back, I’ve revised the summary for AO to explain this point about separation from diffuse a bit better. Added a section, and a neat diagram. http://wiki.polycount.com/wiki/Ambient_occlusion_map#Ambient_Occlusion_Baked_into_Diffuse


    This is from 2008 using Mental Ray renderer, but same principles still apply for real-time rasterizers.
    I am ambivalent about this claim. The argument has its valid points. On the other hand, from a technical point of view, neither is correct if you use real global illumination (sampled at a high level) as a reference.
    A darkening effect in corners and cavities occurs in reality even when the scene is illuminated with direct light. This is also what is strangely noticeable in the second "better" image.
    Which of the two images now looks better is ultimately a matter of taste. To claim that the second is clearly better, I find daring. I would prefer a mixture of both. Absolutely no ambient occlusion in the irradiated areas, it just doesn't really look better.
  • Eric Chadwick
    Options
    Offline / Send Message
    Agree it’s objectively better if you’re using full global illumination. Then you’re getting reactive bounces and accumulation and occlusion, yippee!

    But I think we’re talking about real-time rendering here, which is all about shortcuts, like using baked occlusion, and deciding how you want to mix it in your shader. At which point you can decide you want to mix it into diffuse or not.

    BTW you can also use baked AO for specular occlusion, which helps with real-time rendering for metals and occluding self-reflections.

    Anyhow, ultimately a rasterizer (what most real-time renderers use) is never going to look as good as a raytracer. Which I think is your point.
  • Eric Chadwick
    Options
    Offline / Send Message
    A demo of specular occlusion in glTF, using the extension KHR_materials_specular. I put the four textures for ambient occlusion, roughness, metalness, and specular occlusion all into a single shared RGBA texture. To make the specular map in the alpha channel, I copied the ambient occlusion from the red channel into the alpha channel, and made it more contrasty with a Levels adjustment. 



  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
    I wonder how that compares to bent normals in practice, the look seems very similar.

    https://docs.unrealengine.com/5.0/en-US/bent-normal-maps-in-unreal-engine/
  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    It's not the same thing and they're not mutually exclusive

    Baking specular occlusion into a texture is the same as baking ambient occlusion into a texture - you do it so you can insert information that doesn't exist in your meshes into the lighting system. 

    The bent normal stuff is about manipulating the surface normals used for indirect lighting.  Bent normals can reduce unwanted specular highlighting but that's because it prevents the specular highlighting being there in the first place rather than occlusing it after the fact. 

    It's not unusual to lump specular occlusion in to the same pass as ambient occlusion (I believe UE4 does it) as it generally gives good enough results







  • gnoop
    Options
    Offline / Send Message
    gnoop polycounter
    About bent normals . They require one more separate  "normal map"  of 3 channels , right?   I wonder does anyone really use it in gamedev?
  • Benjammin
    Options
    Offline / Send Message
    Benjammin greentooth
    gnoop said:
    About bent normals . They require one more separate  "normal map"  of 3 channels , right?   I wonder does anyone really use it in gamedev?
    Only character artists in my experience. Don't ask me why  :lol:
  • XilenceX
    Options
    Offline / Send Message
    XilenceX polycounter lvl 10
    I think this is a fascinating topic. Especially in high end realtime renderers like UE5 with Nanite highpoly assets, Lumen and VSM.
    We create our 3D scans with a cross polarized setup, which creates textures with essentially the real Albedo color values of the scanned object.
    Even with all UE5 features turned on (except hardware raytracing features, which is prohibitively expensive for realtime rendering atm) the assets with their real Albedo colors often look rather "boring" / flat.

    Turning off static lighting in the project settings helps, since only then the Ambient Occlusion channel actually has a proper effect in UE5.
    Still, I end up multiplying the AO into the Albedo texture, at least at a low opacity, in my material. 

    In a way I'm glad that it looks like I'm not the only one doing this. Since it's sacrificing some realism for the sake of a subjectively nicer looking scene.
  • EarthQuake
    Options
    Offline / Send Message
    Generally, the approach with AO will depend on how good the lighting systems are in your engine or target renderer.

    • AO should be typically applied with a secondary texture and not baked into albedo (or other maps). This allows the engine to multiply the AO on ambient or indirect lighting pass only. AO should not multiply on direct lighting. A typical example would be AO baked on the underside of a fridge. If applied to the direct lighting component, and a flashlight was shined underneath the fridge, it could never be illuminated. So multiplying AO on all lighting passes tends to look bad because it will be obviously incorrect in some cases - it will tend to look more like dirt* than a lighting effect.
    • If your engine doesn't have an inter-object reflection system, using AO as a sort of reflection occlusion pass can be helpful. But this tends to look pretty bad - when two objects are near each other, the reflections do not darken, the objects simply reflect each other. So again, this looks like a dirty effect, which might be better than nothing but generally doesn't look very good. Luckily, most game engines have either screen space or ray-traced reflection options these days, assuming your project targets modern GPUs.
    • Similarly, diffuse light does not simply get dark when two objects are near, diffuse light is reflected from one object to another, so the objects tend to act more as a light source than occluders. If your engine has a quality GI solution, it's probably not a good idea to multiply AO on the textures. Though depending on the sophistication of system, you may want some degree of micro-occlusion. Baking AO maps with a limited search distance to minimize the inclusion of large-scale occlusion can help.
    • If you're using a full-on ray-tracer/path-tracer (UE5/Lumen uses a hybrid system), there tends to be very little need to use baked AO maps, mostly you'll be adding unnecessary occlusion in this case.

    * As Pior mentioned AO (and direction, curvature, linear gradients, etc) are often used when generating various wear effects for materials. But this is very different from multiplying AO directly onto the maps. In this case, it's geometric data that is used to define where different surfaces (base surface, scratches, dirt, dust, etc) appear. For a dust effect, AO-influenced regions would typically become brighter, not darker. It's important to differentiate AO used as a means for generating masks and AO as a broadly applied multiplicative effect.

    If anyone is interested in testing some of these concepts and has access to Marmoset Toolbag, the Occlusion shading model can be set up either way.
    • The Occlusion slot allows loading of a texture that will only multiply on the ambient (sky) lighting pass
    • The Cavity slot can optionally multiply on both the diffuse and specular passes, both ambient and direct components. So you can try using AO to occlude the different passes at different intensities

    All that said, this isn't something you should consider applying or varying on a per-asset level. Art and technical direction should dictate how or if AO maps are used in the shading pipeline.
  • EarthQuake
    Options
    Offline / Send Message
    Here's a set of examples

    1. (upper left) basic raster (game engine-like) lighting with an ambient sky and some direct lights, no AO effect. The reflections are clearly incorrect here which prevents the surface from reading as metal
    2. (upper right) AO multiplied on the specular reflections - this is equivalent to multiplying the AO directly on the albedo map - the reflections are still incorrect here, but darker in the occluded areas. This doesn't create much of an improvement, it's simply wrong in a different way (two ways)
    3. (middle left) here we have no AO effect, but do have screen space reflections. This is not perfect (the reflections are incorrect in certain places due to screen-space limitations) but is much more convincing since the metallic material is reflecting itself and creating more saturated highlights which more accurately match how our brain perceives brass and other colored metals
    4. (middle right) ray-traced result, no AO effect, this has physically correct reflections and GI
    5. (lower left), screen space reflections + multiplied AO, this is wrong in two ways - screen-space limitations + dirty AO effect, and the dirty AO affect doesn't do much to counteract the limitations of the reflection effect. It just makes the reflections darker in certain areas, moving it further from the ground truth
    6. (lower right), ray-traced + AO, no improvement here, it just looks more grimy and less realistic. Now we're occluding some of the most interesting reflections which are essential to conveying the unique qualities of the surface

  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    Benjammin said:
    gnoop said:
    About bent normals . They require one more separate  "normal map"  of 3 channels , right?   I wonder does anyone really use it in gamedev?
    Only character artists in my experience. Don't ask me why  :lol:

    It's the best way we have to handle mouth interiors/nostrils etc with current lighting setups and since cinematics sell games the character artists get to have all the fun toys
  • gnoop
    Options
    Offline / Send Message
    gnoop polycounter
    poopipe said:
    Benjammin said:
    gnoop said:
    About bent normals . They require one more separate  "normal map"  of 3 channels , right?   I wonder does anyone really use it in gamedev?
    Only character artists in my experience. Don't ask me why  :lol:

    It's the best way we have to handle mouth interiors/nostrils etc with current lighting setups and since cinematics sell games the character artists get to have all the fun toys

    It's still one extra RGB texture . Not for characters  but I use specular scalar  black&white   channel  plus a bit of  AO  in albedo too and IMO it works no worse visually.   Or texture reads  are no more an issue  for  modern games?               

  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    like i said above, they're not mutually exclusive techniques - if you can afford it, do both cos it'll look better. 

Sign In or Register to comment.