Friday, 6 September 2024

Generating Outlines in Houdini using Backface Culling

    I've been wanting to learn more about generating outlines and creating NPR styles within Houdini. I found video showing the backface culling method to generate sweep mesh lines. (Youtube video can be found here). Here are all of my notes detailing the process. 

Setup

This technique requires you to make a camera for this to work. You can create a camera node in the node editor or in the top bar. Select the lock next to the viewport to lock the view to that camera and set up the camera to view your scene how you like it. 




Any piece of geometry should work with this, so for this test I will be using the Houdini rubber toy test geometry available. 

 

Viewport with the Rubber Toy Geo

 

The Node Window at the Object Level

The Node Tree

Once you have your camera and geometry you wish to apply an outline to, select your object and go down into the geometry level.
The Geometry Level

Delete Node

The first node you'll need is a delete node. Here we are going to delete all the polygons that we do not see from the camera's view. In the parameters window, Enable the normal tab, then in the "Backface from" text entry, put “/obj/”NAME OF CAMERA”/ .

Parameters Window for the Delete Node

 

From the camera view it looks as if nothing has changed

 

But from the back we can see that polygons have been deleted

Group Create Node

    Next we have the Outline Node, rename it to a name you will remember because this will be used later (I named it "Outline"). In the Group Name write "$OS". This is our first instance of Houdini's scripting language called VEX. "$OS" means "Operator String", which means that it will take the name of whatever the node is called and it will be used for the group name. This is automatically updated whenever you change the name of the node. Also ensure the Group Type is changed to "Edges".
    For the tabs, uncheck the "Base Group" box and check on the "Include by Edges" enable box.
Make sure you check "unshared edges" on as well.

Parameters Window for Create Group Node


    This node is setting up the group for where we are generating outlines from. It is important that we have "unshared edges" turned on. The group only captures edges only if the edge "has one primitive adjacent to it." (Houdini Doc). So since we've deleted the polygons behind the object, we have edges that only have one polygon next to it, and this node collects those edges.
The orange lines show the selected lines included within the group




Convert Line Node

    The Convert Line node converts edges into line segments. Choose the group "Outline" we've created to create lines from those specific edges. Keep remove unused points on to keep only connected points. Compute length should be set to "restlength", which calculates the perimeter of the lines.
Only the Lines remain

Polypath Node

    This node helps to clean up the line segments. You don't have to change any of the default options, it will reduce duplicate edges that overlap each other.

Resample Node

    We can use the Resample node to continue cleaning up the line segment. It gets rid of unnecessary points on the line segment while still keeping the original shape.

Orientation along Curve Node

    This calculates the orientation of the curves based on the tangents. This should help use when we use the Sweep Curve Node

Sweep Node

        The sweep node creates the actual geometry that will be seen for the outline. If the geometry was textured it will most likely take the colors from the original textures
Sweep Node


Color Node

    We can add a color node to change the overall color of the lines. At the moment, I've found that it only adds to the existing color, and doesn't overrides it. I'll see later how to fix this.
Using a dark Blue for the color


Merge Node

    Now that we're finished generating the lines, we can merge it on top of our original geometry.
The Final Output

 

The node tree

 

Final Thoughts

Overall its good start but the outlines look a bit crunchy, before using the sweep mesh the lines looked nice, but after the sweep node it doesn’t look that great. Also when the camera or object moves some of the lines flicker in and out. Will have to look into this more. 



No comments:

Post a Comment

Python in UE5

 TO start, go into the unreal plugins, look for python. Turn on Python Editor Script Plugin. Go into settings and look for python, make sure...