Halloween Costume ideas 2015

SVERCHOK / Parametric Snippets 1

As I started get deeper into parametric modeling using Sverchok, the more I realized how powerful this workflow could be, when fully integrated into Blender environment and work with the rest of Blender.

The Sverchok Add-On is updated daily, so we may see new nodes and improved version of Sverchok. I tried to keep it up to date.

THE SVERCHOK SCRIPT NODE
There are already some awesome tricks like the new SCRIPT NODE (thanks ZEFFII) that is capable of doing lots of unusual Python tricks inside Sverchok.

I tried experimenting with it using simple Python Script node in Sverchok to randomize Light Colors and Light Intensity using node inside Sverchok.

It requires scripting, but by "nodifying" and containing useful Python script inside a portable node, and having ability to control many objects using simple parameter is great.

  • INPUT
  • PROCEDURES
  • OUTPUT
It is just quite fascinating when LOW LEVEL Data can actually modify the HIGH LEVEL Object Data, back and forth.







POST MODIFIER DATA
In latest Sverchok, we also have the option to read the low level data, POST the Modifiers. This is really cool. Just like Particle System "Use Modifier Stack", the Sverchok preview is shown after all the Modifiers applied to the Mesh, but it is still alive. This is even more procedural.

Let say, Dynamic Paint to scatter some Particles, which then with Sverchok we can control the details of the copies. This still has limitation of course, because it can get heavy. Sverchok is like working in Edit Mode, and unlike Particle Instancing, what we are working inside Sverchok is something to be baked out as Geometry or Mesh at later stage.


MORE POWERFUL THAN ONE THINK
The MAIN PURPOSE and focus of Sverchok is for Parametric Modeling as Nikita has stated. It is the right way to remain focus on development to keep it maintainable by Sverchok developers. I agree with this.

However looking many years ahead, I can see that this is going to be bigger than it is today, when continue being developed. As Work In Progress (WIP), Sverchok Add-On is something that can help general CG artists to understand Math, Vectors, Matrix, parametric creation and so on.

In fact, at current development stage, with limited nodes a more technical users can carefully study each node properly and see them working in context. This is very important. Imagine if the collection of nodes grow like Houdini, over hundreds nodes, then thing can started to get very complicated.

There are already a lot of gems and useful information can be found at Sverchok original thread at Blender Artist Forum:
http://blenderartists.org/forum/showthread.php?272679-Addon-WIP-Sverchok-parametric-nodes-for-architects

At the moment, that forum thread above is the best place to ask questions and maybe request a feature. Sverchok development team is amazing.

USEFUL PARAMETRIC SNIPPETS SERIES

Now, with this "Parametric Snippets" blog series, I will be posting some random finding, maybe simple snapshots of Sverchok node tree that is useful and can be used to build a more complex setup.

Nikita also posted lots of Sverchok snippets
https://plus.google.com/103738725871920806709/posts/Xz5v7TrDHeD

Remember that often by connecting many SIMPLE node tree, users can create COMPLEXITY that normally is very hard to create using manual traditional 3D modeling method.

TRICK: Procedural Animation

It is already possible to create Procedural Animation that can be rendered using Sverchok. I can confirm with that.

There are still few steps involved like:
1. FORCING ANIMATION FOR SVERCHOK
Activating Sverchok animation to update every frame changes, using below Python script below (was written by ZEFFII also, thanks man!)
import bpy

svAnim = bpy.data.node_groups['NodeTree'] 


def my_handler(scene):
    svAnim.update()

bpy.app.handlers.frame_change_pre.append(my_handler)

2. BAKE ALL
Bake is important to enable rendering. Luckily, there is already the Bakery node that can update and output an actual renderable mesh. This data is often destroyed and rebuilt whenever we make changes in Sverchok. However, still useful and make Sverchok Preview renderable.

UPDATE 20140428:
Displaying Real Time Animation is now part of Sverchok, no longer necessary to force it using Python script above.

VECTOR MATH NODE

Vector Math node has lots of useful Math operations for Vectors, such as Cross Product. Below is the basic how to visualize a Cross Product.



