mmf
Class MMF_MixedLighting

Object
  extended by common:Generic
      extended by common:Coloring
          extended by common:DirectColoring
              extended by mmf:MMF_MixedLighting

class 
DirectColoring:MMF_MixedLighting

Intended for use with the 'Gradient_Slope' class formula.
David Makin May 2008


Ultra Fractal Source

Toggle UF Source Code Display

 class MMF_MixedLighting(common.ulb:DirectColoring) {
 ;
 ; Intended for use with the 'Gradient_Slope' class formula.<br>
 ; David Makin May 2008<br>
 ;
 public:
   ; @param pparent the parent,generally "this" for the parent, or zero
   func MMF_MixedLighting(Generic pparent)
     DirectColoring(pparent)
     fBm = new @fBm(this)
     transfbm = new @transfbm(this)
     trans = new @trans(this)
     ltrans = new @ltrans(this)
     merge = new @merge(this)
     trap = new @trap(this)
     if @perturb && @usefbm
       fBm.GlobalInit(0)
      endif
   endfunc
 
   ; @param pz the initial z value
   ; @param ppixel the location, usually #pixel
   func Init(complex pz,complex ppixel)
     if !@usefbm
       transfbm.Init(pz)
     endif
     trans.Init(pz)
     ltrans.Init(pz)
     trap.init(pz)
     if @InitfBm=="Pixel"
       fBmInit = 4.0*ppixel
     elseif @InitfBm=="Initial z"
       fBmInit = 4.0*pz
     endif
   endfunc
 
   ; @param pz the z value
   ; @return a colour
   color func Result(complex pz)
     float v = @ambient + (1.0 - @ambient)*imag(pz)
     if @mode!=1
       if @perturb
         if @InitfBm!="Colour and Light"
           if @usefbm
             v = @str*transfbm.Iterate(fBm.GetfBm(fBmInit)) \
                 + (1.0-@str)*ltrans.Iterate(v)
           else
             v = @str*transfbm.Iterate(trap.Iterate(fBmInit)) \
                 + (1.0-@str)*ltrans.Iterate(v)
           endif
         else
           if @usefbm
             v = @str*transfbm.Iterate(fBm.GetfBm(100*pz)) \
                 + (1.0-@str)*ltrans.Iterate(v)
           else
             v = @str*transfbm.Iterate(trap.Iterate(100*pz)) \
                 + (1.0-@str)*ltrans.Iterate(v)
           endif
         endif
       elseif @v_MixedLighting>0
         v = ltrans.Iterate(v)
       endif
       if @invert
         v = 1.0 - v
       endif
       if @lpos
         v = abs(v)
       endif
     endif
     if @mode<2
       float b = trans.Iterate(real(pz))
       if @pos0
         b = abs(b)
       endif
       color c = gradient(b)
       if @mode==0
         color l = @lightcol*v
         l = rgba(red(l), green(l), blue(l), @lightop)
         if @reverse
           return merge.FullMerge(l,c,@opacity)
         else
           return merge.FullMerge(c,l,@opacity)
         endif
       else
         return c
       endif
     elseif @mode==2
       color l = @lightcol*v
       return rgba(red(l), green(l), blue(l), @lightop)
     elseif @mode==3
       return gradient(0.9975*v)
     else
       float b = trans.iterate(real(pz))
 ;      if @v_MixedLighting=="1.0"
 ;        b = trans.iterate(real(#z)) ; NB. using #z here was a mistake in v1.0
 ;      endif
       if @pos
         b = abs(b)
       endif
 ;      if @v_MixedLighting!="1.0"
       if !@lrept
         if v<0.0
           v = 0.0
         elseif v>1.0
           v = 1.0
         endif
       endif
       v = v*0.99999 ; so the %1 won't wrap to 0 for 1
 ;      endif
       if !@rept
         if b<0.0
           b = 0.0
         elseif b>0.99999
           b = 0.99999
         endif
       endif
 ;      if @v_MixedLighting=="1.0"
 ;        v = 0.5 + 0.4975*v
 ;        b = 0.4975*(b%1)
 ;      else
       if (v = v%1)<0
         v = 1.0 + v
       endif
       if (b = b%1)<0
         b = 1.0 + b
       endif
       v = 0.5 + 0.4975*v
       b = 0.4975*b
 ;      endif
       if @reverse
         return merge.FullMerge(gradient(v),gradient(b),@opacity)
       else
         return merge.FullMerge(gradient(b),gradient(v),@opacity)
       endif
     endif
   endfunc
 
 private:
   DefaultColorMerge merge
   Transfer transfbm
   Transfer trans
   Transfer ltrans
   MMF_AltfBm fBm
   TrapShape trap
   complex fBmInit
 
 default:
   title = "MMF Mixed Lighting (direct)"
   heading
     text = "Intended for use with the 'MMF Gradient Slope' class formula."
   endheading
   int param v_MixedLighting
     caption = "Version (MMF Mixed Lighting)"
     enum = "1.1" "1.2"
     default = 1
     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. Version 1.2 enables the 'Light \
             transfer' when not using perturbation."
     visible = @v_MixedLighting<1
   endparam
   int param mode
     caption = "Method"
     enum = "Mixed" "Just colouring" "Lighting (greyscale)" \
            "Lighting (gradient)" "Split Palette"
     default =0
     hint = "In 'Split Palette' mode colours 0 to 199 in the palette are used \
             for the colouring and colours 200 to 399 are used for the \
             lighting allowing coloured lighting combined with the base \
             colouring. Note that this \
             mode will only work properly with 'Color Density' set to 1, \
             'Transfer Function' set to Linear and 'Gradient Offset' set to 0. \
             Also note that to avoid hard colour breaks colour 0 should be the \
             same as colour 199 if the colouring wraps and colour 200 should \
             be the same as colour 399 if the lighting wraps."
   endparam
   heading
     caption = "Combined parameters"
     visible = @mode==0 || @mode==4
   endheading
   DefaultColorMerge param merge
     caption = "Merge method"
     default = MMF_ExtendedColorMerge
     visible = @mode==0 || @mode==4
   endparam
   float param opacity
     caption = "Merge Opacity"
     default = 1.0
     visible = @mode==0 || @mode==4
   endparam
   bool param reverse
     caption = "Reverse colour and light"
     default = false
     hint = "Normally the lighting is applied as the top layer in the merge, \
             enable this to reverse the order so the colouring is the top \
             layer."
     visible = @mode==0 || @mode==4
   endparam
   heading
     caption = "Colouring parameters"
     visible = @mode<2 || @mode==4
   endheading
   Transfer param trans
     caption = "Colouring transfer"
     default = DefaultGradientTransfer
     hint = "Note that normally you should ensure that the returned value is \
             positive."
     visible = @mode<2 || @mode==4
   endparam
   bool param pos0
     caption = "Force Positive Colour"
     default = false
     hint = "When enabled the absolute value of the colour is taken."
    visible = @mode<2
   endparam
   bool param pos
     caption = "Force Positive Colour"
     default = true
     hint = "When enabled the absolute value of the colour is taken."
    visible = @mode==4
   endparam
   bool param rept
     caption = "Repeat Colouring"
     default = true
     hint = "Allows you to specify whether the colouring value should be \
             allowed to wrap around the gradient or not."
    visible = @mode==4
   endparam
   heading
     caption = "Lighting parameters"
     visible = @mode!=1
   endheading
   color param lightcol
     caption = "Light Colour"
     default = rgb(1.0, 1.0, 1.0)
     hint = "Sets the colour of the light."
     visible = @mode==0 || @mode==2
   endparam
   float param lightop
     caption = "Light Opacity"
     default = 1.0
     hint = "Sets the opacity of the light."
     visible = @mode==0 || @mode==2
   endparam
   float param ambient
     caption = "Ambient Light"
     default = 0.0
     min = -1.0
     max = 1.0
     hint = "Note that this will combine with any ambient light setting in the \
             main formula."
     visible = @mode!=1
   endparam
   bool param invert
     caption = "Invert lighting"
     default = false
     visible = @mode!=1
   endparam
   bool param perturb
     caption = "Perturb the lighting"
     default = false
     hint = "When enabled you can perturb the light values using fBm."
     visible = @mode!=1
   endparam
   int param InitfBm
     caption = "Perturbation initialisation"
     enum = "Pixel" "Initial z" "Colour and Light"
     default = 0
   endparam
   float param str
     caption = "Perturbation strength"
     default = 0.5
     min = 0.0
     max = 1.0
     hint = "Using 0.0 will produce no perturbation, using 1.0 will produce \
             fBm only as the lighting."
     visible = @mode!=1 && @perturb
   endparam
   bool param usefbm
     caption = "Use Plain Alternative fBm ?"
     default = true
     hint = "If you disable this then you'll get a choice of plug-ins."
     visible = @mode!=1 && @perturb
   endparam
   MMF_AltfBm param fBm
     caption = "Perturbation"
     default = MMF_AltfBm
     visible = @mode!=1 && @perturb && @usefbm
   endparam
   Trapshape param trap
     caption = "Perturbation"
     default = MMF_TrapShapefBm
     visible = @mode!=1 && @perturb && !@usefbm
   endparam
   Transfer param transfbm
     caption = "Perturbation transfer"
     default = NullTransfer
     hint = "Normally transfers that take a number in the range 0..1 and \
             return a number in the range 0..1 should be used."
     visible = @mode!=1 && @perturb
   endparam
   Transfer param ltrans
     caption = "Light transfer"
     default = NullTransfer
     hint = "Normally transfers that take a number in the range 0..1 and \
             return a number in the range 0..1 should be used."
     visible = @mode!=1
   endparam
   bool param lpos
     caption = "Force Positive Light"
     default = false
     hint = "When enabled the absolute value of the light is taken."
    visible = @mode!=1
   endparam
   bool param lrept
     caption = "Repeat Lighting"
     default = false
     hint = "Allows you to specify whether the lighting value should be \
             allowed to wrap around the gradient or not."
    visible = @mode==4
   endparam
 }
 


Constructor Summary
MMF_MixedLighting()
           
MMF_MixedLighting(Generic pparent)
           
 
Method Summary
 void Init(complex pz, complex ppixel)
          Set up for a sequence of values
 color Result(complex pz)
          Produce a resulting color index after a sequence is finished
 
Methods inherited from class common:DirectColoring
IsSolid, Iterate
 
Methods inherited from class common:Coloring
GetPixel, IsGradient
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

MMF_MixedLighting

public MMF_MixedLighting(Generic pparent)
Parameters:
pparent - the parent,generally "this" for the parent, or zero

MMF_MixedLighting

public MMF_MixedLighting()
Method Detail

Init

public void Init(complex pz,
                 complex ppixel)
Description copied from class: DirectColoring
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).

Overrides:
Init in class DirectColoring
Parameters:
pz - the initial z value
ppixel - the location, usually #pixel

Result

public color Result(complex pz)
Description copied from class: DirectColoring
Produce a resulting color index after a sequence is finished

This corresponds to the final: section in a coloring formula. Once it is called, no further calls to Iterate() should be made without calling Init() first.

Overrides:
Result in class DirectColoring
Parameters:
pz - the z value
Returns:
a colour