Saturday, 1 October 2022

Extracting camera space procedural geometry edge in houdini using dot product (.hip file attached)

 




1. Object merge your geometry and camera inside a geometry node.  make sure both transform are set to Into This Object.




2. use an attribute wrangle to read the position data

    like so:

            

v@camN = point(1, "P", 0) - @P; // calculating the ray from camera to the point

v@objN = @N;



 

3. take an attribute vop and connect it below the wrangle. inside this we will do dot product to find the edge of the geometry in camera space. 

    here first we read the objN and camN position attributs. then multiply objN with a float to make the effect more prominent. then plug both camN and multiplied objN into a dot product node. we use dot product to find if the ray from camera and the normal on the particular point are in right angle.

if they are in right angle, dot product will produce a value of zero. above 90 degrees it will produce -ve value and below 90 degrees it will produce +ve values. 

4. so, then we plug this value into a ramp and set the ramp type to spline. (you can use RGB ramp as well). 

5. and finally we connect the ramp output to Cd. then after we adjust the ramp a bit we should be able to see the edge appear on the geometry.




So if everything has been done right, we should be able to see the edge and make it thicker or change its position using the ramp and N_Multiply.



example file:  https://learnhoudini.gumroad.com/l/houdiniproceduraledgedetection


No comments:

Post a Comment