1 MINUTE VEX

Introduction


No matter what kind of Houdini tutorials you’ve searched or SideFX demonstrations you’ve seen, you’re likely to have come across the vast, incredibly powerful expression language that is VEX. It has quite the learning curve, as most languages do, but knowing how and when to use it efficiently can be amongst the most rewarding challenges in working with Houdini.

These tips are not intended for the Houdini or VEX beginner - they are an accumulation of the most useful snippets I have come across and written during the last few years. Having to trawl the internet for obscure code while under pressure to deliver can be very daunting; So I hope the following can be as convenient for you as they have been for myself.



1 Minute VEX I - u attribute on complex curves
1) Using surfacedist() and min/max attribute promotion to create a u attribute from point group target distance.

1 Minute VEX II - sampling attributes with uvdist and primuv
2) Using uvdist() and primuv() to sample P on a series of curves, adding a point and respective group at the sampled location.

1 Minute VEX III - ray-cast ambient occlusion
3) Using sample_hemisphere() and intersect() to generate point-based ray-cast ambient occlusion.

1 Minute VEX IV - scaling objects by camera NDC
4) An introduction to NDC space, and using to/fromNDC() to scale objects without changing position relative to camera.

1 Minute VEX V - display culling by camera NDC
5) Using toNDC() and removepoint() to delete points that are not displayed on camera.

1 Minute VEX VI - camera occlusion culling
6) Using intersect() and optransform() to delete points hidden by camera occluding geometry.

1 Minute VEX VII - OCIO transformed attribute from image
7) Using colormap() and ocio_transform() to read an sRGB image and convert it to an ACES-compliant attribute.

1 Minute VEX VIII - sampling nearest texture with UDIM filename expansion
8) Using xyzdist(), primuv() and colormap() to sample the nearest UDIM-friendly texture on a surface.

1 Minute VEX IX - triplanar mapping & projection
9) Using simple vector math, for loops and colormap() to create an attribute triplanar projection

1 Minute VEX X - weighted integer sampling
10) Using sample_discrete() to make a weighted selection from an array.

1 Minute VEX XI - iterating over attributes (finding prim patch area)
11) Using uniquevals() and findattribval() to find the area of a prim patch (by attrib id)

1 Minute VEX XII - gradient estimation from neighbours
12) Using neighbours() to find all adjacent points and calculate a gradient vector with custom weights.