PyNode cookbook

I put together a tiny PyNode cookbook. You can find it at http://wiki.blender.org/index.php/Resources/PyNode_Cookbook .

You are free to experiment with the scripts as you like. Also new recipes are welcomed. :slight_smile:

This is simply great. Five stars from me for this very useful work!!!

Sweet, I’ve been meaning to play more with PyNodes, and this surely helps!

Have fun, everyone :smiley:

/Nathan

Very cool! It would be great to have little example pictures of the output that those nodes produce, too.

I added some categories to the cookbook. I also added small ideas section to beginning of each category. If someone has something you wish to get implemented, just add it there for rest of peeps to see.

I agree that screenshots would be a be a nice addition. I will probably try to tackle this next along with some example .blends.

Thank you for the efforts. I pulled the code into an editor, then commented out the title block and saved each separately and jumped into Blender to try them out. It works!!! Yeh.
May be a bug in 2.46?? but after some playing I got three instances of the two scripts I had loaded into the Dynamics button?? Do you know if there is any intent to implement the Dynamic button in the Compositor Node window. It is on the menu, but “stubbed out” for now. I would love to push Blender in the Material and Compositor node level. The composite window should have the scope of function as Eyeon’s Fusion?? and the Dynamic button allows the building of new functions into the flow in Python before a C++ translation of the best.
Thanks again for your contributions.
Paul

paulhart2: Unfortunately PyNodes are limited only to materials for now. Hopefully we will see an implementation for compositing too in the future. :slight_smile:

I’ll be working on Compo Nodes sometime Soon<tm> :slight_smile: Especially now that ianwill managed to make PyNodes work with the threads for the render!

/Nathan

BeBraw, thanks for the info.
JesterKing, Wahoo… great to hear of the potential work on this area.
Anybody else finding “multiple instances” showing up in the DynamicsButton area after some time goes by. Looks like a bug, so I will see if I can duplicate it and document.
Paul

Mmmmhh How long are these pynodes availables ? I wasn’t aware of them.
It seems a very nice idea !

Man, there is sooo much to learn in Blender ! I sometimes feel lost in front of the 99% i don’t master…

But i think i should rather learn and Master the “regular” material nodes before tackling these custom ones…

Thanks for sharing your recipes BeBraw !

I’ve just started playing with pynodes. I read the man page on the wiki, and played with most of the recipes. Then I did some research and I’m currently reading this: Siggraph Shader Course.

Anyway, today I decided I knew enough to try and make something. I thought I chose something simple, but I haven’t been able to get anywhere with it. I’m trying to make a slope shader - a shader that outputs a linear gradient based on the angle of the surface. It would be pretty simple to do, but I can’t get into the right coordinate system.

It looks like the surface normal in self.shi is provided in camera space? I’m guessing the view normal is the direction of/to the camera? I have no idea what surfaceViewVector is supposed to be though?? Is there an easy way to get the object matrix of whatever the surface normal is relative to? You could just grab the active camera from the scene, but that wouldn’t work right in any of the preview renders… I think access to camera and object data needs be part of the information available in the call method!

Also it would be nice to be able to get access to lighting data. Right now the material nodes are more of a pre/post-process preformed before or after all the real lighting and shading happen. It would be cool if we could also receive and cast rays and just skip the material input nodes all together. I doesn’t seem that hard to write your own specular/diffuse/shadow/etc. shader, and it would allow a lot more possibilities in the material nodes :eyebrowlift:

TIA for any hints!

Kitsu,

I am very curious about that light model coding as well.
I see that this could lead to interesting results.

That stripy texture (Mod 2) is a very nice zebra effect.

Those PyNode are amazing. Very interesting to explore.
I guess now I finally need to learn Python.

One quick question - it seems that all textures I tried
produce jaggy results. The resolution is not very smooth
while I have OSA turned on. Something wrong here?

Argh. I still have to get those example images/.blends done. I will see if I manage to do that today.

kitsu: Do you have a proper example of a slope shader? Even an image or RenderMan script would do. Toon shaders found at the wiki have some slope detection in them (slope based on camera) so you might want to check them out. See http://bebraw.googlepages.com/toon02.png for example. Thanks for the link to the .pdf by the way. It seems like a good read.

In most of nodes I provided the user an option to feed their own vector. This is a nice alternative for using self.shi in some cases. The toon nodes have examples of how to use self.shi. Note that accessing texture coordinates requires that you have created a texture to the material and set its space properly. This is something that can be remedied by using Geometry input node, at least partially.

