|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Generic common:Coloring common:GradientColoring mmf:MMF_SmoothOrbitTraps
class
Written by David Makin based on normal Orbit Traps by Damien Jones
Started May 2008
Note that you can use any normal trap plug-ins with this formula
but you'll only get smoothing for Trap Modes derived from
MMF_TrapModeSmooth or MMF_TrapModeSmoothWithThreshold, generally
that means Trap Modes with "Smooth" in the title such as those
in mmf.ulb.
class MMF_SmoothOrbitTraps(common.ulb:GradientColoring) { ; ; Written by David Makin based on normal Orbit Traps by Damien Jones<br> ; Started May 2008<br> ; <p> ; Note that you can use any normal trap plug-ins with this formula ; but you'll only get smoothing for Trap Modes derived from ; MMF_TrapModeSmooth or MMF_TrapModeSmoothWithThreshold, generally ; that means Trap Modes with "Smooth" in the title such as those ; in mmf.ulb.<br> ; public: import "common.ulb" import "dmj5.ulb" ; Constructor - note the inititialisation of smoothing variables<br> ; if necessary.<br> ; @param pparent the parent, generally "this" for the parent, or zero func MMF_SmoothOrbitTraps(Generic pparent) GradientColoring.GradientColoring(pparent) m_TrapSelect = new @f_trapselect(this) m_TrapTransform = new @f_traptransform(this) m_TrapShape = new @f_trapshape(this) m_TrapTransfer = new @f_traptransfer(this) m_TrapMode = new @f_trapmode(this) m_TrapTexture = new @f_traptexture(this) m_TrapColoring = new @f_trapcoloring(this) m_FinalTransfer = new @f_finaltransfer(this) m_IterTransfer = new @f_itertransfer(this) m_TrapShape.SetThreshold(@p_threshold) m_TrapMode.SetThreshold(@p_threshold) if @smoothing<3 && (@f_trapmode==MMF_TrapModeSmooth \ || @f_trapmode==MMF_TrapModeSmoothWithThreshold \ || @f_additer) il = real(1.0/log(@power)) ; for divergent smoothing lp = log(0.5*log(@bailout)) ilp = il*lp cil = real(1/log(@cpower)) ; for convergent smoothing clp = log(-0.5*log(@smallbail)) cilp = cil*clp endif if @f_trapcoloring==MMF_TrapColoring \ && @f_traptexture==DMJ_TrapShapeFlat MMF_TrapColoring(m_TrapColoring).SetTextureFlag(false) endif m_texture = 0.0 endfunc ; Initialisation (per pixel)<br> ; Standard colour Init()<br> ; This version:<p> ; Note that if the texturing is set to position only and texturing ; is enabled then the texture Iterate() function is called here.<br> ; @param pz initial z from the formula ; @param ppixel the location (normally #pixel) func Init(complex pz, complex ppixel) GradientColoring.Init(pz, ppixel) m_TrapSelectSequence = m_TrapSelect.InitDefault() m_TrapTransform.Init(pz) m_TrapShape.Init(pz) m_TrapTransfer.Init(pz) m_TrapMode.Init(pz) m_TrapTexture.Init(pz) m_FinalTransfer.Init(pz) m_IterTransfer.Init(pz) if @smoothing<3 && (@f_trapmode==MMF_TrapModeSmooth \ || @f_trapmode==MMF_TrapModeSmoothWithThreshold \ || @f_additer) m_zold = m_zolder = pz m_zolderok = m_zoldok = false endif m_notlast = true if @p_texturepositiononly && @f_traptexture!=DMJ_TrapShapeFlat m_texture = m_TrapTexture.Iterate(ppixel) endif endfunc ; <p> ; Note that the texture calculation is skipped if there's no texture ; (using DMJ_TrapShapeFlat) or texturing is position only<br> ; @param pz the z value func Iterate(complex pz) GradientColoring.Iterate(pz) if @smoothing<3 && (@f_trapmode==MMF_TrapModeSmooth \ || @f_trapmode==MMF_TrapModeSmoothWithThreshold \ || @f_additer) \ && m_notlast m_zolder = m_zold m_zold = pz m_zolderok = m_zoldok m_zoldok = true endif m_TrapSelectSequence = m_TrapSelect.Iterate(m_TrapSelectSequence) if ((@f_trapselect==DMJ_TrapSelect && m_TrapSelectSequence>0.5) \ || m_TrapSelectSequence > @p_trapselectthreshold) complex zt = m_TrapTransform.Iterate(pz) float distance = m_TrapShape.Iterate(zt) float texture = m_texture distance = m_TrapTransfer.Iterate(distance) zt = m_TrapShape.GetTransformedPoint() if @f_traptexture!=DMJ_TrapShapeFlat && !@p_texturepositiononly texture = m_TrapShape.GetTextureValue() if (@p_textureposttransform) texture = texture + m_TrapTexture.Iterate(zt) else texture = texture + m_TrapTexture.Iterate(pz) endif texture = (texture + m_TrapTexture.GetTextureValue()) \ * @p_texturestrength endif if (!m_TrapTransform.IsSolid()) m_TrapMode.Iterate(pz, zt, distance, texture) else m_TrapMode.IterateSilent() endif else if @f_TrapShape==MMF_TrapShapeZold && @f_fixzold complex zt = m_TrapTransform.Iterate(pz) MMF_TrapShapeZold(m_TrapShape).IterateSilentZold(zt) else if @f_TrapTransform==MMF_TrapTransformZold MMF_TrapTransformZold(m_TrapTransform).IterateSilentZold(pz) else m_TrapTransform.IterateSilent() endif m_TrapShape.IterateSilent() endif m_TrapTransfer.IterateSilent() m_TrapMode.IterateSilent() if @f_traptexture!=DMJ_TrapShapeFlat && !@p_texturepositiononly m_TrapTexture.IterateSilent() endif endif endfunc ; <p> ; Note that if "Process final iteration" is enabled then Iterate() ; is called first one last time using the final value of pz.<br> ; @param pz the final z value ; @return index value float func ResultIndex(complex pz) float result if @processlast m_notlast = false Iterate(pz) endif GradientColoring.ResultIndex(pz) m_TrapMode.Result() m_Solid = @p_usesolid && m_TrapMode.IsSolid() result = m_TrapColoring.Result(m_TrapMode) float f = 0.0 if @smoothing<3 && (@f_trapmode==MMF_TrapModeSmooth \ || @f_trapmode==MMF_TrapModeSmoothWithThreshold \ || @f_additer) float m if (@smoothing==0 || @smoothing==2) && |pz - m_zold|>1 \ && (m=|pz|)>=@bailout m = log(m) if @dauto && m_zoldok f = @fudge*real(lp - log(0.5*m))/log(m/log(|m_zold|)) else f = @fudge*real(ilp - il*log(0.5*m)) endif elseif (@smoothing==1 || @smoothing==2) \ && ( (|pz - m_zold|<=@smallbail && !@cfixed) \ || (|pz - @cfixedval|<=@smallbail && @cfixed) ) if @cfixed m = log(|pz - @cfixedval|) if @cauto && m_zoldok f = @fudgec*real(clp - log(-0.5*m)) \ /log(m/log(|m_zold-@cfixedval|)) else f = @fudgec*real(cilp - cil*log(-0.5*m)) endif elseif @cauto && m_zolderok m = log(|pz - m_zold|) f = @fudgec*real(clp - log(-0.5*m)) \ /log(m/log(|m_zold-m_zolder|)) elseif m_zoldok f = @fudgec*real(cilp - cil*log(-0.5*log(|pz - m_zold|))) endif endif if (@f_TrapMode==MMF_TrapModeSmooth \ || @f_trapmode==MMF_TrapModeSmoothWithThreshold) && f!=0.0 if @f_TrapMode==MMF_TrapModeSmooth MMF_TrapModeSmooth(m_TrapMode).OldResult() else MMF_TrapModeSmoothWithThreshold(m_TrapMode).OldResult() endif result = result + f*(result - m_TrapColoring.Result(m_TrapMode)) endif endif if @f_additer if @processlast return m_FinalTransfer.Iterate(result) \ + m_IterTransfer.Iterate(0.05*(m_Iterations + f)) else return m_FinalTransfer.Iterate(result) \ + m_IterTransfer.Iterate(0.05*(1.0 + m_Iterations + f)) endif else return m_FinalTransfer.Iterate(result) endif endfunc ; <p> ; Note that if "Process final iteration" is enabled then Iterate() ; is called first one last time using the final value of pz.<br> ; @param pz the final z value ; @return color value color func Result(complex pz) MMF_TrapColoring mmftc if (mmftc = MMF_TrapColoring(m_TrapColoring)) if mmftc.UseColor() float result color icol if @processlast m_notlast = false Iterate(pz) endif GradientColoring.ResultIndex(pz) m_TrapMode.Result() m_Solid = @p_usesolid && m_TrapMode.IsSolid() icol = mmftc.ResultColor(m_TrapMode) result = mmftc.ResultTexture(m_TrapMode) float f = 0.0 if @smoothing<3 && (@f_trapmode==MMF_TrapModeSmooth \ || @f_trapmode==MMF_TrapModeSmoothWithThreshold \ || @f_additer) float m if (@smoothing==0 || @smoothing==2) && |pz - m_zold|>1 \ && (m=|pz|)>=@bailout m = log(m) if @dauto && m_zoldok f = @fudge*real(lp - log(0.5*m))/log(m/log(|m_zold|)) else f = @fudge*real(ilp - il*log(0.5*m)) endif elseif (@smoothing==1 || @smoothing==2) \ && ( (|pz - m_zold|<=@smallbail && !@cfixed) \ || (|pz - @cfixedval|<=@smallbail && @cfixed) ) if @cfixed m = log(|pz - @cfixedval|) if @cauto && m_zoldok f = @fudgec*real(clp - log(-0.5*m)) \ /log(m/log(|m_zold-@cfixedval|)) else f = @fudgec*real(cilp - cil*log(-0.5*m)) endif elseif @cauto && m_zolderok m = log(|pz - m_zold|) f = @fudgec*real(clp - log(-0.5*m)) \ /log(m/log(|m_zold-m_zolder|)) elseif m_zoldok f = @fudgec*real(cilp - cil*log(-0.5*log(|pz - m_zold|))) endif endif if (@f_TrapMode==MMF_TrapModeSmooth \ || @f_trapmode==MMF_TrapModeSmoothWithThreshold) && f!=0.0 if @f_TrapMode==MMF_TrapModeSmooth MMF_TrapModeSmooth(m_TrapMode).OldResult() else MMF_TrapModeSmoothWithThreshold(m_TrapMode).OldResult() endif icol = icol + (icol - mmftc.ResultColor(m_TrapMode))*f result = result + f*(result - mmftc.ResultTexture(m_TrapMode)) endif endif if @f_additer if @f_traptexture==DMJ_TrapShapeFlat mmftc.SetTextureFlag(true) if @processlast result = m_IterTransfer.Iterate(0.05*(m_Iterations + f)) else result = m_IterTransfer.Iterate(0.05*(1.0 + m_Iterations + f)) endif elseif @processlast result = m_FinalTransfer.Iterate(result) \ + m_IterTransfer.Iterate(0.05*(m_Iterations + f)) else result = m_FinalTransfer.Iterate(result) \ + m_IterTransfer.Iterate(0.05*(1.0 + m_Iterations + f)) endif else result = m_FinalTransfer.Iterate(result) endif icol = mmftc.MergeResult(icol,result) if @smoothing<3 && @f_traptexture==DMJ_TrapShapeFlat && @f_additer mmftc.SetTextureFlag(false) endif return icol endif endif return gradient(ResultIndex(pz)) endfunc protected: Generator m_TrapSelect UserTransform m_TrapTransform TrapShape m_TrapShape Transfer m_TrapTransfer TrapMode m_TrapMode TrapShape m_TrapTexture TrapColoring m_TrapColoring Transfer m_FinalTransfer Transfer m_IterTransfer float m_texture float m_TrapSelectSequence private: complex m_zold complex m_zolder float il ; for divergent smoothing float lp float ilp float cil ; for convergent smoothing float clp float cilp bool m_zoldok bool m_zolderok bool m_notlast default: title = "MMF Smooth Orbit Traps (Gradient)" rating = recommended int param v_mmfsmoothorbittraps caption = "Version (MMF Smooth Orbit Traps)" enum = "1.0" default = 0 hint = "This field is to absolutely ensure backward compatibility, \ the default will always be set to the latest version, but \ there may be some cases where an older effect that you like \ is lost in an update and you could still use it by selecting \ the older version number." visible = false endparam heading caption = "Information" text = "Note that you can use any normal trap plug-ins with \ this colouring but you'll only get smoothing for Trap \ Modes written for it - generally trap modes with 'Smooth' \ in the title, e.g. in mmf.ulb. \ This colouring class is mainly intended for \ use on 'outside' areas, i.e. areas where bailout occurs, \ but for some of the mmf.ulb trap shapes it is required \ for 'inside' areas in preference to standard orbit trap \ formulas. If used 'inside' then it's best to select \ 'Neither' as the 'Smoothing method' and not to enable \ 'Process final iteration'. Note that when not wanting \ any texturing you should always set 'Trap Texture' to \ dmj5.ulb->Flat Texture." endheading heading caption = "Smoothing parameters" endheading int param smoothing caption = "Smoothing method" enum = "Divergent" "Convergent" "Both" "Neither" default = 0 hint = "Choose the smoothing that matches your main formula type \ e.g. 'Divergent' for z^2+c, 'Convergent' for Newton, \ 'Both' for Magnet formulas. If using this colouring for \ 'inside' areas then it's best to select 'Neither'." endparam heading text = "Divergent Smoothing parameters" visible = @smoothing==0 || @smoothing==2 endheading float param bailout caption = "Bailout" default = 128.0 hint = "This should match the bailout in the fractal formula." visible = @smoothing==0 || @smoothing==2 endparam bool param dauto caption = "Auto-power" default = true hint = "When enabled should produce smoothing for most divergent \ areas without you needing to set the divergent power value \ for the colouring." visible = @smoothing==0 || @smoothing==2 endparam complex param power caption = "Power/exponent/degree" default = (2,0) hint = "This should match the power/degree/exponent in the \ fractal formula. When using 'Auto-power' it's only used \ for areas that bailed on the first or second iteration." visible = @smoothing==0 || @smoothing==2 endparam float param fudge caption = "Scaling fudge" default = 1.0 hint = "This is a scaling fudge value, it's used to scale \ the calculated iteration fraction when the value \ doesn't reach 1, it's unlikely to be required for \ divergent smoothing but I added it just in case. If \ 'Auto-power' or the best value you can find for \ the power parameter don't produce smooth results then \ modifying this value may help." visible = @smoothing==0 || @smoothing==2 endparam heading text = "Convergent Smoothing parameters" visible = @smoothing==1 || @smoothing==2 endheading float param smallbail caption = "Bailout" default = 1e-5 hint = "This should match the small bailout in your fractal formula." visible = @smoothing==1 || @smoothing==2 endparam bool param cauto caption = "Auto-power" default = true hint = "When enabled should produce smoothing for most convergent \ areas without you needing to set a convergent power value \ for the colouring." visible = @smoothing==1 || @smoothing==2 endparam complex param cpower caption = "Power/exponent/degree" default = (2,0) hint = "This should match the power (exponent/degree) for the \ convergent areas of your main fractal formula. When \ using 'Auto-power' it's only used for areas that bailed \ on the first or second iteration." visible = @smoothing==1 || @smoothing==2 endparam float param fudgec caption = "Scaling Fudge" default = 1.0 hint = "This is a scaling fudge value, it's used to scale \ the calculated iteration fraction when the value \ doesn't reach 1. If 'Auto-power' or the best value you can \ find for the 'Convergent Power' parameter don't \ produce smooth results then modifying this value \ should help." visible = @smoothing==1 || @smoothing==2 endparam bool param cfixed caption = "Absolute convergence" default = false hint = "For when using a main formula that tests for convergence by \ using (only) |#z-value| rather than |#z-zold|, a typical \ example would be a Magnet formula where |#z-1.0| is often \ used. When enabled set the value of 'Convergence root' \ appropriately." visible = @smoothing==1 || @smoothing==2 endparam complex param cfixedval caption = "Convergence root" default = (1,0) hint = "Use (1.0,0) for some Magnet formulas." visible = (@smoothing==1 || @smoothing==2) && @cfixed endparam heading caption = "Trapping parameters" endheading bool param processlast caption = "Process final iteration" default = true hint = "When enabled then the final (bailed out) value of z is \ trapped in addition to the previous values. Should not \ be enabled if colouring 'inside'." endparam Generator param f_trapselect caption = "Trap Iteration" default = DMJ_TrapSelect expanded = false endparam float param p_trapselectthreshold caption = "Threshold" default = 0.5 hint = "When using a Generator other than a TrapSelect type, values \ could range anywhere from 0 to 1. This threshold sets which \ values will be interpreted as 'do not trap' and which will be \ interpreted as 'trap'." visible = (@f_trapselect != DMJ_TrapSelect) endparam UserTransform param f_traptransform caption = "Trap Position" default = TrapTransform hint = "This transform is commonly used to set the position of the \ trap. You can load any Transform object here, but if you \ replace the TrapTransform you will lose the ability to \ position the trap. To regain that ability, use the \ TransformMerge class here so you can load any Transform \ and still be able to use a TrapTransform object." expanded = false endparam TrapShape param f_trapshape caption = "Trap Shape" default = MMF_TrapShapeTriangleInequality hint = "The trap shape sets the overall shape of the trap. Its only \ task is to measure the distance from any point to the trap \ shape." endparam bool param f_fixzold caption = "Fix zold ?" default = true hint = "When enabled this improves the functionality of your trap \ shape when skipping iterations but can cause problems when \ combined with some Trap Positions so you may disable it if \ necessary." visible = @f_TrapShape==MMF_TrapShapeZold endparam Transfer param f_traptransfer caption = "Trap Transfer" default = TrapTransfer hint = "A transfer allows you to manipulate the distances provided \ by the trap shape." expanded = false endparam TrapMode param f_trapmode caption = "Trap Mode" default = MMF_TrapModeSmoothAverage endparam heading text = "Warning - The currently selected Trap Mode will not be \ smoothed. You should use a Trap Mode with 'Smooth' in the \ title." visible = @f_trapmode!=MMF_TrapModeSmooth \ && @f_trapmode!=MMF_TrapModeSmoothWithThreshold endheading float param p_threshold caption = "Trap Threshold" default = 1.0 hint = "This is the overall size or thickness of the trap area. \ (Some trap modes may not use the threshold value.)" visible = (@f_trapmode == TrapModeWithThreshold) endparam bool param p_usesolid caption = "Use Solid Color" default = false hint = "If checked, any areas not inside any trap shape will be \ colored using the solid color." endparam TrapShape param f_traptexture caption = "Trap Texture" default = DMJ_TrapShapeFlat hint = "A trap shape that is used as a texture. Textures do not \ change the shape of the trap but may change its coloring." endparam bool param p_texturepositiononly caption = "Texture from location only" default = false hint = "When enabled the texturing is based on the location. \ This is equivalent to basing the texture on #pixel. \ The rendering time is reduced \ considerably when this is enabled. Note that when \ used the texture density will be completely \ independant of the trap shape but may still change \ depending on the trap mode." visible = @f_traptexture!=DMJ_TrapShapeFlat endparam bool param p_textureposttransform caption = "Use Transformed Coordinate" default = false hint = "If checked, texturing will be based on the final transformed \ coordinate used in the trap shape (i.e. it will follow the \ trap shape, rather than being separate from it)." visible = (@f_traptexture != DMJ_TrapShapeFlat) \ && !@p_texturepositiononly endparam float param p_texturestrength caption = "Texture Amount" default = 1.0 hint = "Sets the overall amount of texture to be used. Larger \ numbers will increase the effect of the texture. A value \ of 0 will remove the effects of the texture." visible = (@f_traptexture != DMJ_TrapShapeFlat) \ && !@p_texturepositiononly endparam TrapColoring param f_trapcoloring caption = "Trap Color Mode" default = MMF_TrapColoring endparam Transfer param f_finaltransfer caption = "Final Transfer" default = MMF_TrapTransfer hint = "Allows you to manipulate the final combined value of \ the trap colour and the texturing." endparam param f_additer caption = "Add the smooth iteration count" default = false endparam Transfer param f_itertransfer caption = "Iteration Transfer" default = MMF_TrapTransfer hint = "Allows you to manipulate the final combined value of \ the trap colour and the texturing." visible = @f_additer endparam }
Constructor Summary | |
---|---|
MMF_SmoothOrbitTraps()
|
|
MMF_SmoothOrbitTraps(Generic pparent)
Constructor - note the inititialisation of smoothing variables if necessary. |
Method Summary | |
---|---|
void |
Init(complex pz,
complex ppixel)
Initialisation (per pixel) Standard colour Init() This version: |
void |
Iterate(complex pz)
Note that the texture calculation is skipped if there's no texture (using DMJ_TrapShapeFlat) or texturing is position only |
color |
Result(complex pz)
Note that if "Process final iteration" is enabled then Iterate() is called first one last time using the final value of pz. |
float |
ResultIndex(complex pz)
Note that if "Process final iteration" is enabled then Iterate() is called first one last time using the final value of pz. |
Methods inherited from class common:GradientColoring |
---|
IsGradient, IsSolid |
Methods inherited from class common:Coloring |
---|
GetPixel |
Methods inherited from class common:Generic |
---|
GetParent |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public MMF_SmoothOrbitTraps(Generic pparent)
pparent
- the parent, generally "this" for the parent, or zeropublic MMF_SmoothOrbitTraps()
Method Detail |
---|
public void Init(complex pz, complex ppixel)
Note that if the texturing is set to position only and texturing
is enabled then the texture Iterate() function is called here.
Init
in class GradientColoring
pz
- initial z from the formulappixel
- the location (normally #pixel)public void Iterate(complex pz)
Note that the texture calculation is skipped if there's no texture
(using DMJ_TrapShapeFlat) or texturing is position only
Iterate
in class GradientColoring
pz
- the z valuepublic float ResultIndex(complex pz)
Note that if "Process final iteration" is enabled then Iterate()
is called first one last time using the final value of pz.
ResultIndex
in class GradientColoring
pz
- the final z value
public color Result(complex pz)
Note that if "Process final iteration" is enabled then Iterate()
is called first one last time using the final value of pz.
Result
in class GradientColoring
pz
- the final z value
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |