|
|
Roughly a year ago I re-worked the wood pattern and implemented an
inbuilt function called f_wood() which could mimic it using the same
basic approach long used for wood. I wasn't very satisfied with the
result. My thinking was what we really needed was functionality which
could create growth rings in a more realistic way.
One of the distribution types recently added to f_distribtion() was a
normal/gaussian. With this in hand, I took another run at an f_wood()
supporting more realistic growth rings. I left all turbulence and
displacement to outside actors.
Attached is an image where in the top row the variation is accomplished
with a random number stream adjusting a nominal ring width for each
ring. In the second row the random values conform to a normal
distribution - less often are extreme values seen. The columns represent
the three return types.
Of note, the color_map for middle and right columns use the blend_mode 3
feature of v3.8 to get the ring 'steps' to better show.
Bill P.
The documentation text from functions.inc:
Returns 0-1 ramp value within a ring and ring number. Optionally, the
float portion of the ring number can represent the what fraction of the
total rings in the tree a particular ring represents.
Values are returned as two 32 bit values encoded in the double space
where the individual values are accessed via the f_dec2x_f32() function.
The first 32 bit float is the 0-1 pattern value within the particular
ring. The second value is a 32 bit float representing this ring's count
from the core by the integer portion of the float and optionally a
[0..1) value representing thisRingCnt/treeRingsCount via the decimal
portion.
The aim with f_wood is not to mimic the wood pattern, but rather provide
a function returning growth rings which vary in width, a definable wood
core and the ring number and fractional position in the wood log. The
hope is upon this base, more natural algorithmic-ally generated 'wood
patterns' can be created.
TODO. There are only 6-7 digits of accuracy in that second float! For
typical ring counts OK, but maybe the user should be able to select the
second return type?
Example:
#declare Core = 0.02;
#declare Width = Core/2.0;
#declare Rings = int(((1.0-Core)/Width)+10);
#declare Seed = 9871.123456;
#declare Mean = 0.0; // Used only if type is 1
#declare Sigma = 1/3; // ditto
#declare Pigm00 = pigment {
function {
f_dec2x_f32(
f_wood(1,f_hypot(x,y),Core,Width,Rings,Seed,Mean,Sigma),
0)
}
color_map {...}
}
Though aimed at creating wood patterns, the function can be used with
any gradient of values.
Eight parameters required:
1. Type. If 0, a random value stream is used to vary each ring width. If
1, the random value stream conforms to a more nature like normal
distribution. Option 1 is slower.
2. Input value. Usually a distance from a center, but any gradient works.
3. The core / starting radius. If positioning wood shapes in the pattern
away from the core, this can be used to improve performance by skipping
the ring calculations prior to those needed.
4. The nominal width of each ring in the 'tree log.'
5. The count of the rings in the tree. Used to calculated a stepped
gradient of each ring from the core to the bark.
6. Seed for random number stream(s). It should be a float other than 0.
7. Mean value of the normal distribution. Used only if the type is 1.
8. Sigma value for the normal distribution. Used only if the type is 1.
Post a reply to this message
Attachments:
Download 'story_f_wood.jpg' (416 KB)
Preview of image 'story_f_wood.jpg'
|
|