





 
 




 
 


Op 09/01/2024 om 21:07 schreef Bald Eagle:
> Enjoy the eye and mind candy.
>
Oh LOL! Well done :)

Thomas
Post a reply to this message


 
 




 
 


"Bald Eagle" <cre### [at] netscapenet> wrote:
> Over the last 2 days, I've fallen down the mathematical pattern rabbit hole, and
> have been experimenting with all manner of what can be done with a simple
> pigment {function {}}
> statement.
>
> I currently have a list of 155 different patterns, including simple y = f(x)
> style functions, implicit equations (some combination of x&y) = (some other
> combination of x&y), and even some parametric polar equations and what I believe
> are parametric Cartesian equations.
>
> Hammering out that many equations one after the other and using different
> methods to visualize the "raw" results has allowed me to learn some new things
> and gain valuable insights into how best achieve a good, aesthetically pleasing
> result, and why some patterns might be difficult to implement in the absence of
> various "tricks".
>
> At this junction, I would like to thank everyone in the POVRay community, and
> especially Tor Olav Kristensen, Sam Benge, jr, William Pokorny, Jerome Grimbert,
> as well as the vast Shadertoy community  most notably Inigo Quilez, Martijn
> Steinrucken, and FabriceNeyret2, for inspiring me, and setting me on the path of
> discovery with regard to using functions to make amazing patterns.
>
> With that, I'll just leave here a most amazing Greek frieze pattern, produced by
> an astonishingly small amount of code, adapted to SDL from a shader by
> FabriceNeyret2.
>
> While this is probably one of the most complex patterns I've adapted, simply due
> to some specialized and highly technical methods that make its visibility even
> possible, I'd love to see people experimenting with simple equations to produce
> interesting patterns that we can build a library of.
>
> After progressively trimming down the amount of code I need to make a simple
> grid on a plane, I'd love to see such patterns codegolfed down to the bare
> minimum, and then parameterized to increase their variation and versatility.
>
> Happy New Year, everyone.
>
>  Bald Eagle
Wow, this one looks not easy and beautiful.
Post a reply to this message


 
 




 
 


"Bald Eagle" <cre### [at] netscapenet> wrote:
(Still experimenting and struggling with various aspects of getting patterns
from other platforms to play well with SDL.)
> Hammering out that many equations one after the other ... has allowed me to learn
some new things and gain valuable i
nsights ...
OK, just to list the ones that I've written down so far:
(Questions, comments, and constructive criticism welcome as always)
Important tips to generate quality patterns from equations

Be very careful with the use of parentheses  especially when + or  is in an
equation. Group terms.
You may want to declare different parts of a complex equation as separate
functions, then combine them in the final function
Use fmod instead of mod to get a regular repetition of a pattern across the
origin
HOWEVER, sometimes using mod in certain functions gives a better (more
expected) result  so try both
Use Mike Williams' "shell" trick for isosurfaces to give an infinitely thin line
a visible thickness
Change the line thickness to give definition to patterns that may not show up
with smaller values.
Some equations don't cross the zero/integer/mod threshold often enough to show
finer details. Multiply the
WHOLE equation (use parentheses) by a factor to increase the number of
lines/levels.
Zoom in or out to see pattern attributes that may not be visible or clearly
rendered.
If you're graphing y as a function of x, then you must write it in the form of:
function {y  formula} since when y=formula, the value is 0
If you're graphing a 2argument function of both x and y, then you must write it
in the form of: function {(x  x_formula) + (y  y_formula)}
If you're graphing a polar equation, then write it in the form of: function {r 
formula}
POVRay's internal method of wrapping function values winds up hiding negative
vs positive parts,
and won't be revealed until made as an isosurface, or the function is shifted
by + 0.5 and visualized with a color map
If you're using functions that return values in the 0255 range, you're going to
have to divide the result by 255
If the function repeats over a range of 0255, then you're going to have to use
mod (Function (x, y, z), 256)/255
You're going to need function versions of HSV to RGB to perform color
calculations
For fullcolor patterns, you're going to separate functions for r, g, and b,
plus an average texture using all 3 functions
There are common functions and operations that the function parser doesn't
recognize, and you'll have to write your own versions of
identifiers previously declared in a scene (even for loop iterators!) cannot
then be used in a function
If you're experiencing a blank pattern (all black/white/gray) then you have
likely forgotten to explicitly include x, y, and z into your function
argument list. If your function takes some value N as an argument, but also
uses x, y, or z, then you must #declare F = function (x, y, z, N) {}
If your pattern only appears in the first quadrant (upper right, both x and y
are positive), then you will likely need to use abs(X) and abs(y) in your
equation
Post a reply to this message


 
 




 
 


