Halloween Costume ideas 2015

SVERCHOK / Parametric Snippet 8

Suzanne possesed by Eval Knievel of Sverchok.

Here we go again, more basics yet useful Sverchok snippets to brighten your day. Plenty of them!

The more one explores Sverchok, the more one discovers interestingness of Sverchok Add-On and Python, and as well many other related areas that also reveal Blender capability and also procedural, parametric, computational concepts.

We can think of Sverchok as a new language inside Blender for modeling, animation and other things.

Advance Grasshopper Plugin
For example, this video was pointed by Zeffii the other day, it is a video lecture on Grasshopper plugin for Rhino video, displaying a node called "Galapagos" explaining "Genetic Algorithms":
https://www.youtube.com/watch?v=4QqkxT1XeNw

That kind of setup is really impressive. A kind of thing that I would like to see in Blender. The setup might get complex, but first the thinking and understanding of the concepts is truly invaluable.

Sometimes it is not how complex or complicated of setup you can build, but how deep one's understanding of small things that allow him/her to continue to advance.

And of course, you cannot do it alone. In fact, this kind of computational thinking is pretty collaborative. You think, it is just you and the computer, but in fact, it is many brains and the computer. I owe a lot from the helps of Sverchok Developers, with their examples in code and node.

RE: Sverchok Setup

Installation of Sverchok should be much simpler now and should NOT give you any error message. Many asked me same questions, so I will re-write it again.

Download the latest zip from Github. Click on "Download Zip" button.
https://github.com/nortikin/sverchok

After Sverchok installed, inside Node-Tree panel, on the right side, you should get this panel that allows you to check if there is a new version to download.

Now, from my experience, sometimes this works, sometimes does not. When it works, you feel awesome. Sometimes it says "cannot extract". In such case, I would just reinstall Sverchok Add-On by removing and adding the latest Zip. No sweat.


Nikita made new tutorial and provide some more serious examples.
http://nikitron.cc.ua/Sverchok_man_09.html

What's new in Sverchok? By the time I am writing this, there are already some more new things. Whether improvement in speed, some more Formula Math, or some more nodes. So let's look at some things.

SVERCHOK 3D VIEW PROP NODE

A simple node that gives you quick access to tweak 3D View while working inside the node-tree. This node allows you to:
- View Render Only
- Show/Hide Grid in X,Y,Z
- Change grid color
- Gradient Color Option
- Switch Blender orbit navigation between Turntable or Trackball



FUNCTION WAVE RELOADED


  • Range Min Max
  • Some Math Nodes


How many times have I touched on SINE WAVE? Probably too many times already, but Sine is simple and it explains many concept.

I will touch on TRIANGLE WAVE today. Triangle wave is not as simple to create, we need a specialty function to get this wave. With Sine wave, we just plug it in into Math Formula node.



Above will give a static Sine wave. If you want a movement, you just "push" the wave in time, just by adding offset values, normally the input is Frame number.

This Triangle wave also create pattern that looks like a Zig Zag, or Ping Pong pattern that can be useful for animation when we want it to go back and forth repeatedly but in a linear fashion (no acceleration or change in speed). While Sine wave does this smooth pattern that goes between -1 and 1, Triangle wave is linear, straight line goes from -1 to 1 repeatedly in a constant speed.

Some useful links I found when researching about triangle wave:
http://en.m.wikipedia.org/wiki/Triangle_wave
http://stackoverflow.com/questions/1073606/is-there-a-one-line-function-that-generates-a-triangle-wave

That one link from Stack Overflow gives the formula I needed, something like this:

min = 0
max = any maximum number (this is the Amplitude)
i = number of iteration (a growing number)

Assuming min is 0 and number grows:
x = max - abs ( i % (2 * max) - max )

Let's translate the formula above into Node Tree. You can use Formula2 node, however, this time, I want everything to be nodes and noodles.

Start from the deepest nest, which is ( 2 * max ). Then continue on and see the correlation of the function, break and convert each part into node tree.




A better setup would be to use Range Float node instead of relying on Line node. Range float allows you to have more control over the "length" of the wave while adjusting the resolution details of the wave. It seems like a small feat, but important.



Triangle Wave = Ping Pong animation
Do you remember how we can use MODULO function to get a Looping kind of animation? With Triangle wave, we actually get a Ping Pong kind of animation.

The setup below will show you clearly what is really happening. Supposed I draw a stroke using Grease Pencil like below. And I want a sphere to travel from the start point on the left to end point on the right. Below is one way we would set it up.

We first set the trajectory of Sphere along the Grease Pencil curve. How much details of interpolation we want it. Then using List Item, we specify exactly where and when the Sphere should be placed.


Above, I am manually sliding the sphere along curve. Using function, such as Linear Curve, Sine wave curve, or Triangle Wave, we will be able to control the motion.



There is a bit more to explore here, but I leave it there. Just to get the basic idea.

I think it can be further simplified. With our setup, we end up with triangle that does not really go between -1 and 1. I prefer it to go between that range that we can remap.

