Point clouds: lighting, 2D visual style, real-time density

Points carry their world normal: POINTCLOUDLIGHTING lights them in the
shaded visual styles (1 lit from both sides, 2 with back faces dark),
from the view (POINTCLOUDLIGHTSOURCE 0) or the default lights (1).
The 2D wireframe style draws no cloud points: a found cloud shows its
extents and "Point clouds are not displayed in 2D visual style.",
or nothing with POINTCLOUD2DVSDISPLAY 1. While the view moves only
POINTCLOUDRTDENSITY per cent of the points are drawn; the points are
stored in an order where every leading part samples the whole cloud.
The colour map dialog lists its schemes by name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-09-30 14:54:03 +03:00
1 parent ee0d4aedb5
commit b69ae291bb
10 files changed
+202 -22

No files matched your search

+21 -1
View File
@@ -22,9 +22,13 @@ struct Uniforms {
struct PointParams {
size_px: f32,
// POINTCLOUDLIGHTING (0 off; 1 lit from both sides; 2 back faces dark)
// and POINTCLOUDLIGHTSOURCE (0 headlight; 1 the default lights).
lighting: f32,
source: f32,
_pad0: f32,
light_dir: vec3<f32>,
_pad1: f32,
_pad2: f32,
};
@group(1) @binding(0) var<uniform> params: PointParams;
@@ -32,6 +36,7 @@ struct PointIn {
@location(0) pos: vec3<f32>,
@location(1) pos_low: vec3<f32>,
@location(2) color: vec4<f32>,
@location(3) normal: vec4<f32>,
};
struct VertOut {
@@ -54,6 +59,21 @@ fn vs_main(@builtin(vertex_index) corner: u32, in: PointIn) -> VertOut {
let half_ndc = params.size_px / max(u.viewport_size, vec2<f32>(1.0, 1.0));
out.clip_pos = vec4<f32>(clip.xy + corners[corner] * half_ndc * clip.w, clip.z, clip.w);
out.color = in.color;
let n = in.normal.xyz;
if params.lighting > 0.5 && dot(n, n) > 0.01 {
// Measured from the reference: headlight ambient 0.2 + 0.576 diffuse,
// the default lights 0.3 + 0.9 (clamped).
let d = dot(normalize(n), params.light_dir);
var shade: f32;
if params.source > 0.5 {
shade = min(0.3 + 0.9 * max(d, 0.0), 1.0);
} else if params.lighting > 1.5 {
shade = 0.2 + 0.576 * max(d, 0.0);
} else {
shade = 0.2 + 0.576 * abs(d);
}
out.color = vec4<f32>(in.color.rgb * shade, in.color.a);
}
return out;
}