Raytrace Shadows using VEX
The main motive of this experiment was to extract information from the lights and use it for several applications like simulations, basic OpenGL previews, procedural effects etc to name a few.
In this node graph setup I object merged the ground geometry and character. To extract the location of the lights I channel referenced the position to the transform SOP attached to an add SOP as a placeholder.
I have used 3 lights for a practical example.
In this code, I have begun by collecting all the required information. In this case, we need the position of the ground to use as a base geometry and the position of the light. I have plugged the light into the second input and stored it as pos2.
The next step is to use the intersect function, as described in the Houdini Help, "This function computes the intersection of the specified ray with the geometry". Before we proceed to use this function we need to calculate the ray direction. This can be done by finding the difference between the light and the ground as represented in the image below.
Once we have all the required information we can continue to use the intersect function. As stated in the help the formula is:
int intersect(int input, vector orig, vector dir, vector p&, float u&, float v&)
After using the previous code on all the lights we can combine them by adding them together.
I took my test further by trying to use this information in pops. I played around with the normals and used the information from the lights as a sort of masking data. I used normals only for a visual reference and further fed that into the velocity data. A basic pop setup helped me create an interesting magical effect based on the shadows.