NOTE: Technical note, usually with a setup that requires us to resample the curve (Grease Pencil), Vector Interpolation needs to do the hard work to process Grease Pencil curve. Even such a simple curve above is nearly 4000 points. Thus, you get a slow frame rate during animation. This is not so much of issue since we can always bake or cache the mesh output. However, I suggest that you ALWAYS Simplify the Grease Pencil or reduce the counts before you brought it into Sverchok. Did you know that originally "animation" was not planned in Sverchok? There you go, we are lucky to have animation happening!

Random Spawning inside Box Volume

I have some interest with Unreal Engine 4 recently. And this video is kind of interesting:
http://youtu.be/9-7SmkasS_A

In relation to Sverchok, from the video above, we learn to be spawn points inside Box Volume.



Inside Sverchok, we cannot really "scatter" points into surface or volume. However, we know that Blender Particles has that capability right? And we can use that for now. Below is Particle Volume and KDtree Edges node working hard making all those edges.


Vector Interpolation can also be used to kind of randomly scatter points, in between points.


In a simpler scenario below, it is more clear.

Between 2 Points in 3D space, scatter some random points of specific count.


For every point between 2 points, plant some Lines. We get something that looks like a barcode.



Do you know that in recent Sverchok, we have the ability to use Vectorized Input for Lines? Which means you can now have array of lines with different number of vertices?




This means array of lines, where each lines has different stack is possible. That would make layout for city building a lot easier now, right?

Procedural Fence and Bridge should be easier to create this way, created under 30 nodes.




I tend to think in term of Lines, which could be useful too. That way, we have the Outlines and kind of have the relationship of each parts.

Then what we do is simply replacing each dummy Lines with the real part. Each part can also be made procedurally. Or it does not need to. You simply have premade Modular Part that you have modeled.

Thus we create a modular and reuseable system.

Building Complexity with Modular Parts

When I just started, I always think of building everything at once. While it is possible, but also not efficient.

Just like writing a novel, we should probably start by creating the Outline or the Cage, then we started to build on that.

So for something we build procedurally and parametrically, we should also think that way. We can prototype using dummy object. See how we can break parts.

1. TOWER BUILDING: Roof Top Part, Bottom Facade Part, and in between parts.
2. SNAKE: Head part, Body Segments, Tail part
3. BIPED CHARACTER: Head, Body, Arms, Legs
4. INSECT CHARACTER: Antenna, Head, Body, Legs, Wings

I made this Procedural Centipede the other day at the Library. This is not that different from Procedural Dominos, except that here, we have segmented part that makes the body of Centipede. And with centipede, each part have Left and Right leg. Sometimes, each segment have 4 legs. Each part should be replaceable.

Maybe the segment have some details, and perhaps closer to the head and tail, the segment is getting smaller. And maybe the Head and Tail part needs to be replaced with a more detailed version. That is all should be carefully thought before we start creating this.

Perhaps the Spine will change and can be animated. Should we just start with a straight spine? Perhaps each of the spine will become Blender Armature Bone to drive hundreds of Centipede.

Yes, that is also something to be considered beforehand. This is when your brain start to think procedurally or even more parametrically.

While some well done node-based setup allow users to create complex things almost without thinking (which can be pretty embarrassing) however, in most real case scenario, good artists must learn to understand the concept. Not always having to re-invent the wheel, but be creative with solutions.

Below is a good quote from "Think Python" online book.


Procedural Centipede WIP





You might notice that I am using some new Curve Generator node in Sverchok, they are:
  • Basic 3 Pt Arc
  • Basic Spline

MEET EVAL KNIEVEL NODE

To close our Snippet article today, I will show you the new Eval Knievel node by Zeffii.

Documentation:
https://gist.github.com/zeffii/527bd6537357629e173f

This node is like a simpler version of Scripted Node, basically a single liner node to insert Python magic that allow you to possess some parts of Blender outside of Sverchok Node-Tree.

It can read/listen INPUT from OUTSIDE SOURCE and send OUTPUT to OUTSIDE SOURCE. This node is pretty eval, I supposed!

SET VALUE
= {x}

GET VALUE
{x} =

The code is running backward:

Example:
print({x}[0]); blah = {x};


To possess Cycles Material using Eval Knievel

import colorsys; data.materials['Material'].node_tree.nodes['Emission'].inputs['Color'].default_value = colorsys.hsv_to_rgb (*{x}[:3]) + ({x}[3],)

import colorsys; data.materials['Material'].node_tree.nodes['Emission'].inputs['Color'].default_value = colorsys.hsv_to_rgb ({x}[0], {x}[1], {x}[2]) + ({x}[3],)

Above line of code takes INPUT X and pass it to Cycles Material Color, in HSV wheel.


Suzanne Possessing the Sverchok Ghost by Eval Knievel
Suzanne Transform Matrix => Drive Matrix of Sverchok Object



3D Cursor being possesed by Eval Knievel
Random Position value => drive 3D Cursor




Eval Knieval works only for a single object, not for array of objects. It is definitely possible to make it works with many objects.

If I am not wrong, the node will evolve and enable you to call Python Function from Text Editor. So, in the way it is like quick Drivers and Python Expression.

So for this Eval Knievel node, you need to know a bit more about Python and Blender Python. Use it wisely and carefully.


http://lucumr.pocoo.org/2011/2/1/exec-in-python/
http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
http://effbot.org/zone/librarybook-core-eval.htm

Post a Comment

MKRdezign

Contact Form

Name

Email *

Message *

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