Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

August 10, 2014

Sverchok, the basics

What is Sverchok?

The quick answer: Geometry Nodes for Blender.
The elaborate answer: An open-source and Free visual node based coding environment aimed at creating geometry. It is written in Python and uses Blender's custom PyNodes API for the user interface. Currently (August 2014) Sverchok has about 100 Nodes, and some nodes have 10 or more unique behaviours. It is hosted on GitHub


I'm going to assume you know how to enable the add-on, how to add Nodes to the node view, and how to connect them together. Team Sverchok compiled illustrated documentation for every available Sverchok-node, some references are more extensive when the node performs complex operations.

How to use Sverchok

The following examples will introduce you to some trigonometry and vector math. I'm going to start with the idea of a circle, and build from there. If you see small/minimized Nodes, they are usually Math nodes - minimizing them keeps things less cluttered.

sverchok basic circle

The first example shows a common problem; first and last vertex share the same location in space, because the last vertex is created at 360 degrees which is the same as 0 degrees. Same as sin(0) == sin(2*PI).

download file

download file
To avoid the double vertex we limit the rotation to 360-(360/n). This subtracts one segment from the total rotation. This already allows you to adjust n verts and the amplitude, but it might be time to add some edges to connect the vertices.

connecting vertices

download file
In this scenario, the code shown in the text field of Formula node will output a list of n items. Often we want the number of vertex lists to match the number of edge lists, but here you see the verts count in the viz node is 1 and the edges count is 5. The solution is to wrap the edge-list before it hits the viz node, this is done with the Join List node.

download file
Here you see how to wrap a list and also how to use the BGL debug node (this node might change in the future, but the essence should stay the same)


Creating edges with formula node relies on some python knowledge, formula node allows you to write list comprehensions, this might put some people off -- it shouldn't. There are alternatives to generating Edge lists, the UV Connection node will do it in one go.

download file
With UV connection node replacing the Formula Node for edge creation, you get a sense that some commonly performed operations can be abstracted into their own Node. Concepts like creating edges, edge loops, and even polygons from a list of vertices come up very often and deserve specialized Nodes. In this file, if you tick the Polygon button, you will see the UV connection node creates a single polygon from the edge list. Internally it makes a fan of triangles or more complex arrangement of triangles to display the polygon.

But ..5 verts doesn't make a circle

Nope, but even 1 million verts only approximates a Circle. I used 5 verts to this point to show that in circular trigonometry you want to pay attention to first and last vertex and the potential of doubles in space. My tip is to keep vertex counts low as often as possible so you can see easily if your numbers correspond to what's being created, or if there is some overlap.

vertex count == 22

Circle Node

Because Circle geometry is something we use often, it also has a dedicated node. Generators -> Circle .

Shows nicely how many nodes are involved in something as simple as a Circle. Similar nodes exist for Plane (grid), UV Sphere, Cube, Cylinder, even line.

Circle Node + Vectorization

This gives opportunity to show what we can do with an atomic element like the Circle. We can feed it multiple values for the number of verts, and out the other side will come a nested list of vertices that represent several circles.

download file
You'll notice that feeding the No. Vertices socket of the Circle node an Int Range node, with settings for Start, Step and Count produces a multitude of circles with the same radius but different vertex counts. The Circle node takes care of the edge or polygon definition list for every outputted circle.

download file
We can also provide a set of different radii and a variety of vertex counts, and you will get n different circles with each a different radius. n=4 in this case

No comments:

Post a Comment

Please use Blender.StackExchange.com for python scripting questions unrelated to this post.