Easy3D 3.0.0
Loading...
Searching...
No Matches
SurfaceMeshAmbientOcclusion Class Reference

Per-vertex ambient occlusion computed by hemisphere ray casting. More...

#include <easy3d/algo/surface_mesh_ambient_occlusion.h>

Classes

struct  Parameters
 Bake parameters. More...
 

Static Public Member Functions

static SurfaceMesh::VertexProperty< float > bake (SurfaceMesh *mesh)
 Computes per-vertex ambient occlusion with the default parameters and stores it in the vertex property "v:ao".
 
static SurfaceMesh::VertexProperty< float > bake (SurfaceMesh *mesh, const Parameters &parameters)
 Computes per-vertex ambient occlusion and stores it in the vertex property "v:ao".
 
static void colorize (SurfaceMesh *mesh, const SurfaceMesh::VertexProperty< float > &ao, const vec3 &color=vec3(1.0f))
 Writes the ambient occlusion term to the vertex color property "v:ao_color".
 

Detailed Description

Per-vertex ambient occlusion computed by hemisphere ray casting.

Unlike the screen-space ambient occlusion driven by RenderSettings, this is a view-independent bake: around every vertex a set of rays is cast into the cosine-weighted hemisphere of its normal, and the fraction of rays that escape the mesh within the search radius is stored. The result depends only on the geometry (not on a camera or a viewport), is deterministic, and is accurate enough to render publication-quality figures.

Example usage:

static void colorize(SurfaceMesh *mesh, const SurfaceMesh::VertexProperty< float > &ao, const vec3 &color=vec3(1.0f))
Writes the ambient occlusion term to the vertex color property "v:ao_color".
Definition surface_mesh_ambient_occlusion.cpp:274
static SurfaceMesh::VertexProperty< float > bake(SurfaceMesh *mesh)
Computes per-vertex ambient occlusion with the default parameters and stores it in the vertex propert...
Definition surface_mesh_ambient_occlusion.cpp:191
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44

The mesh must be a triangle mesh; vertex normals are updated by bake().

Member Function Documentation

◆ bake() [1/2]

SurfaceMesh::VertexProperty< float > bake ( SurfaceMesh *  mesh)
static

Computes per-vertex ambient occlusion with the default parameters and stores it in the vertex property "v:ao".

Parameters
meshThe surface mesh (must be a triangle mesh).
Returns
The vertex property "v:ao", with values in [0, 1] (1 = fully visible).

◆ bake() [2/2]

SurfaceMesh::VertexProperty< float > bake ( SurfaceMesh *  mesh,
const Parameters &  parameters 
)
static

Computes per-vertex ambient occlusion and stores it in the vertex property "v:ao".

Parameters
meshThe surface mesh (must be a triangle mesh).
parametersThe bake parameters (see Parameters).
Returns
The vertex property "v:ao", with values in [0, 1] (1 = fully visible).

The bake is deterministic: the same mesh and parameters always produce the same values, independent of the thread count.

◆ colorize()

void colorize ( SurfaceMesh *  mesh,
const SurfaceMesh::VertexProperty< float > &  ao,
const vec3 &  color = vec3(1.0f) 
)
static

Writes the ambient occlusion term to the vertex color property "v:ao_color".

Parameters
meshThe surface mesh.
aoThe per-vertex occlusion term returned by bake().
colorThe unoccluded surface color (default: white).

The resulting color is color * ao, so it can be used directly as a material or exported as vertex colors. The scalar term in "v:ao" stays intact, so the mesh can be colorized repeatedly.


The documentation for this class was generated from the following files: