common
Class DefaultGradientTransfer
Object
common:Generic
common:Transfer
common:DefaultGradientTransfer
class
- Transfer:DefaultGradientTransfer
Provides the same gradient transfer options as Ultra Fractal's built-in gradient options.
This transfer function emulates the normal gradient transfer method.
It's designed primarily for conversion of a positive float to a final
gradient index (also positive float) but does not mod it from 0 to 1
making it potentially useful for other transform purposes.
Note that it deliberately returns negative values unchanged
to ensure normal gradient behaviour.
David Makin, May 2008
Ultra Fractal Source
Toggle UF Source Code Display
class DefaultGradientTransfer(Transfer) {
; Provides the same gradient transfer options as Ultra Fractal's built-in gradient options.
; <p>
; This transfer function emulates the normal gradient transfer method.
; It's designed primarily for conversion of a positive float to a final
; gradient index (also positive float) but does not mod it from 0 to 1
; making it potentially useful for other transform purposes.
; Note that it deliberately returns negative values unchanged
; to ensure normal gradient behaviour.
; David Makin, May 2008
public:
float func Iterate(float pr)
if (pr < 0.0)
return @p_offset*0.0025
endif
float x = pr * @p_zscale
if (@p_xfer == "Sqr")
x = 2*sqr(x)
elseif (@p_xfer == "Sqrt")
x = 0.5*sqrt(x)
elseif (@p_xfer == "Cube")
x = 3*x^3
elseif (@p_xfer == "CubeRoot")
x = (x^(1/3))/3
elseif (@p_xfer == "Log")
x = log(1+x)
elseif (@p_xfer == "Exp")
if (x >= 100)
x = exp(100)
else
x = exp(x)
endif
elseif (@p_xfer == "Sin")
x = abs(sin(x))
elseif (@p_xfer == "ArcTan")
x = abs(atan(x))
elseif (@p_xfer == "Cos")
x = 1+cos(x)
elseif (@p_xfer == "LogTan")
x = log(1+abs(tan(x)))
elseif (@p_xfer == "LogLog")
x = log(1+log(1+x))
elseif (@p_xfer == "InvArcTan")
x = 0.0005*((2.0*#pi/atan(x))^2.0 - 1)
endif
return 0.0025*@p_offset + x * @p_zscale2
endfunc
default:
title = "Default Gradient Transfer"
int param v_defaultgradienttransfer
caption = "Version (DefaultGradientTransfer)"
default = 101
hint = "This version parameter is used to detect when a change has been made to the formula that is incompatible with the previous version. When that happens, this field will reflect the old version number to alert you to the fact that an alternate rendering is being used."
visible = @v_defaultgradienttransfer < 100
endparam
param p_xfer
caption = "Transfer Function"
default = 0
enum = "Linear" "Sqr" "Sqrt" "Cube" "CubeRoot" "Log" "Exp" "Sin" "ArcTan" "Cos" "LogTan" "LogLog" "InvArcTan"
hint = "This function will be applied to the value."
endparam
param p_zscale
caption = "Pre-Scale (Density)"
default = 1.0
exponential = true
hint = "Applied prior to the 'Transfer Function'."
endparam
param p_zscale2
caption = "Post-Scale"
default = 1.0
exponential = true
hint = "Applied after the 'Transfer Function'."
endparam
param p_offset
caption = "Offset"
default = 0.0
hint = "This is meant as a gradient index offset, so the value you give is actually divided by 400 in use."
endparam
}
Method Summary |
float |
Iterate(float pr)
call this to process another value in the sequence |
Methods inherited from class Object |
|
DefaultGradientTransfer
public DefaultGradientTransfer()
Iterate
public float Iterate(float pr)
- Description copied from class:
Transfer
- call this to process another value in the sequence
- Overrides:
Iterate
in class Transfer