MixedReality-GraphicsTools-Unity icon indicating copy to clipboard operation
MixedReality-GraphicsTools-Unity copied to clipboard

User/pinkb/ambient occlusion

Open pinkwerks opened this issue 3 years ago • 1 comments

Overview

Adds an "ambient occlusion" component that modifies a mesh to include ambient occlusion data for use by the Standard Shader

image

image

Motivation

Ambient occlusion adds realism to a scene by providing important clues to viewers about an object's relationship to other objects. However, as a post-process it is expensive and not well suited for VR and low-end platforms. Baking global illumination to textures can cumbersome and relies on sane UVs (when not using lightmaps).

As an alternative, we bake this occlusion information into the mesh vertices, which is evaluated per vertex and passed to fragment shader as part of rasterization.

Notes

  • Additional updates to StandardShaderGUI.cs to support material conversions that use GLTF material semantics
  • The fidelity of the AO solution is very dependent on the vertex count and normals of the mesh.

pinkwerks avatar Aug 16 '22 23:08 pinkwerks

This is super cool and useful. Thank you for the contribution! Added some minor comments below.

I also tried it out locally and saw AO generated as expected (circled in blue) but also saw some vertices appear to get brighter (circled in green). Is this expected? image

Thanks for the review and comments! The "brighter" vertex was un-occluded due to ray casts not considering back faces. This has been fixed.

pinkwerks avatar Aug 27 '22 19:08 pinkwerks

Just checking in to see if this is ready for a re-review?

Cameron-Micka avatar Sep 08 '22 22:09 Cameron-Micka

I'm going to refactor this into a standalone window, and not a component. Will re-open a fresh PR when that is ready.

pinkwerks avatar Sep 09 '22 17:09 pinkwerks