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:







We've had techniques like:


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 {
#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 {
-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 {

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 {
#declare VarThickness = 0.02;
#declare Fn01 = function {

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

Download 'f_remapstory.png' (367 KB)

Preview of image 'f_remapstory.png'


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