"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
>
> (Still experimenting and struggling with various aspects of getting patterns
> from other platforms to play well with SDL.)
>
> Important tips to generate quality patterns from equations
> 
> Use Mike Williams' "shell" trick for isosurfaces to give an infinitely thin line
> a visible thickness
Say what??!!
That would be really useful.
Do you have a link to this trick, or a short explanation? (keeping my fingers
crossed)
Post a reply to this message


 
 




 
 


"Kenneth" <kdw### [at] gmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
>
> > Use Mike Williams' "shell" trick for isosurfaces to give an infinitely
> > thin line a visible thickness
>
>
> Do you have a link to this trick, or a short explanation? (keeping my fingers
> crossed)
I just took a look at the Mike Williams 'isosurface tutorial' that you packaged
and sent to me as a .pdf file some years ago. Is the technique you refer to here
the same as Mike's 'thickening' trick using 2 parallel surfaces (page 18 of
149)? Or is it something different?
Thickening
If we have a function F(x,y,z) we can turn it into two parallel surfaces by
using abs(F(x,y,z))C where C is some small value. The original function should
be one that works with zero threshold. The two resulting surfaces are what you
would get by rendering the original function with threshold +C and C, but
combined into a single image. The space between the two surfaces becomes the
"inside" of the object. In this way we can construct things like glasses and
cups that have walls of nonzero thickness.
[example:]
#declare F = function {y + f_noise3d (x*2, 0, z*2)}
isosurface {
function {abs (F(x, y, z))0.1}
......
Post a reply to this message


 
 




 
 


"Kenneth" <kdw### [at] gmailcom> wrote:
> Is the technique you refer to here
> the same as Mike's 'thickening' trick using 2 parallel surfaces (page 18 of
> 149)? Or is it something different?
It is the same  yet with a slight difference.
If you're trying to make a black pattern on a white background, you're going to
want a solid black pattern, not a small gradient from C to 0 to +C.
So you just use select to make a discontinuous function.
#declare Pattern = function {select (abs(F(x,y,z)C, 0, 0, 1)}
And then when you do plane {z, 0, pigment {function {Pattern (x, y, z)}}}, you
get what you're probably expecting.
 BW
Post a reply to this message


 
 




 
 


"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
>
> > Is the technique you refer to here
> > the same as Mike's 'thickening' trick using 2 parallel surfaces (page 18 of
> > 149)? Or is it something different?
>
> It is the same  yet with a slight difference.
>
> If you're trying to make a black pattern on a white background, you're going to
> want a solid black pattern, not a small gradient from C to 0 to +C.
>
> So you just use select to make a discontinuous function.
>
> #declare Pattern = function {select (abs(F(x,y,z)C, 0, 0, 1)}
>
> And then when you do plane {z, 0, pigment {function {Pattern (x, y, z)}}}, you
> get what you're probably expecting.
>
Great, thanks. Yes, you were reading my mind, ha. (Actually, my own use would be
the reverse a white pattern on a black background.) I'll test it and play...
Post a reply to this message


 
 




 
 


I played with a few more functions  I think I'm up to about 189 in the
collection, and still have many more to implement.
This one I liked because it was "simple", and would probably find use in any
number of scenes, for different purposes.
Like the ultraimpressive Greek frieze pattern, this one got adapted from
Desmos, and it takes a lot of reading and thinking to grasp Desmos' syntax /
expression structure, unravel what is meant, and discard the superfluous parts.
I got it wrong about a dozen times, but in the process found that sometimes the
mistakes yield some pretty amazing and complex pattern in and of themselves.
So, when experimenting with new patterns, don't give up, and don't be surprised
when the raw pattern seems to bear absolutely no relation to the pattern that
you're trying to code. The raw vs "thickened" pattern can differ  starkly  in
appearance.
Hopefully we can get a few new patterns posted in this thread, and I'm going to
try to post at least one new pattern a week, to keep some momentum going.
Hope you like.
 BE
Post a reply to this message
Attachments:
Download 'mathpatterns1.png' (59 KB)
Preview of image 'mathpatterns1.png'


 
 




 
 


"Bald Eagle" <cre### [at] netscapenet> wrote:
> I'm going to try to post at least one new pattern a week, to keep some momentum
going.
Post a reply to this message
Attachments:
Download 'mathpatterns1.png' (193 KB)
Preview of image 'mathpatterns1.png'


 
 




 
 


Neat grid pattern.
Post a reply to this message
Attachments:
Download 'mathpatterns1.png' (15 KB)
Preview of image 'mathpatterns1.png'


 
 




 

