Skip to main content

Drawing with a wacom in Houdini

It's been ages since I posted last, I haven't been doing much Houdini at home in the last few years. I got an Indie licence to make some content for other things I am doing, so I will be doing more in Houdini now -- and whenever I find something that is a bit interesting or might be useful for someone I will try to post it.

Recently I was looking for a solution for drawing curves with a wacom, and retain the pressure data  and curves so that it can be procedurally animated after it has been drawn. I was trying to find ways to recreate/trace consteallation drawings from the 1661 book Uranometria (http://skytonight.org/Bayer-1661)


The goal was to get clean curves that could be procedurally animated after they had been drawn, and also to get an image that is not obscured by the stars that you can see in the above snap.

I was trying to use inkscape, which is great for drawing with but I had no idea how I could get any data out of it, and it seemed to make solid shapes instead of curves (when trying to use a tapering pen)

Houdini has the 'stroke' SOP which works well with the wacom, capturing pressure data and working out of the box. However on my machine I was having a problem where any hiccups in performance would also cause an interruption in the data that was captured ... as you can see in this screenshot, drawing a fast circle sometimes results in large gaps in the shape:


After some googling around for some other ways to get good data out of a wacom, I found that Qt supports tablets, and I could use the Python Panel in Hoduini in order to use Qt to draw with the wacom -- so I ended up making a panel that can be drawn in. It seems that regardless of Houdini's performance, Qt will still capture all of the data from the wacom, and any loss of performance will only affect the display and not the data....

In the python panel, a circle drawn with roughly the same speed as I did in the stroke SOP above, I end up with much more consistent data, even if something cooks and Houdini stutters around a bit, the input data doesn't seem to be interrupted.


The parts are:
 - The python panel, which has some buttons and sliders for controls and a drawing widget that captures and displays the stokes.
 - a SOPs node that takes a string of all of the stroke data.
 - a setting on the panel for which SOP is being worked on.

When a sop is selected from the drop down on the panel, the data is loaded from a string parm on the SOP, and can be added to. If a SOP is selected in the network view, the panel will change to show the curves from that SOP.

The units in the panel are pixels, so it is also pixels when it is read into SOPs. Zero is at the cross in the centre of the python panel.

A background image can be loaded into the panel, which is always centred and 1:1 for pixel size. The path to the image is saved on a parm in the SOP, so I can have different reference images for different nodes (and teh path to the reference image is saved)

The panel also has panning and zooming, which SEEMS like a simple feature but it was a bit of a pain :)

There are a few other features to make workflow easier too, like a "duplicate" button, which just duplicates the current SOP and starts editing it. The "dup and clear" button is the same as pressing duplicate and clear and makes the workflow quite a bit faster.

There are a few things that the panel does to keep the stroke that I am drawing updating quickly, it:
 - only shows that last 10 strokes when you are drawing, as with 100s of strokes the widget gets quite slow to update.
 - only sends data from the widget to the SOP when the pen is lifted from the tablet, as generally I don't look at the scene view when drawing.

For the Uranometria drawings, there are some specific things in them that I wanted to be able to trace easily. The first is smooth outlines or very straight lines -- I wanted a way to define a curve using breakpoints instead of trying to freehand it:


There is a setting on the SOP called "Curves as Breakpoints", which will interpret each curve (just a tap with the wacom) as a breakpoint in a curve. It adds handles to ensure the created curve passes through the breakpoints, and converts it to a bezier curve. Super useful for the very smooth lines! The only downside to this is that you have to have a node for every curve you want to draw -- which is why the "dup and clear" button is useful... as it makes it a lot quicker to start a new curve.

The other feature that is common in the Uranometria drawings is very regular lines for the shading. I added a setting to the SOP node to add new lines at regular spacing between all drawn lines:


Making it much quicker to add a lot of the shading detail. The SOP also adds a bit of noise (had to be some in there somewhere)

In the drawings the outlines are very often just made from regulary spaced dots, so the duplication tool is useful for those too!


The problem with this mode is also that you have to have a node for every section of hatching to create.

I have tried a few practice drawings to test out the tools, and I do end up with way too many nodes:


Oh also. .... the 'undo' button, doesn't really undo, but just deletes the last drawn line. Also there is no way to edit what has already been drawn -- so it is good to have the drawing split into many nodes.

It would probably be better to have all of the curves on one node, but I also don't want a massive multi-parm on one node..... we will see!

Next I am going to try getting the procedural animation working, to make sure there is nothing else I need in the tools first.



Here is a timelapse of tracing one of the more simple constellations, which shows the curve tool and the duplication tool:



The python panel and the OTL can be downloaded here

Beware that these files were made with an Indie licence!

Comments

  1. Hey Sam,

    This seams like a really usefull and fun tool! I would like to use it, but unfortunately it is not working correctly with the current H Version for me(18.0.460).
    I have the python panel "Tablet Draw" and the SOP draw strokes in place. but no strokes get generated by drawing in the panel ( not with mouse and not with stylus). I dont see them in the panel and they dont get created in sop context. The right SOP node is connected in the little drop down menu. Do you have any idea what might be wrong?

    Cheers and Thanks alot
    Philipp

    ReplyDelete

Post a Comment

Popular posts from this blog

Cloth tear geometry and shading detail

Been adding geo detail to the torn cloth and shading the additional geo. Shading sure is fun! :) Thickness added to the cloth geo Extrude sides are extruded out again  The second extrusion is done twice, once for the U direction, and once for the V direction. Polyframe is used to get the UV gradient to extrude along, vopsops are used to move the extrudeFront points after extrusion as you can't control the extrusion per point with just a polyExtrude node... The extrusion is done twice so that the two different surfaces represent the opposing thread directions. since my geometry (and therefore tears) are in line with the U and V direction, the effect is not obvious in this case. The extra geo after shading The .hip file below has a slightly newer shader than in the video and the image above, I removed the part of the shader that created the soft ramp for the alpha edge and used just the thread noise instead; it now looks more like: Slightly newer shader than...

Wire to RBD feedback in DOPs

Normally if a wire is constrained to an RBD, the rbd isn't affected by the wire at all. Which is annoying ... but I had an idea to get it to work. the wire solver can store the internal forces on the geometry. In DOPs I made a point force, the position is set to the position of the constraint and the force is the wire's internal (linear) force. I have put a sopnet in the dopnet to get the wire and the constrained point so I can reference them in the point force. It could be simpler with a python expression to get the position and force directly without going through the sopnet, but this is just a little test... For multiple attachment points, I think a copy data node could be used to copy the point force data for each constrained point ... hip file here Wire to RBD feedback forces from Sam Hancock on Vimeo .

Worm locomotion with FEM

I have always wanted to do a dynamic locomotion setup, I have tried in the past with wire and sop solver with .... interesting results ;) With FEM in Houdini 13, the rest attribute is stored on vertices which allows a tetra to change its rest state independently of the surrounding tetras. With this, parts can be expanded and shrunk to get a muscle type action. I have started with a worm since it is quite simple, the contractions and expansions move back along the worm in a wave, opposing the travel direction. It took quite a bit of tweaking to get him moving at all. One major element of a real worm's action that's missing is the little hairs that grip the ground. I couldn't find a way to change the friction per point so I have gone a bit hacky and multed down v wherever I didn't want the worm to move. I would love to hear if there is a per point friction control! Here is the video Houdini 13 FEM Worm locomotion from Sam Hancock on Vimeo . ...and the .hip is...