HoudiniExperiments

From cgwiki

Occlusion Vop Sop

Not occ.jpg

Download scene: File:occlusion_vop_wip_v02.hipnc

Surprised to see there's no definitive answer for this (occlusion sop) either within houdini or on odforce; an odforce search turns up various answers about writing out point clouds, c++, bit slow, avoid, etc. My super low-brow understanding of how point-based occlusion works in prman made me think there should be a simple(ish) vop network to do this.

edit: Actually there's a thread on doing it here ( http://forums.odforce.net/topic/20792-learning-vopsop/page-10?hl=vops#entry124867 ), but I'm trying very hard to not look at the examples, and work it out myself! :)


The result isn't correct, but it's interesting. Density map? Curvature map? Not sure.

Anyway, here's the idea:

  1. Use measure sop to calculate area per primitive promote that to point
  2. Vop network that runs this loop per point:
    1. Get the nearest n points within a certain distance
    2. Loop over each found point and get its position, area, normal
    3. accumulate the distance * area * dot product of this points normal vs the found points normal
  3. output the final result and scale/gamma to taste


By accumulating the distance, near points should occlude more, far points occlude less. Except already I can see I have my logic wrong, my code should be reversed, damnit. Anyway, scale that by the area, again, bigger primitives occlude more, smaller less. Finally compare normal; the idea that prims that face each other get maximum occlusion, but perpendicular ones get none (eg,a point that has a polygon above it, edge-on, shouldn't occlude.... right?)

Like I said, the result isn't correct, but feels like it has potential. Hmm.

This uses 'nearpoints' and a loop, I'm sure pcfilter could be used instead to get the result even faster and lazier. Can't work it out though. And yes, of course I could just use a mantra occlusion shader and bake it, but where's the fun in that?

Second attempt

This looks better!

Pig ao2.jpg

Download scene: File:vex_ao.hip

This logic makes a little more sense; for each point, get a random ray direction within a cone (using the normal as the center of the cone), use intersect() to trace a ray out from that point along the ray. If it hits something, darken the point, if it doesn't hit something, ignore. The intserect() call can return all sorts of interesting info about the point it hit, which is a shame as I immediately throw away all that info, and just record if it hit something or not.

After about an hour of swearing at it, realised why it wasn't working; you need to add a little offset to the source point, otherwise intersect just hits the prim the point belongs to, and everything is occluded. That's the @P+(raydir*.001) bit in the intersect call.

vector hit, raydir;
float u, v, conewidth;
int hitprim;
@Cd = 1;
 
float maxdist = ch('maxdist');
conewidth = radians(ch('conewidth'));
int rays = chi('rays');
 
for (int i = 0; i<rays; i++ ) {
    raydir = sample_direction_cone(@N*maxdist,conewidth,vector2(rand(@Time+i)));
    hitprim = intersect(0,@P+(raydir*0.01), raydir, hit, u, v);
    if (hitprim==-1) {
      @Cd *= 1;
    } else {
      @Cd*=1-(1/float(rays));
    }
 
}
 
@Cd = pow(@Cd, ch('gamma'));

Generic rolling cubes

Rolling cubes wip.gif

Download scene: File:generic_rolling_cubes_wip_v01.hipnc

An extension of the 'cubes marching' example on the Houdini#Cubes_marching page, but modified so that that the cubes can roll over arbitrary surfaces.

It's close, but needs some work to make it proper sexy. I got lazy and used a 'find shortest path' sop to generate a path, but spent more time cleaning it up than on the actual effect. Anyway, getting clean normals for the system to work with is a chore, I had to do some manual editing to get them consistent.

The idea is if the path has well defined normals, we can use that to drive the lift-off-surface part, as well as the rotation axis (the rotation axis is cross(@v,@N) rather than cross(@v,{0,1,0}). You can see it gets a little twitchy on abrupt direction changes, feels like there should be a clean way to drive it. Parking it for now.

Misc

File:platonic_weave.hipnc

File:spin_grid.hipnc

File:spin_grid_vex.hipnc

File:vol_vel_clip_cube.hipnc

File:webbing.hipnc

Clouds

Clouds.jpg - File:clouds_v04.hipnc - fluffy

Clouds2.jpg - File:clouds_v05.hipnc - toned down displacement, much finer vdbtoparticles resolution

Carve without carve

Carve sans carve.gif File:carve_without_carve.hip

Normals

Normals dot example.jpg

Points down veins

Veins capture.gif

Download scene: File:points_down_veins.hip

Grains fail: File:points_down_veins_grains.hip

Take 2, with pop attract and grains:

Veins capture2.gif

Download scene: File:points_down_veins_grains_v02.hip

Veins split paths.gif

Take 3, using toadstorms wiser method to create paths from single tree structure with 'find shortest paths' sop. Download scene: File:points_down_veins_grains_v03.hip

Take 4. Classic itch I can't help but scratch...

Veins capture4.gif

Download scene: File:points_down_veins_grains_v04.hip

Stroke in houdini

Pig stroke.gif

Download scene: File:stroke_v01.hipnc

Bow vectors

Bow vectors cap.gif

Download scene: File:bow_vectors.hipnc


Subdivide on one axis

Edge subdiv one axis.gif

Download scene: File:subdiv_on_z.hipnc

Rivets

Download scene: File:rivetting.hipnc

Download scene: File:rivets_fix.hipnc

Rivet debug.gif

Recursive copy with for loop

Fern grow.gif

Download scene: File:fern_grow.hip

Rope weave

Weave screenshot.gif

Download scene: File:rope_weave.hip

Volume deform on curve

Vol path.gif

Download scene: File:volume_path_deform.hipnc

Pscale to colour

Download scene: File:pscale_in_shader.hip

Download scene: File:pscale_in_shader_v02.hip

Download scene: File:pscale_in_shader_packed.hip