dmj5
Class DMJ_Distort
Object
common:Generic
common:Transform
common:UserTransform
dmj5:DMJ_Distort
class
- UserTransform:DMJ_Distort
Distortion (especially fBm) transformation.
(Roughly ported from dmj.uxf:dmj-fBm-Glass1 and dmj3.uxf:dmj3-fBm-Distort)
Ultra Fractal Source
Toggle UF Source Code Display
class DMJ_Distort(common.ulb:UserTransform) {
; Distortion (especially fBm) transformation.
; (Roughly ported from dmj.uxf:dmj-fBm-Glass1 and dmj3.uxf:dmj3-fBm-Distort)
public:
import "common.ulb"
func DMJ_Distort(Generic pparent)
UserTransform.UserTransform(pparent)
m_DistortionAngle = (0,1) ^ (@p_distortionangle / 90.0)
if (@p_fixed > 0)
m_Transform = new @f_transform(this)
m_TrapShape = new @f_trapshape(this)
m_Transfer = new @f_transfer(this)
endif
if (@p_fixed2 > 0)
m_Transform2 = new @f_transform2(this)
m_TrapShape2 = new @f_trapshape2(this)
m_Transfer2 = new @f_transfer2(this)
endif
endfunc
func Init(complex pz)
UserTransform.Init(pz)
if (@p_fixed > 0)
m_Transform.Init(pz)
m_TrapShape.Init(pz)
m_Transfer.Init(pz)
endif
if (@p_fixed2 > 0)
m_Transform2.Init(pz)
m_TrapShape2.Init(pz)
m_Transfer2.Init(pz)
endif
endfunc
complex func Iterate(complex pz)
UserTransform.Iterate(pz)
complex zt
float d
float d2
; get distortion basis
if (@p_fixed > 0)
zt = m_Transform.Iterate(pz)
d = m_TrapShape.Iterate(zt)
d = m_Transfer.Iterate(d)
else
d = 1.0
endif
; determine distortion angle
complex v = m_DistortionAngle ; by default, assume linear distortion; use regular vector
if (@p_fixed2 > 0)
zt = m_Transform2.Iterate(pz)
d2 = m_TrapShape2.Iterate(zt)
d2 = m_Transfer2.Iterate(d2)
d2 = d2 * @p_distortionstrength2
v = v * ((0,1) ^ (d2 / 90.0))
endif
if (@p_distortionstyle == 0) ; radial distortion
v = (pz - @p_distortioncenter) / cabs(pz - @p_distortioncenter) * v ; rotate to correct angle
endif
; distort
pz = pz + v * d * @p_distortionstrength
return pz
endfunc
protected:
complex m_DistortionAngle
UserTransform m_Transform
TrapShape m_TrapShape
Transfer m_Transfer
complex m_DistortionAngle2
UserTransform m_Transform2
TrapShape m_TrapShape2
Transfer m_Transfer2
default:
title = "Distort (fBm and more)"
int param v_dmj_distort
caption = "Version (DMJ_Distort)"
default = 100
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_dmj_distort < 100
endparam
int param p_distortionstyle
caption = "Distortion Style"
default = 0
enum = "radial" "linear"
hint = "This selects whether the distortion will be focused around a single point, or directed along a line."
endparam
float param p_distortionangle
caption = "Distortion Angle"
default = 0.0
hint = "This is the angle to rotate the distortion."
endparam
complex param p_distortioncenter
caption = "Distortion Center"
default = #center
hint = "Sets the center of distortion."
endparam
heading
caption = "Distortion Strength"
expanded = true
endheading
int param p_fixed
caption = "Method"
default = 1
enum = "fixed value" "object"
hint = "Chooses whether distortion strength should be a fixed value or be calculated by an object."
endparam
float param p_distortionstrength
caption = "Distortion Strength"
default = 0.5/#magn
hint = "This is the amount of pushing or pulling on the image to do. When the strength is calculated by an object, this acts as a multiplier, controlling the overall amount of distortion."
endparam
UserTransform param f_transform
caption = "Distortion Transform"
default = NullTransform
hint = "This will apply a transformation to coordinates used to generate the distortion texture, but this transformation will not affect the underlying image. You can use this to warp only the distortion texture."
visible = (@p_fixed == 1)
endparam
TrapShape param f_trapshape
caption = "Distortion Texture"
default = DMJ_TrapShapeFBM
hint = "This is the distortion texture. You can use any trap shape here, but the most effective distortions for texturing will likely come from noise and fBm trap shapes."
visible = (@p_fixed == 1)
endparam
Transfer param f_transfer
caption = "Distortion Transfer"
default = TrapTransfer
hint = "This allows you to modify the output of the distortion texture before it is used in the distortion algorithm."
expanded = false
visible = (@p_fixed == 1)
endparam
heading
caption = "Distortion Angle"
expanded = true
endheading
int param p_fixed2
caption = "Method"
default = 0
enum = "fixed value" "object"
hint = "Chooses whether distortion angle should be a fixed value or be calculated by an object."
endparam
float param p_distortionstrength2
caption = "Distortion Angle Multiplier"
default = 90.0
hint = "This is multiplied with the object calculation to give a distortion angle in degrees."
visible = (@p_fixed2 == 1)
endparam
UserTransform param f_transform2
caption = "Distortion Transform"
default = NullTransform
hint = "This will apply a transformation to coordinates used to generate the distortion texture, but this transformation will not affect the underlying image. You can use this to warp only the distortion texture."
visible = (@p_fixed2 == 1)
endparam
TrapShape param f_trapshape2
caption = "Distortion Texture"
default = DMJ_TrapShapeFBM
hint = "This is the distortion texture. You can use any trap shape here, but the most effective distortions for texturing will likely come from noise and fBm trap shapes."
visible = (@p_fixed2 == 1)
endparam
Transfer param f_transfer2
caption = "Distortion Transfer"
default = TrapTransfer
hint = "This allows you to modify the output of the distortion texture before it is used in the distortion algorithm."
expanded = false
visible = (@p_fixed2 == 1)
endparam
}
Methods inherited from class Object |
|
DMJ_Distort
public DMJ_Distort(Generic pparent)
DMJ_Distort
public DMJ_Distort()
Init
public void Init(complex pz)
- Description copied from class:
Transform
- Set up for a sequence of values
This function will be called at the beginning of each
sequence of values (e.g. at the beginning of each fractal
orbit). It will be called even if only one value is being
transformed (e.g. a normal transformation formula). Use
this to perform any setup that is exactly the same for
each value in the sequence being transformed.
- Overrides:
Init
in class Transform
- Parameters:
pz
- the value representing the sequence; for a normal transformation formula use, this will be #pixel. In some cases this may differ from the first value passed to Iterate() if the calling code applies some other transformations.
Iterate
public complex Iterate(complex pz)
- Description copied from class:
Transform
- Transform a single point within a sequence
After a sequence has been set up with Init(), this function
will be called once for each value in the sequence. Note
that all values in the sequence must be processed in order
(they cannot be processed out of order). If the sequence
contains only one value, Init() will still be called and
then Iterate() will be called just once.
- Overrides:
Iterate
in class Transform
- Parameters:
pz
- the complex value to be transformed
- Returns:
- the transformed value