Viewpoint-Based Per-Vertex Ambient Occlusion package for Unity URP.
Add to Unity Package Manager
Paste this URL into Unity's Window › Package Manager › + › Add package from git URL,
or click Install.
https://www.pkglnk.dev/viewpoint-vertex-ao.git README
Rendered from GitHubViewpoint-Based Per-Vertex Ambient Occlusion

A Unity URP package that computes per-vertex Ambient Occlusion by rendering the mesh from multiple viewpoints and accumulating depth-based visibility. AO is computed once at runtime on initialization and baked into the material — there is no per-frame overhead after that. The result matches the visual appearance of URP/Lit with an Occlusion Map. Because AO is stored in auto-generated UV2 coordinates and vertex colors, the mesh does not need pre-existing UV unwrapping.
Because AO is baked in world space rather than computed per-frame in screen space, both eyes in a stereo VR headset read identical occlusion values — unlike Screen Space Ambient Occlusion (SSAO), which evaluates the scene independently from each eye's viewpoint and can produce subtly different results per eye, causing visual inconsistency in VR.
Requirements
- Unity 2022.3.0f1 or later
- Universal Render Pipeline (URP) 12.1.0
Installation
Package Manager UI (recommended)
- Open Window > Package Manager.
- Click the + button in the top-left corner and choose Add package from git URL…
- Enter the following URL and click Add:
https://github.com/NegativeMind/viewpoint-vertex-ao.git
Usage
Attach
AOBehaviourto any GameObject that hasMeshFilter+MeshRenderercomponents (child objects are included automatically).Configure the component in the Inspector:
Property Description Spread AngleCone half-angle around each vertex normal. 1.0= full hemisphere,0.0= equatorial ring. Controls how much of the sphere contributes to each vertex's AO.Sampling LevelNumber of viewpoints. Higher = smoother AO, longer bake time. Capture ResolutionResolution of the per-viewpoint depth capture texture (256–4096). Higher = finer geometry detail resolved, more GPU memory. Default is High(1024).AO ScaleBlend factor between no-occlusion ( 0) and full occlusion (1).Show DebugReplaces the material with a grayscale preview of the raw AO values, and draws the viewpoint positions as gizmos in the Scene view. Play the scene. AO is computed once during
Start()and applied immediately.
| Without AO | AO debug view (Show Debug) |
|---|---|
![]() |
![]() |
Notes
- The mesh's material is replaced at runtime. The original material's properties (base texture, color, metallic, smoothness) are copied to the new material via
CopyPropertiesFromMaterial. - AO computation renders meshes explicitly with
CommandBuffer.DrawMesh, so no dedicated layer setup is required. - AO is not recalculated at runtime after
Start(). Re-enter Play mode to recompute. - The
_VERTEX_COLOR_AOshader keyword enables reading AO from vertex colors instead of UV2, for use with custom shaders that need AO in theCOLORsemantic. - VR / XR: Single Pass Instanced stereo rendering is supported. All shaders include
#pragma multi_compile_instancingand the required URP stereo macros. Depth capture bypasses the URP pipeline viaCommandBuffer.DrawMeshto avoid XR interference with the internal depth texture.
References
Paper
Viewpoint-Based Ambient Occlusion Rudomin, I., Hernández, B., & Barrera, R. (2006). IEEE Computer Graphics and Applications, 26(6), 60–69. https://www.researchgate.net/publication/5501367_Viewpoint-Based_Ambient_Occlusion
The technique samples the hemisphere above each vertex's surface normal by rendering the scene from N viewpoints distributed on a sphere. Each viewpoint votes on whether a vertex is visible, and the mean visibility is taken as the AO value.
WebGL Implementation
geo-ambient-occlusion by wwwtyro — a WebGL implementation of the viewpoint-based AO technique: https://github.com/wwwtyro/geo-ambient-occlusion
Original Unity Implementation
This package is based on Unity-GeoAO by Xavier Martinez (nezix), which references geo-ambient-occlusion above — MIT License: https://github.com/nezix/Unity-GeoAO
Adapted for URP, refactored to use a running-average accumulation shader, and extended with per-vertex normal cone filtering.
See THIRD_PARTY_NOTICES.md for full license texts.
Algorithm
N viewpoints are distributed on a sphere around the mesh using a Fibonacci spiral. The scene is rendered from each viewpoint with a depth buffer. For each vertex, the shader checks whether the viewpoint falls within the cone around the vertex normal (Spread Angle), and if so, tests visibility against the depth buffer. Visibility results are accumulated as a running average. The final value per vertex is a mean visibility in [0, 1] (1 = no occlusion, 0 = fully occluded), which is baked into a texture and applied to surfaceData.occlusion — darkening only indirect (ambient/GI) lighting, identical to URP/Lit with an Occlusion Map.
Versions 0
No versions tracked yet.
Dependencies 3
Changelog 0 releases
No changelog entries yet. Run the admin Changelog & Version Scanner to pull from the repository's CHANGELOG.md.
README Markdown
Copy this to your project's README.md
## Installation
Add **Viewpoint Vertex AO** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/viewpoint-vertex-ao.git
```
[](https://www.pkglnk.dev/pkg/viewpoint-vertex-ao)Embed badge README snippet
[](https://www.pkglnk.dev/pkg/viewpoint-vertex-ao) <a href="https://www.pkglnk.dev/pkg/viewpoint-vertex-ao"><img src="https://www.pkglnk.dev/badge/viewpoint-vertex-ao.svg" alt="pkglnk installs"></a> https://www.pkglnk.dev/badge/viewpoint-vertex-ao.svg Comments
No comments yet. Be the first!




Sign in to join the conversation
Sign In