"Cracks, Creases, Lightening etc in OSL" Implementation

Hi I started this here as it is no longer a question of if someone has done it it’s now what is the best way of doing it.

Ok I have been learning a bit and I have come up with a couple of ideas. Comments would be gratefully received.

What I am now thinking is that to do this I need a persistent point cloud.
My current idea is to simply feed the script with another shader like noise or what ever.
Define:
a start point
start colour of value
a possible destination.
an erosion level
and maybe other parameters
a hit colour or value

then start at the start point head to the destination find the closest points that are equal to the hit colour. Find the next that is not that colour and then look for it again when found calculate the erosion and draw a line of the appropriate value between the two points. This process would continue for each point found and those around it always heading in the direction toward the destination.

Is this a good way to look at the problem or am I completely off track here.

Feeding it with another texture would allow the code to me small and simple and infinitely flexible.

Ideas please.
Thanks

Hi there,

This is not a easy task, i can think of a few ways to go about it:

1 - Use a k-d tree algorithm (you can search about it on wiki and you’ll find several code samples online)

2 - Using Recursion, taking each last step, branching to the next step, a big pain to get good results and heavy

Once you have the dots you have to connect them, i’m not really sure if you can do this with OSL, i think OSL only calculates one point of a 2D or 3D object at a time

I hope i helped a bit,

Thanks

Ok now I’m completely confused.
k-d tree, laplacian
wtf

so using another shader to drive it wont change anything.

Does a shader algorithm get processed for each pixel in each pass?
Sorry I haven’t had a chance to actually play yet.
Still trying to work out the rules

Hello,

With OSL you’ll get a Closure with all the surface data and it is processed like a whole, not pixels,

You can map textures into it, but if you want to, like, crack an object starting from one point of the surface to another, you would have to use the surface point system represented by the global var P,

P is a 2D ou 3D array depending on the surface you can find more detailed info here:
https://github.com/imageworks/OpenShadingLanguage/blob/master/src/doc/osl-languagespec.pdf

Thanks that is more clear.
I will read the spec. I was getting there. Its a bit too easy to ask questions rather than do the reading.
But thanks heaps.

Having the same question
Does a shader algorithm get processed for each pixel in each pass?