TRICK: Outward Vertex Normal => Adaptive Polygons

I learned this trick from Houdini TD Spencer Lueder not long ago. To get Vector of Points that goes outward, just subtract vector to itself.

In Sverchok, just use Vector Math to add or subtract to get outward vector.


Which allows you to do something like below.



If you want it to work for Center of Polygons, use Center Polygons Sverchok node.



Alex said that instead of having Vector In (0,0,1), we use something like this instead: 1e-6 (0.000001). Small number that is almost zero.

Anyways, above we can see how WEIGHT made by node ca be used to pull objects to face certain direction specified.

Of course, there is also the uber powerful Adaptive Polygons node that you can use it when required. It is more convenient, very easy to adapt OBJECT into a TEMPLATE.



Mentioned by Nikitron that we can also use VECTOR NORMAL node.

TRICK: List via Formula

I found this from one of example by Nikita.

We could type in our own List of Numbers into the Formula node. As we know it already, there are two types of Formula nodes: Formula and Formula2.

Formula

Formula2
One of the main reason I like Sverchok is its way to handle LIST DATA STRUCTURE. Very similar to Python, easy to understand and we are given all kind of List nodes that does some interesting modifications to INPUT list and give us OUTPUT list that we really want.

Reversing List example:

We look at data, check and compare to understand why certain List does not give us the output we want. For example below, we have Random Vector node that gives output ready to be used as Vertices, while the Formula2 node, needs List Join to give data output that is better suited for Vertices.


Reversing List can change the output Polygon Face normal.

Try this yourself with all kind LIST nodes in Sverchok to better understand LIST in Sverchok and how it handles multiple data. It is very important once we start dealing with FRAME DATA for Animation Offset, Animation Variations.

NEW TRICK 20140429: Randomize Copy Instance

This is actually something that I requested from Sverchok team around 3 months ago. This is quite a nice surprise and finally we have List Item. Thanks to Linus!

LIST ITEM is a powerful way to quickly create variations of object.

In this example, you see that we have something that resemble Particle Instancing (random object in group). HOWEVER, keep in mind that those duplicate copies are NOT instances, they are actually a single object that can be combined together. Similar to SOP (Surface Operator) in Houdini, or like Blender Edit Mode, if you are adding objects into the Mesh. They are all can ended up being a single mesh or multiple objects if you use LIST JOIN.



There are few things, such as: UV, Materials, etc are not yet implemented. Like I said, it's not instancing.

TRICK: Adaptive Edges

New node from Linus. This replace every edges with another edges. You can supply the replacement edges by drawing it parametrically or just draw Grease Pencil.

Sometimes this node flip, but I guess there is a way around it.

TRICK: List Match

List Match node is an interesting node. I need to look at Grasshopper PDF documentation (Sverchok is originally inspired by Grasshopper for Rhino).

Say, I have 2 Lines DATA, and I want to "match" them.


TOP LINES have 9 Vertices
BOTTOM LINES have 2 Vertices.

Let see what List Match can actually do:


X-Ref

Cycle

Short

Repeat

NOTE:
Watch out, don't forget to do "Matrix Apply" when you use Object In. That is to ensure that the position of our data is already Applied, not at the original position (remember sometimes we do need to Apply Position, Rotation, Scale to confirm the current transform in World Space)

And of course, List Match can give us the MANDALA.
http://en.wikipedia.org/wiki/Mandala

Everything comes from a single dot.
Everything is connected to each other.
A single entity does not belong to itself, but part of the universe.
You see List Match is really quite powerful.


Not necessarily for random abstract looking design,



TRICK: Visualizing Index (of Vertices)

In the past, before Blender 2.7, we are able to display INDEX number of Vertex, Edges, Face of Polygon Mesh in Edit Mode, by turning it on using:
bpy.app.debug = True

You probably want to consider using this script by Bart to visualize the indices.
http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Index_Visualiser

However, in Sverchok we can use the INDX Viewer Draw node.


For now, it seems to display only Index of Vertices. I am hoping that it will one day display ANY kind of values, including Vector, Weight, and other type of data that represent values. A bit like ICE in Softimage. It can be very cluttered, but good to have.

