Welcome to Fractal Forums

Fractal Software => Programming => Topic started by: Kali on November 15, 2012, 07:09:15 PM




Title: Distance field blending
Post by: Kali on November 15, 2012, 07:09:15 PM
I want to achieve a blending effect between two distance-estimated objects.
I tried to do it my own way but no good results... Quilez describes a way to do it here: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
But he uses "smoothcurve()" function? What is it? at first I thought it was a GLSL function but is not, and I couldn't find any clear references about what this function means and what it does... :hmh:

Any clues?



Title: Re: Distance field blending
Post by: eiffie on November 15, 2012, 07:25:09 PM
I remembered another thread on this...
http://www.fractalforums.com/programming/overlapping-spheres/ (http://www.fractalforums.com/programming/overlapping-spheres/)

THIS ANSWER CAME FROM SUBBLUE SO IT CARRIES SOME WEIGHT :)
I'm guessing smoothcurve is like the smoothstep function in OpenGL, which (from the spec):

Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1.  This is useful in cases where you would want a threshold function with a smooth transition.
This is equivalent to:
   t = clamp ((x – edge0) / (edge1 – edge0), 0, 1);
   return t * t * (3 – 2 * t);

...or it may be like the exponential step function he shows here:
http://iquilezles.org/www/articles/functions/functions.htm (http://iquilezles.org/www/articles/functions/functions.htm)


Title: Re: Distance field blending
Post by: Kali on November 15, 2012, 08:17:56 PM
Thanks eiffie! The weird thing is that before opening this thread, I did a search here at the forums for the word "smoothcurve" and no results, I did it again now and I found the post you pointed at :hmh: