Page 5 of 6

Re: Voronoi ISL Shader

Posted: Tue May 31, 2011 9:18 pm
by Doug Armand
OnoSendai wrote:Implemented a basic Voronoi function.
Messing around with it:
The ones with rings are based on pulse()ing the distance from the voronoi cell points. There's also 4 scales of Voronoi regions mixed together :)
Will these be easily accessible to a shader nublet like me without needing a maths degree? :wink:
If so then that will be great indeed

Re: Voronoi ISL Shader

Posted: Tue May 31, 2011 9:46 pm
by OnoSendai
Doug Armand wrote:
OnoSendai wrote:Implemented a basic Voronoi function.
Messing around with it:
The ones with rings are based on pulse()ing the distance from the voronoi cell points. There's also 4 scales of Voronoi regions mixed together :)
Will these be easily accessible to a shader nublet like me without needing a maths degree? :wink:
If so then that will be great indeed
Yes, we've been working on that as well. Will post some details soon.

Re: Voronoi ISL Shader

Posted: Tue May 31, 2011 11:38 pm
by galinette
Hello,

If you want, I can try to explain my shader. It gives a result quite different than these

Etienne

Re: Voronoi ISL Shader

Posted: Wed Jun 01, 2011 12:13 am
by OnoSendai
Hi Etienne,
That's fine thanks.
These pictures are from 'fractal' Voronoi regions, e.g. a sum of voronoi regions of different scales.

Re: Voronoi ISL Shader

Posted: Wed Jun 01, 2011 12:50 am
by OnoSendai
Here's a visualisation of the basic voronoi noise, with the code:

Code: Select all

def scaledVoronoiDist(vec2 p, real scale) real :
  dist(p * scale, voronoi(p * scale, 1.0))
  
def eval(vec3 pos) vec3 :
  vec3(scaledVoronoiDist(getTexCoords(0), 10.0))
You can see the underlying grid pattern, which I will do some work to get rid of soon.

Re: Voronoi ISL Shader

Posted: Wed Jun 01, 2011 1:32 am
by CTZn
Very nice, so we can map the cells size... some control over randomness might be of use too.

Looking forward for these improvements in accessibility you are talking about, I'm wondering wether that may concern sharing of code snippets :)

Re: Voronoi ISL Shader

Posted: Wed Jun 01, 2011 2:03 am
by OnoSendai
You will be able to define shader 'parameters' like so, which will then be available in your shader as pre-defined functions:

We're still working on the code, we'll make a fuss about it when it's done, because it should be pretty cool, and should finally make shaders easily tweakable by artists :)

Code: Select all

	<albedo>
				<shader>
          <param>
            <colour3>
              <name>BrickBaseColour</name>
              <description>Base colour for the brick.</description>
              <value>0.6 0.2 0.2</value>
            </colour3>
          </param>

          <param>
            <colour3>
              <name>GroutBaseColour</name>
              <description>Base colour for the grouting.</description>
              <value>0.5 0.5 0.5</value>
            </colour3>
          </param>
          
          <param>
            <real>
              <name>BrickColourVariation</name>
              <description></description>
              <min>0</min>
              <max>1.0</max>
              <value>0.3</value>
            </real>
          </param>

					<shader>
						<![CDATA[	
						   
def brickColour() vec3 : 
  paramBrickBaseColour() + 
  vec3(
    noise(vec2(0.5 + brickXNum() * 10.0, 0.5 + brickYNum() * 10.0)) * paramBrickColourVariation(), 
    0.0, 
    0.0
  )
  
def groutColour() vec3 : 
  paramGroutBaseColour()

def eval(vec3 pos) vec3 :
  if(
    (brickX() < grout()) || 
    (brickY() < grout()) ||
    (brickX() > (paramBrickWidth() - grout())) || 
    (brickY() > (paramBrickHeight() - grout()))
    ,
    groutColour(),
    brickColour()
  )
						]]>
					</shader>
				</shader>
			</albedo>

Re: Voronoi ISL Shader

Posted: Wed Jun 01, 2011 10:49 am
by CTZn
Mmmh tasty, I remember about that one now. Is this something that will be able [for] use early ?

Re: Voronoi ISL Shader

Posted: Mon Mar 19, 2012 2:03 pm
by mspaw
Etienne-

Im working on a voronoi map as well and wondering if you would be willing to share how you are getting the rounded corners on your stones. Ive been playing with any number of combinations of the feature points but have yet to figure out how you achieve the rounded appearance. Any help would be great.

Thanks!

-Michael

Re: Voronoi ISL Shader

Posted: Thu Mar 22, 2012 10:49 pm
by galinette
Hi,

Yes, I can share the shader! I have to look at home and find back the file... It was quite complex

I can remember the principle behind it.

If you want to model a pyramid in ISL, you can decribe it like that:
- Find the equation z(u,v) of each 4 planes of the pyramid
- If you take for any point the minimum of these 4 equations, you have a procedural pyramid

Now, instead of the min function, just take a softmin. You will get a rounded pyramid. This is basically how I make the ceramic tiles in a database material.

The rounded stones works similarly, but for this I need to make voronoi pyramids instead of voronoi cells. The pyramid panes are defined by the distance to the closest voronoi cell edge. This was a pretty big ISL shader...

Etienne

Re: Voronoi ISL Shader

Posted: Fri Mar 23, 2012 4:29 am
by mspaw
Etienne-

Id love to see the codes for sure. I'm wondering if it can be made into a 3d solid procedural? It sounds like if I already have a voronoi function I need to check the point to be shaded against all the edges and do a soft min, if I understand correctly? Id love to see what that might look like in C++ but if you have a working version I may be able to tease out the rest. The trick I gather is building up a sum of all the boundaries.

Looking forward to it!

Thanks

-Michael

Re: Voronoi ISL Shader

Posted: Fri Mar 23, 2012 4:50 am
by galinette
What do you mean by 3D solid procedural?

In fact, it is not easy to start from a voronoi func to compute the distance to edges. It is more easy to build a "voronoi pyramids" function from scratch.

Of course, it should be doable in C++, which is much more flexible than ISL!

Etienne

Re: Voronoi ISL Shader

Posted: Fri Mar 23, 2012 5:53 am
by mspaw
Im actually working on a map for 3ds max. By solid procedural i mean a map that takes a XYZ input vs UV and computed the value in 3d space. I gather yours is in UV space?

Yeah computing the boundaries is a trick but it should be doable.

-Michael

Re: Voronoi ISL Shader

Posted: Fri Mar 30, 2012 4:29 am
by mspaw
Etienne-

Any luck digging out the code?

Thanks!

-Michael

Re: Voronoi ISL Shader

Posted: Sun Apr 01, 2012 8:53 am
by galinette
Hi!

Please find the materials attached.
pyra is more a base shader for you to understand how to make some interesting effects
stones is the stone material. It is unfinished and ugly, but all the base code is there. All it needs is artistic optimization...

I will have less and less time to work on these free-time things now : I am the father of a little girl named Augustine since yesterday evening! I will continue the work on coated glass though (this is not free time but work time!)

Regards,

Etienne