NEW TRICK: Kdtree and Convex Hull

Kdtree node deals with Point Cloud. It is quite powerful as it can find NEAREST points by comparing points. Think Ambient Occlusion or Raycast. Kind of like one mesh can SEE or aware of other mesh. Imagine glass ball with electricity inside and you are touching the of the glass. Kind of like that.

Convex Hull node is useful to create Mesh output based on Point Cloud.


Kdtree is a very advanced node, and I think it has lots of usages.





Use the Force?


TRICK: Line with Noise
Sometimes everything can be a bit more interesting, natural and organic, when we applied Noise.


TRICK: List Mask for Polygon Face Masking

I found out about this by accident.


List Mask can be used to mask data. But it is most obvious when we are masking Polygon Faces.

It works with LIST with ZERO and ONE (TRUE or FALSE).




With something like this, you can quickly create interesting geometry pattern.

SCRIPT NODE: Compare True False

I wrote this Python script for Script Node that "compare" between 2 list and return TRUE or FALSE based on the list. This could be useful for List Masking. Maybe this is possible to re-create using Sverchok node, but often it is easier to write down as code.

I am sure below script can be simpler or more efficient, but it will work.

HOW TO USE:
Just provide 2 different list, the order matters. It will result in TRUE or FALSE (Boolean Binary Code) by comparing the two list, if there are 2 matching number, return TRUE, and if not matching number, return FALSE.

SCRIPT NODE: "COMPARE"

def sv_main(dataA=[], dataB=[]):

    # in boilerplate - make your own sockets
    in_sockets = [
        ['s', 'In list A',  dataA],
        ['s', 'In list B',  dataB]
    ]

    # import libraries if you need.
    
    # your code here
    out = []
    
    for i in dataB:
        if (i in dataA):
            out.append(1)
        else:
            out.append(0)
    
    out = [out]

    # out boilerplate - set your own sockets packet
    out_sockets = [
        ['s', 'Out', out]
    ]

    return in_sockets, out_sockets





SCRIPT NODE: Random Range with Min and Max
def sv_main(min=0.0, max=10.0, count=1, seed=0.0):

    # in boilerplate - make your own sockets
    in_sockets = [
        ['s', 'Min',  min],
        ['s', 'Max',  max],
        ['s', 'Count',  count],
        ['s', 'Seed',  seed],
    ]

    # import libraries if you need.
    from util import sv_zip
    import random

    # your code here
    random.seed(seed)

    myList = []    
    
    for i in range(count):
        #myList.append(random.randrange(min,max))
        #myList.append(random.random())
        randVal = (max-min) * random.random() + min
        
        myList.append(randVal)
    
    print(myList)
    out = myList

    # out boilerplate - set your own sockets packet
    out_sockets = [
        ['s', 'Out', out]
    ]

    return in_sockets, out_sockets


NOTE: We might end up with some stray vertices that we need to clean up later. No big deal. Just use Blender Edit Mode to clean it up.

UPDATE 20140428: Nikitron said we actually have Delete Loose node to clean up stray vertices and edges, so please use that!



TRICKS: Binary Code, Random True or False
Creating Number Pattern is a very interesting area. You can study or source some Math formula that does it for you.

A very cool example is the Script Node for Fibonacci Phyllotaxis (by ZEFFII) to generate numbers that spit out beautiful design:

Now, for something simper, if you want to generate random 0 and 1 number pattern, you can use something like below:


Random gives a random floating values between 0 and 1, the Float2Int node will use round() function to round the number, and you can end up with number 0 and 1.

Below is an example of usage of "BINARY SUZANNE"



Suzanne is made up of 500 Faces, and randomly deleting (masking) Faces using Random 0 and 1, we end up with 250 Faces left. Something to remember. 50-50 chances.

Remember that you can also bring your own Data using Text In node (CSV, etc). Unlimited possibility!

TO BE CONTINUED...
That's all of the Sverchok Parametric Snippets of Tricks I have for now. Hope they are useful. Will add more over time.

Post a Comment

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget