Height Field Visibility

calendar_today

22.07.2024

label

Environment

mouse

Houdini 20.5

Description

A custom height field mask showing the eye-level visibility of each voxel. Most visible parts from any location on the terrain are highlighted red, rather hidden areas are marked blue.

1 Code

C
        // PARAMETERS
float lift = chf('lift');
float shorten = chf('shorten');

// SAMPLE POSITIONS
vector pos[] = detail(1, 'pos', 0);

// RAY ORIGINS
vector orig = v@P;
orig.y += f@height;
orig = minpos(1, orig);
orig.y += lift;

// RAYTRACING
int missed = 0;
foreach(vector p; pos){
    vector dir = p - v@P;
    float dist = length(dir);
    dir = normalize(dir) * max(dist - shorten, 0.0);
    int pr = intersect(1, orig, dir, set(0), set(0));
    missed += pr < 0;
}

// OUTPUT
f@mask = missed / float(len(pos));

/*
GRID POINTS FOR DEBUGGING
int pt = addpoint(0, orig);
setpointattrib(0, 'hits', pt, missed, 'set');
*/
    
download

Downloads

link

Related articles

favorite

260

label

Environment

Accumulate snow behind rocks

favorite

248

label

Environment

Crop Fields

favorite

180

label

Environment

Deforming a Height Field

favorite

124

label

Environment

Eikonal Distance Terrains

favorite

25

label

Environment

Geometric Median on Mesh Pieces

favorite

179

label

Environment

Height Field Gradient Advection