POV-Ray : Newsgroups : povray.advanced-users : Making Patterns with functions : Re: Making Patterns with functions Server Time
23 Feb 2024 12:57:38 EST (-0500)
  Re: Making Patterns with functions  
From: Bald Eagle
Date: 22 Jan 2024 14:50:00
Message: <web.65aec611d81b84791f9dae3025979125@news.povray.org>
"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 2-argument 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}

POV-Ray'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 0-255 range, you're going to
have to divide the result by 255

If the function repeats over a range of 0-255, 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 full-color 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.