×

RACOON ARTWORKS

Blog and Resources

WORK / INFO
Showcase
CG-Basics
About me
Contact
CG ARTICLES
PBR Shooting & Calibrating
PBR Rules & Measurements
OSL in Production
Timeride VR
PHYSICAL PROJECTS
Desk PSU
Microscope Ring Light
PCB Soldering Frame
Soldering Fume Extractor
Soldering Iron Stand
High Power Ring Light V2
High Power Ring Light
Trebuchet
Turntable V1
CG DOWNLOADS
Maxscripts
Extend Borders
ShapeConnect
CoronaConverter
RedshiftConverter
Autoload Materials
BindLightToCamera
QuickSplineClone

OSL
Parallax Occlusion Mapping

Blackmagic Fusion
Matcap Material
Firefly Filter
Tonemapping Tools


---------------------------
Imprint | Impressum
Privacy policy | Datenschutz
---------------------------

Houdini VEX renderer

Published 2017/10/06

This article has kind of transformed into a mini tutorial/aimless rambling about raytracing, sorry. The fancy images at the end are the important part here ;) .

So, I’ve started learning Houdini recently and I’ve completely fallen in love already. It’s not always easy, especially in the first few days, but it all starts to make sense now and writing my own operators and more complex stuff in VEX (programming language) is way more fun than I expected. VEX is easy to learn, incredibly fast and has a good mix between low level access and built-in high level functions.
Well, so what is a good way to practice vex and have a bit of fun? … Exactly, writing your own renderer!

AO and point lights

So, first thing I did was adding a plane in front of a camera, subdivide it (each point (vertex for maxers) represents a pixel) and shoot rays through each point towards the scene. If it hits, it returns the hit position, primitive number (polygon number) and barycentric coordinates of the position on that primitive. With that being done, the hardest part is already over. The rest is just retrieving properties of the geometry like normals, vertex colors and UVs and shooting rays from different positions in different directions.
Next step, adding point lights: calculating simple shading using the dot product of the surface normal and light direction and adding it all together with vertex colors. Still looks a bit dull, so adding shadows by tracing a ray from the surface to light. If it hits something on the way, the pixel is in shadow and we return black. AO is then basically the same thing, just shooting random rays in a hemisphere and averaging the hits.

AO and point lights

So, next step is adding area lights with color. Same thing as point lights, just instead of firing a ray in direction of one point we fire multiple rays and vary the target

AO and point lights

After that, we basically have everything we need to implement simple Brute force Global illumination and Reflections.
For GI, I basically did all of the above just instead of shooting rays from a camera, I shoot several rays in hemispheric direction from the surface of whatever point on the surface I have hit with my camera ray. Reflections are again the same thing, just a variation of the steps above. Instead of shooting rays from a camera position, I shoot rays in the reflected view direction starting from the position on the geometry I hit.

So, that’s actually all there is for a (very) simple raytrace renderer in Houdini. Some optimizations for the secondary rays (not rendering reflections for all GI rays, clamping GI ray intensity, etc) helped keeping the render times low.

Preview Rendering