POV-Ray : Newsgroups : povray.beta-test.binaries : Function / pattern issues. Adding f_remap. : Function / pattern issues. Adding f_remap. Server Time
26 Feb 2024 15:20:55 EST (-0500)
  Function / pattern issues. Adding f_remap.  
From: William F Pokorny
Date: 10 Apr 2020 07:19:40
Message: <5e90564c@news.povray.org>
Previous related postings:

http://news.povray.org/povray.beta-test.binaries/thread/%3C5da21410%40news.povray.org%3E/

http://news.povray.org/povray.beta-test.binaries/thread/%3C5dab3f55%241%40news.povray.org%3E/

http://news.povray.org/povray.beta-test.binaries/thread/%3C5dbc6985%241%40news.povray.org%3E/

http://news.povray.org/povray.beta-test.binaries/thread/%3C5dd8006c%241%40news.povray.org%3E/

and

http://news.povray.org/povray.beta-test.binaries/thread/%3C5e8a0353%241%40news.povray.org%3E/


We've had techniques like:

max(Fn01(x,y,z)-VarThickness/2.0,-Fn01(x,y,z)-VarThickness/2.0)

for creating isosurface shells; shells of negative value. If you want 
more than one shell based on the same function, it can be done, but in 
the simplest linear function forms, it ends up that the shell at 0.0 is 
twice the 'thickness' of all the others. The set up is also messy.

To help added a new inbuilt f_remap function to povr.

#declare f_remap = function { internal(3) }
// Parameters:
// 1. Incoming value to remap to weighted triangular peaked
// wave -1 to 1 to -1.
// 2. Number of triangle peaks in values remap. Min of 2.
// 3. Threshold for shell values. 0.0 returns weighted
// triangular values. When > 0.0 negative, normalized negative value
// shells created around the 2-8 values specified with
// parameters [4-11].
// 4-11 values to consider 0 points between peaks. Max of 8.

--- Upper left image
Used to displace the y plane via:

#declare Fn00 = function { f_gradient(x,y,z,1,0,0.5) }
#declare Fn01 = function {
     f_remap(Fn00(x,y,z),3,0.0,
         -1.0,0.0,0.5,2.0,
         100,100,100,100)
}
#declare Fn03 = function { y + Fn01(x,y,z)*0.25 }

it generates the upper left image. It remaps values so as to have 0 
crossings at the 2-8 values specified. Given the f_gradient input (and 
yes, that is a new inbuilt function too replacing the three X,Y,Z only 
functions.inc forms), we end up with ramps into and out of the 0 
crossing which themselves peak in a triangular fashion at -1 and 1 values.

--- Upper right mage
Using a normal-ish approach to get shells (here walls) at the zero 
values we use:

#declare Fn02 = function {
max(Fn01(x,y,z)-VarThickness/2.0,
-Fn01(x,y,z)-VarThickness/2.0) }

and get the upper right result where though the shells now all two sided 
they still change widths due the differences in ramps into and out of 
the zero regions.

--- Lower left image
Here we pass the VarThickness threshold to the f_remap function. It 
creates the shells while normalizing to the steepest ramp from 1 or -1 
into any 0 value. The use code for this looks like:

#declare Fn00 = function { f_gradient(x,y,z,1,0,0) }
#declare VarThickness = 0.15;
#declare Fn01 = function {
     f_remap(Fn00(x,y,z),3,VarThickness,
         -1.0,0.0,0.5,1.2,
         100,100,100,100)
}

with Fn01 used directly in the isosurface function. Result in the lower 
left.  Yes, for less linear input functions the shell/width thicknesses 
are still going to vary even with normalization - but substantially less so.

--- Lower right image...
Playing with the value difference between noise generator 2 and 3 as 
wondered about in the recent posting to p.b.i. The code for that looks like:

#declare Fn00 = function {
    f_snoise3d(x-2/2,y/2,z/2,2)-
    f_snoise3d(x-2/2,y/2,z/2,3)
}
#declare VarThickness = 0.02;
#declare Fn01 = function {
     f_remap(Fn00(x,y,z),5,VarThickness,
         -0.6,-0.3,0.0,0.3,0.6,
         100,100,100)
}

and the result is shown in the lower right. Yes, f_snoise3d is now 
inbuilt and requires the noise generator to be set.

Bill P.


Post a reply to this message


Attachments:
Download 'f_remapstory.png' (367 KB)

Preview of image 'f_remapstory.png'
f_remapstory.png


 

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