Rendering a point cloud without normals using Eye Dome Lighting (EDL) for depth perception.
Overview
This tutorial renders a raw point cloud that has no normal information, yet still conveys shape and depth clearly, by adding Eye Dome Lighting to the standard Easy3D Viewer. It uses the familiar effect pattern (see Tutorial_501_AmbientOcclusion): subclass Viewer, install a RenderSettings in init(), and replace it to toggle the effect. The entry point loads the bunny point cloud, gives it a uniform color and a visible point size, and runs the custom viewer; the EDL logic lives in the TutorialEyeDomeLighting class (shown after this file).
The technique
A point cloud has no connectivity and often no normals, so classical lighting (Lambert, Phong) cannot be evaluated — a flat-colored cloud looks like a confusing blob of dots. Eye Dome Lighting (Boucheny, 2009; popularized by CloudCompare and Potree) is an image-space shading trick that needs only the depth buffer: the cloud is first rendered normally into color and depth buffers, then a full-screen post-process compares each pixel's depth with the depths of a few neighbors at a small screen-space offset. If the neighbors are consistently closer to the camera, the pixel lies on the "far side" of a depth discontinuity (a silhouette or crease) and is darkened; pixels on flat, front-facing regions stay bright. The darkened contours act like a shading cue and make silhouettes, overlaps, and surface relief pop out, even though no surface or normal was ever computed. It is cheap (one extra pass), works on any point set, and complements ambient occlusion for meshes (Tutorial_501). See the renderer's EDL pass for the implementation.
Easy3D API
- Viewer: the interactive viewer; subclass it, install RenderSettings in init(), and override key_press_event() to control the effect by replacing those settings.
- RenderSettings::eye_dome_lighting: the declarative flag that enables the depth-based pass.
- PointCloud / DrawablePoints: the data and its points drawable; set_uniform_coloring() gives all points one color (so all shading variation comes from EDL) and set_point_size() makes the splats large enough to cover the surface.
Running it
Press 'space' to toggle Eye Dome Lighting on/off (the state is printed to the console) and compare how much easier the shape is to read with the contours darkened. Standard Viewer navigation (mouse drag to rotate, wheel to zoom) applies.
28#include <easy3d/core/model.h>
29#include <easy3d/renderer/drawable_points.h>
30#include <easy3d/renderer/renderer.h>
31#include <easy3d/util/resource.h>
32#include <easy3d/util/initializer.h>
89int main(
int argc,
char **argv) {
95 const std::string file = resource::directory() +
"/data/bunny.bin";
98 TutorialEyeDomeLighting viewer(EXAMPLE_TITLE);
102 auto model = viewer.add_model(file,
true);
104 std::cerr <<
"failed to load model. Please make sure the file exists and format is correct" << std::endl;
111 auto drawable = model->renderer()->get_points_drawable(
"vertices");
112 drawable->set_uniform_coloring(
vec4(0.6f, 0.6f, 1.0f, 1.0f));
113 drawable->set_point_size(5.0f);
Definition collider.cpp:182
The header file of the viewer class:
27#ifndef EASY3D_TUTORIAL_EYE_DOME_LIGHTING_H
28#define EASY3D_TUTORIAL_EYE_DOME_LIGHTING_H
30#include <easy3d/viewer/viewer.h>
44 explicit TutorialEyeDomeLighting(
const std::string &title =
"");
50 bool key_press_event(
int key,
int modifiers)
override;
The default viewer implementation for both OpenGL and Vulkan backends.
Definition viewer.h:143
The source file of the viewer class:
28#include <easy3d/core/point_cloud.h>
29#include <easy3d/renderer/camera.h>
30#include <easy3d/renderer/render_settings.h>
38TutorialEyeDomeLighting::TutorialEyeDomeLighting(
const std::string &title) :
Viewer(title) {
40 camera()->set_up_vector(
vec3(0, 1, 0));
41 camera()->set_view_direction(
vec3(0, 0, -1));
42 camera_->show_entire_scene();
45 hint_ =
"Press 'space' to toggle Eye Dome Lighting";
48void TutorialEyeDomeLighting::init() {
54 settings.eye_dome_lighting =
true;
55 set_render_settings(settings);
60bool TutorialEyeDomeLighting::key_press_event(
int key,
int modifiers) {
61 if (key == KEY_SPACE) {
64 settings.eye_dome_lighting = !settings.eye_dome_lighting;
65 set_render_settings(settings);
66 std::cout <<
"Eye Dome Lighting "
67 << (settings.eye_dome_lighting ?
"enabled" :
"disabled") << std::endl;
71 return Viewer::key_press_event(key, modifiers);
Declarative effect settings shared by all rendering hosts.
Definition render_settings.h:80
- See also
- RenderSettings, Viewer, PointCloud, DrawablePoints, Tutorial_501_AmbientOcclusion