I haven’t found an easy way to access lighting data. Of course you could use the basic Python API Blender provides if you really want to. It would be probably possible to abstract a nice interface for lighting data this way.

cekuhnen: I pretty much got the idea for Mod 2 out of thin air. I wanted balloony shader and got one. Note that the stripes that it produces are not always even (start/end seam) so this might take some rethinking.

Jaggy results are most likely due to my inexperience with shaders. It will probably take some extra filtering at the boundaries to make it work with OSA nice.

Blender’s texture plugins might be a nice source for inspiration. Check them out at http://www-users.cs.umn.edu/~mein/blender/plugins/texture/ . Another resources I can recommend are http://www.amazon.com/Texturing-Modeling-Procedural-Approach-Kaufmann/dp/1558608486/ (gotta buy this one!) and http://www.scratchapixel.com/tutorials/home/home.php (teaches you how to build your own raytracer). Also checking out any page that has something to do with surface shaders is a good idea.

BeBraw

I have seriously now coding experience.
Unfortunately the tile patch did not make it into the current build.

Would it be difficult for you to translate this texture into python code?
http://www-users.cs.umn.edu/~mein/blender/plugins/texture/r_weave/
Fabric is a very difficult material to work with and such a procedural
solution is very elegant to use.

I am also curious if you would have a solution to leather? Voronio is
not the best for it. The wrinkles in this texture are not uniform.

I messed around some more on Sunday afternoon and came up with a couple of simple nodes. First is a node that creates equal sized bands on an object, then I made an input node for the current frame number, finally I made a simple vector split node :rolleyes:

http://kitsu.petesdomain.com/images/Blender/mat-nodes/band-nodes.jpg
http://kitsu.petesdomain.com/images/Blender/mat-nodes/band-render.jpg

Blend

Mainly I was just playing around with the geometry inputs. The way I understand the geom vectors are the location of the current pixel in the given space? Anyway my splitter node is nicer than using some float to pick an axis :wink:

cekuhnen: I’ll see if I can make something similar. I don’t really get C that well, but there are some hints in the old textures source.

BeBraw: Thanks for the pointers. I ordered the book you linked, and I’m going to try to read the tutorial you linked today. Looking through Blender’s shader header I think I see some interesting stuff, but it is hard to tell how much is passed through the struct vs. what is just used to fill it out…

I’m really impressed by how stable the PyNodes are now - I haven’t had one crash so far (though I haven’t been trying hard :evilgrin:). It is irritating that all the noodles get unhooked when you update the node though. The default Blender auto-rewire should work fine if some sockets get deleted. Also it would be nice if non-init errors just turned the node red rather than deleting all the sockets.

I played around some more last night and made a simple dots pattern:
http://kitsu.petesdomain.com/images/Blender/mat-nodes/dots-render.png

http://kitsu.petesdomain.com/images/Blender/mat-nodes/dot-nodes.png

Blend

I think I can fix the aliasing visible on some of the dots by adding a falloff at the threshold of the dot-spheres. I’d also like to add an offset factor between rows, but this is enough for now.

I had a look at the weave stuff, did some research, and read a whole bunch of Ken Perlin’s stuff. I’ve got some interesting ideas now, but most are pretty complicated to implement. I’ll probably try to make a straight port of the old weave code tonight and see if I can understand what it is doing.

I also figured out a decent work around for the noodle unlinking problem. Edit your code, save your blend, then select your blend from the File>Open Recent list. It still breaks on error, but it is quicker than rewiring everything on every update.

Darn book hasn’t arrived yet. I’m going to try to figure out how to output normals next - dots should have bumps!

lol: Dots + noise :ba:
http://kitsu.petesdomain.com/images/Blender/mat-nodes/dot-radius-noise.png
http://kitsu.petesdomain.com/images/Blender/mat-nodes/dot-radius-noise-nodes.png

http://kitsu.petesdomain.com/images/Blender/mat-nodes/dot-scale-noise.png
http://kitsu.petesdomain.com/images/Blender/mat-nodes/dot-scale-noise-nodes.png

Nice work kitsu! Thanks for sharing. Feel free to add the files/links to them to the wiki. :slight_smile:

Nice work “Kitsu” and others. Particularly like the noise introduction on the last two images. I have pulled all of the “Recipes” from here and the Pynodes Cookbook and added an attribution header to each and saved them off as separate .PY files. I suspect some of the “vector” examples may be best attributed to “Wahooney” but I don’t know which. Anyway, this allows some organizational clarity, particularly as the number of these grow. Thank you all for the fine efforts and the sharing. http://www.hartworks.net/blender/PyNode-Scripts.zip
Paul