A hagelslag (sprinkles) OSL shader

Created for other purposes but this noise pattern is quite versatile. In the image below it is used for the chocolate sprinkles but bacteria and some forms of dust is what it originally was intended for:


As always, example code and node setups are available on my blog:

http://blenderthings.blogspot.com/2012/12/a-hagelslag-sprinkles-osl-shader-for.html

I know the crust in the image above looks completely fake but that was not what I was focussing on, however, I am still trying the improve the display of the sprinkles themselves because although they are displaced, they still look a bit flat. I think I can improve that by reducing the gloss and darkening the difuse close to the edge of the sprinkles as these edges are lower and receive less light, kinda like AO. But I am interested to hear other suggestions.

i tried to redo this one a few times

and i get nothing out of the osl shader
just a diffuse color

is it possible to upload a sample file so we can test this one
which is very interesting

thanks

just a diffuse color is often caused by forgetting to enable osl features in the camera panel, at least that is what I forget all the time

i do have the OSL enable in render panel
but not certain what you meant with Camera panel var!
most of the other osl shader works well but not this one!

here is file sample
let me know if you find something wrong

zspeck2.blend (503 KB)

thanks

here is render of what i get


thanks

If i may - thanks for posting new ideas. It’s interesting to see examples like these.
I have different results out of the file RickyBlender posted - it mostly works - http://www.pasteall.org/pic/44918. By “mostly” i mean it renders, 32 passes of that plane in 5 min which is, well, slow. I might not have the latest hardware tho.
What is not quite ok is that when i start to breathe during cycles crunching this, blender disappears from my screen leaving this in terminal

While at, i can’t figure out what is the meaning of lines :


vector dp = vector(5,7,11);
...

dp *= 17;

in this OSL script.
Could you comment on these a bit, please?

Edit: for the protocol -
AMD Athlon™ 64 X2 Dual Core Processor 3800+
OpenGL Renderer : GeForce GTX 560/PCIe/SSE2
Memory : 5081MB (915MB used)

linux, 64bit, Blender r54186.

on which OS and SVN did you do it ?

thanks

varrkenvarken

can you confirm that it is working fine on your system

i can prepare a bug report but need some more info on this bug

i’m on window 32 bits vista

thanks

@eppo: got that error earlier as well I am starting to doubt I’ve posted the correct version. I’ll check it out once I am home ( I have a day job as well :-; )

I wasn’t suspicious for nothing :slight_smile: Updated the code in the blog article. Turned out a return statement inside a shader definition is a problem. Tested against W7-64 / r 54202. Encountered this earlier: the distance() function not being completely implemented. Meanwhile that is fixwd (making the workaround in this same sprinkles recipe obsolete in fact). Despite all its versatility OSL is still a bit rough on the edges…

@eppo: about that dp business: If you want to have more than one random value inside a cell, it’s useless to call cellnoise() twice with the same parameter. Therefor you might add large vector to your coordinate and get a different cellnoise value. This way you can get a set of random values that is the same within a given cell. To make them appear oncorrelated when you can see many cells this vector offset should be large and if you use a multiplication factor it helps if that is a prime to reduce patterns. However, the implementation of that here is rather sloppy so don’t pay too much attention to it.

Let me know if it works for you guys now.

cheers.

that’s beginning to work now on vista 32 bits
thanks for the update

can you explain a little how you make the cylinder shape
is it like using some bezier curve may be

i’d like to make some curvy lines like that
to simulate some texture i have and it does not really exit yet

and thanks for sharing these OSL shader

thanks

Thanks for the explanation.
Somehow did not associate this vector with randomization here. Learn some new tricks every day…

Checked corrected version - it works on r54330, no crashes so far.

@rickyblender: the cylinder shape is because the distance to a line segment is used to drive the bump height, no splines involved here if you want to produce curvy lines (for your angel hair?) you might produce a random set of points, connected by a spline. unfortunately i cannot spend time on that myself now but if you check my leaf veines shader you will find that the veins are implemented as quadratic splines.

i’ll check if i can find some equation that looks like wavy lines for angel hair
it’s a weird shape but an interesting one
never seen it before

sparkles

can you show a render of sparkles on how it i supposed to look at low density
i did some render and it looks to me that some parts are missing but may be normal behavior!


thanks

I refactored the code because the bugs in OSL that needed special treatment are no longer there. Per request I also added a separate output with a random number that is unique for each sprinkle, so now it is possible for example to add a unique color to each of them.

Details & code in this article.