# Difference between revisions of "HoudiniExperiments"

### Occlusion Vop Sop

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!

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

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

#### Clouds

- File:clouds_v04.hipnc - fluffy

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

#### Points down veins

Download scene: File:points_down_veins.hip

Grains fail: File:points_down_veins_grains.hip

Take 2, with pop attract and grains:

Download scene: File:points_down_veins_grains_v02.hip

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...

Download scene: File:points_down_veins_grains_v04.hip

#### Stroke in houdini

Download scene: File:stroke_v01.hipnc

### Bow vectors

Download scene: File:bow_vectors.hipnc

### Subdivide on one axis

Download scene: File:subdiv_on_z.hipnc

### Rivets

Download scene: File:rivetting.hipnc

Download scene: File:rivets_fix.hipnc

### Recursive copy with for loop

Download scene: File:fern_grow.hip

### Rope weave

Download scene: File:rope_weave.hip

### Volume deform on curve

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

### Sweep with twist and scale control

Download scene: File:sweep_twist_v02.hipnc

### Struts

Download scene: File:struts.hip

### Pop droplets

Download scene: File:Running Droplets_me_v02.hip

### Display binary numbers in a font sop

Download scene: File:decimal_as_binary_text.hip

Uses tricks from these 2 posts:

### For loop recursive clip subdivide

Download scene: File:recursive_subdivide.hip

### Vdb clip slices

Download scene: File:vdb_clip.hip

### Curve unroll

This was the first pass rough version, I cleaned it up and made a longform tutorial: CurveUnrollTutorial.

Download hip: File:curve_unroll.hip

I can't post this in the regular wiki until I understand it properly, its all a little delicate and hard coded. The idea is to measure the angle between each point and store that as an attribute. Then in another wrangle rotate each primitive by that angle to flatten out the shape.

The tricky bit is that for prim 5, it has to be the accumulated rotations of primitives 0 1 2 3 4. Plus, to make it interesting each prim has to have its rotation timing staggered to get this unroll effect to work. Plus plus, its a mildly tricky dance where the rotation has to be done by moving each prim to the origin, but then put back at the right place where its the position of the accumulated rotations.

If I don't think about it too much I can recreate it from scratch, but if I get it wrong, its lots of random stabbing, swapping the order of code lines, frustration. One day I'll revisit it and try to properly understand it (or come up with a cleaner implementation), but until then...

Original odforce thread here : http://forums.odforce.net/topic/31600-spiral-unrolling-rolling-animation/?tab=comments#comment-174963

### Purple Trails

Download file: File:purple_trails.hipnc

### Pig sphere deform

Download file: File:pig_sphere_deform1.hipnc

### Sphere plot motion trail

Download file: File:plot_motion_path.hip

### Skeleton from edge transport

Download scene: File:skeleton_edge_transport.hip

### Metaball bevel

Download hip: File:metaball_bevel.hip

### Video stipple

Inspired by this cool reddit post.

Download hip: File:stipple.hip

### Steel wool

Download hip: File:steel_wool.hip

### Chaser lights

Download hip: File:chaser_lights.hip

### Projection setup

Download hip: File:polar_projection_hdr.hip Download hip: File:polar_projection_hdr_redshift.hip

Quick go at taking an hdri, building proxy geometry in the viewport while seeing the projection in the viewport, then dropping in some other models to reflect/get bounce light and shadows from these objects. A photogrammetry setup like this is common in commercials and vfx. Mantra and redshift setups are provided.

### Curve bend

Download hip: File:curve_bend.hipnc

Setup using the hair guide process node to do the bend per curve, and some fiddly bits to add a straight section before and after the bend.

### Pops from points

Download hip: File:pops_from_points.hip

### Mops page turn

Mops is cool. The falloff node is super fun, makes setting up a page flip effect like this a breeze.

Download hip: File:mops_pageturn.hip

### Wire tree

Download hip: File:wire_tree.hip

Or a much simpler way using a sweep: File:wire_tree_sweep.hip