Ambient Occlusion in Avogadro 2: update

Hi,

As some may have seen already, Avogadro 2 has a Van der Waals spheres
display type with Ambient Occlusion. However, this is not nicely integrated
with the overall rendering code and this mail contains information on how I
plan to integrate this. I’m currently moving so I plan to start working on
this in january.

The current technique is briefly outlined below:

  1. Ambient Occlusion (using textures)
  • needs UV or other texture mapping for occluded geometry
  • occluding geometry does not need this mapping (allows for mixed approach)
  • texture stores visibility from all angles (uniformly sampled in
    pre-processing step)

algorithm for “baking” occlusion maps:
for all viewing directions:
render occluding geometry (depth map stored in texture)
render to occlusion texture (lookup visibility in depth map)
add 1 / n_sample_dirs if pixel is visible from current viewing
direction

Moving this code to the GLRenderer class should not be difficult. However,
for ambient occlusion to work on all geometry we would need UV texture
mapping for meshes. For protein and nucleic acid meshes this could easily
be generated together with the mesh but I don’t have a solution yet for
handling surface meshes resulting from the marching cubes algorithm.

Another technique is Screen Space Ambient Occlusion.

  1. Screen Space Ambient Occlusion
  • post-processing step
  • samples depth map to compute occlusion
  • from wikipedia: “Rather local and in many cases view-dependent, as it is
    dependent on adjacent texel depths which may be generated by any geometry
    whatsoever.”

In short, I don’t think SSAO is very useful for avogadro.

Below are the concrete steps I plan to implement:

  • ambient occlusion will become global feature (on/off)
  • enable GLRenderer to render depth map to texture
  • add new rendering pass for depth only (same as opaque, but no lighting
    calculations required)
  • add support for post-processing steps on rendered image (for SSAO, also
    useful for bluring, etc.)
  • add UV-mapping for SphereGeometry and CylinderGeometry
  • experiment with various methods to unwrap surfaces to 2D textures (this
    is the most difficult part and suggestions are welcome)

references:


Tim

As some may have seen already, Avogadro 2 has a Van der Waals spheres display type with Ambient Occlusion. However, this is not nicely integrated with the overall rendering code and this mail contains information on how I plan to integrate this. I’m currently moving so I plan to start working on this in january.

This would be really great. Clearly the ambient occlusion support that’s already in there is very helpful with larger systems.

Moving this code to the GLRenderer class should not be difficult. However, for ambient occlusion to work on all geometry we would need UV texture mapping for meshes. For protein and nucleic acid meshes this could easily be generated together with the mesh but I don’t have a solution yet for handling surface meshes resulting from the marching cubes algorithm.

What’s the technical problem? Is it handling the transparency? I mean, I would think at mesh generation time for surfaces, you could also generate texture mapping in the same way as protein and nucleic acid ribbons/cartoons.

Or do you mean the problem is for general surfaces that have a mapped color scheme (e.g. electrostatic potential, which is already a texture on the surface).

Thanks,
-Geoff