OSL Goodness

ah, awesome, thank you sir. that’s exactly what i was hoping for.

i know this totally defeats the purpose of “writing your own shaders”, but is there (or has anyone dreamed up the idea of) a utility that can let you make shaders using nodes and output a .osl file? i mean something along the lines of what utilities like Sler, Shrimp, or Shaderman are to PRMan.

on another note, i just noticed this -
[ATTACH=CONFIG]201310[/ATTACH] caustics! i know this is a pretty lame example, but those caustics are lovely, they converged really quickly, and this is just the default node_glass_bsdf shader.

I guess that’s because at the studio where OSL is mainly developed (Sony Pictures Imageworks) it’s like Linux 95% and some Macs. It’s not much different with the other main VFX houses…

OSL now supports a wireframe shader (triangles only though):

#include "stdosl.h"
#include "oslutil.h"

shader node_wireframe(
    float Line_Width = 2.0,
    int Raster = 1,
    output float Fac = 0.0)
{
    float wire = wireframe("triangles", Line_Width, Raster);
    Fac = wire;
}


Maybe Cycles now could show selection in viewport?

@kivig: That is not related to Viewport Drawing.

Blender Trunk now has full Open Shading Language Support + Custom Shaders!
http://lists.blender.org/pipermail/bf-blender-cvs/2012-November/051009.html
http://lists.blender.org/pipermail/bf-blender-cvs/2012-November/051010.html
http://lists.blender.org/pipermail/bf-blender-cvs/2012-November/051011.html

Credits: Brecht, Lukas, Dalai, Jens and yours truly :slight_smile:
It has been a pleasure working on this!

WHAT?? yay! thank you sir!

On Graphical, I only see mac build. Any others soon?

Another OSL experiment: Gabor Noise completely in OSL

http://www.pasteall.org/blend/17295

http://www.pasteall.org/pic/show.php?id=39980

There is a built-in gabor noise function in OSL (OSL specs, page 52). However, it is currently still a bit limited in terms of controlling the frequency spectrum, which is what gives gabor noise it’s amazing potential. From what i understand it would be very hard to make generic OSL functions that allow full user control over this spectrum using just the C++ implementation.

So, beside the joy of just making it work with OSL alone, it could possibly be a great way of extending this method with customized user tools and make it as flexible as possible.

The implementation is very basic still, the standard noise implementation in the specs has a number of features that are not available in this simple test, such as filtering.

The general method of creating “impulses” based on cell-noise-type hashing could also be used for other purposes. E.g. DingTo suggested making a “Stars” background texture by scattering small image textures instead of densely sampled gabor kernels. Lots of possibilities, i hope it works as an inspiration :slight_smile:

And texture is now supported :slight_smile:


surface
environment
(
    string filepath = "//textures/panorama-base.jpg",
	output closure color Cout = 0
)
{
  vector mdir = I;
	color paint = environment(filepath, mdir);
	Cout = paint * emission();
}

Notes:
it supports relative filepaths and it can be used with groups. At some point we will have it as a nice FILEPATH data type (so you can pick a file in your system), or even an image. That’s for after Pynode merge though

Hi.
If it possible to release this old plugin http://www-users.cs.umn.edu/~mein/blender/plugins/texture/water/index.html
with osl animated shader?

I don’t know how the plugin works in detail (don’t want to read through the code thoroughly), but i’m guessing the cell hash method use in cell noise and gabor noise could be adapted for this :wink:

You’d basically have to extend the static 2D cell hash with an additional parameter for time. This allows you to cull away any water splashes that don’t contribute to a sample, thereby making it possible to render on arbitrary scales at any point in time with good performance (that’s the main idea of cell hashes). For each contributing drop you then generate a radially symmetric wave based on spatial distance, with the main radius defined by the “time of impact”.

It’s actually a beautiful example, i might give it a try :slight_smile:

Haven’t been able to build with OSL on Windows 64. Has this issue been resolved?

You can compile OSL on windows with cmake and scons now. (Enable WITH_BF_CYCLES_OSL = 1 for scons) but its a bit crashy still. Make sure you have the latest libs.

Quick update: i tried modifying the gabor noise method to make such a raindrop effect, here is a first result:

http://www.pasteall.org/pic/show.php?id=40641

and the OSL code:

http://www.pasteall.org/37358

Doesn’t look very convincing yet, but that’s a matter of improving the wave model used, i.e. the way the way fades out in the distance and over time. There are also a few bugs and inconsistencies with the handling of time scale, so just take it as a proof of concept. And of course it needs an actual water shader :wink:

As noted above, the big advantage of this method is scalability: you can render a gazillion rain drops without affecting performance, unlike particles/dynamic paint etc., which give you more control over individual rain drops, but are limited in terms of scale.

Also the method can quite easily be made seamless and repeatable in both space and time, allowing tiled textures and/or looped animation.

Hey Thomas,
Thanks for the Quick reply.
Alas, still won’t build. Are there OSL libraries for mingw64 ?
My guess is no.

CYCLES_OSL = C:/opt/blender_builds/trunk/…/lib/mingw64/osl OSL not found

EXR C:/opt/blender_builds/trunk/…/lib/mingw64/openexr/include/OpenEXR

CUDA nvcc = C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.0/bin/nvcc.exe
Blender Skipping: (bf_intern_ctr;extern_redcode)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
OSL_INCLUDES

used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/blender
used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/bvh
used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/device
used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/kernel
used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/kernel
used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/kernel/osl
used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/kernel/shaders

used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/render
used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/subd
used as include directory in directory C:/opt/blender_builds/trunk/intern/cycles/util

OSL_LIB_COMP
linked by target “blender” in directory C:/opt/blender_builds/trunk/source/creator
OSL_LIB_EXEC
linked by target “blender” in directory C:/opt/blender_builds/trunk/source/creator
OSL_LIB_QUERY
linked by target “blender” in directory C:/opt/blender_builds/trunk/source/creator
Configuring incomplete, errors occurred!

It’s really great to play with OSL, but more I understand what I do more I’ve question.
So here is my list:
Can we have acess to the coordinate of another object?
Can we create a BSDF?
Can we know a value of a BSDF(input) change the value and out the BSDF ?
Is there a way to affect all the screen?? For exemple a vignette?? I know when i make a vignette node with windows coordinatte and multiply the color in color object, it should work. But I mean something more like a filter for all the frame. Is that clear??
Thanks for answer, for sure I will have other question.

by the way, just out of curiosity - is there a layman-friendly explanation as to why rendering with OSL takes twice as long to clean up noise as rendering with SVM?

I’ve tried a couple builds now, and they always crashed on me, so I decided to try compiling the shader from the text editor. Somehow, the Blender to 3Delight exporter screwed things up… But now I have another error showing up. Help?


br1992 you have to go in node editor, add script node, select text and you will see