mmf
Class MMF_AltfBm

Object
  extended by common:Generic
      extended by mmf:MMF_AltfBm

class 
Generic:MMF_AltfBm

This is an fBm texture class. It simply has an an init for the internal texturing variable set-up and a function to return the texture value (float) for a given complex value.


Ultra Fractal Source

Toggle UF Source Code Display

 class MMF_AltfBm(common.ulb:Generic) {
 ; This is an fBm texture class. It simply has an an init for the
 ; internal texturing variable set-up and a function to return the
 ; texture value (float) for a given complex value.<br>
 public:
   ; @param pparent the parent, generally "this" for the parent, or zero
   func MMF_AltfBm(Generic pparent)
     Generic.Generic(pparent)
   endfunc
 
 ; Initialisation of the texture variables.<p>
 ; This is designed to be called once per change of texture, so normally
 ; just once say in a global section or in a constructor but it could be
 ; recalled if initiators were included in the class that could be set up
 ; in the constructor and modified later - allowing reconfiguration of the fBm.
 ; <p>The initialisation is done here (in it's own function) instead of in the
 ; constructor mainly so that it's possible to avoid the init when texturing
 ; is disabled at run time e.g.<br>
 ; if @fBm<br>
 ;   GlobalInit(value)<br>
 ; endif<p>
 ; Here pz is actually unused but is included in case derived functions
 ; want to initiate based on an external value.<br>
 ; @param pz a complex value for initialisation of the fBm
   func GlobalInit(complex pz)
     float d=#pi/180.0          ; for conversion to radians
     float c=4096.0*@rs         ; overall frequency
 
 ; fBm level 1
 
     float ang=@ang0*d        ; convert rotation to rads
 
 ; q[level,0] and q[level,1] are the scaling factors for the
 ; x+y and x-y arrays, the "correct" value should be the same
 ; for both (ie. 1/sqrt(2)) but to increase variation the
 ; values used are in the neighbourhood of 0.7071, being n/8192
 ; where n is a prime number.
 
     q[0,0]=5471.0/8192.0
     q[0,1]=6143.0/8192.0
 
 ; The rotation values
 
     q[0,2]=cos(ang)
     q[0,3]=sin(ang)
 
 ; Combine the overall sharpness and frequency with the
 ; sharpness and frequency for this level.
 
     q[0,4]=@frac0*@frac
     q[0,5]=c*@rs0
 
 ; Put the amplitude in the array so it can be indexed
 
     q[0,6]=@amp0
 
 ; Put the enabled flag in an array so it can be indexed
 
     f[0]=@flag0
 
 ; fBm level 2 (Note slightly different values q[1,0] and q[1,1])
 
     ang=@ang1*d
     q[1,0]=6079.0/8192.0
     q[1,1]=5521.0/8192.0
     q[1,2]=cos(ang)
     q[1,3]=sin(ang)
     q[1,4]=@frac1*@frac
     q[1,5]=c*@rs1
     q[1,6]=@amp1
     f[1]=@flag1
 
 ; fBm level 3
 
     ang=@ang2*d
     q[2,0]=5501.0/8192.0
     q[2,1]=6113.0/8192.0
     q[2,2]=cos(ang)
     q[2,3]=sin(ang)
     q[2,4]=@frac2*@frac
     q[2,5]=c*@rs2
     q[2,6]=@amp2
     f[2]=@flag2
 
 ; fBm level 4
 
     ang=@ang3*d
     q[3,0]=6047.0/8192.0
     q[3,1]=5563.0/8192.0
     q[3,2]=cos(ang)
     q[3,3]=sin(ang)
     q[3,4]=@frac3*@frac
     q[3,5]=c*@rs3
     q[3,6]=@amp3
     f[3]=@flag3
 
 ; fBm level 5
 
     ang=@ang4*d
     q[4,0]=5507.0/8192.0
     q[4,1]=6091.0/8192.0
     q[4,2]=cos(ang)
     q[4,3]=sin(ang)
     q[4,4]=@frac4*@frac
     q[4,5]=c*@rs4
     q[4,6]=@amp4
     f[4]=@flag4
 
 ; fBm level 6
 
     ang=@ang5*d
     q[5,0]=6037.0/8192.0
     q[5,1]=5573.0/8192.0
     q[5,2]=cos(ang)
     q[5,3]=sin(ang)
     q[5,4]=@frac5*@frac
     q[5,5]=c*@rs5
     q[5,6]=@amp5
     f[5]=@flag5
 
 ; fBm level 7
 
     ang=@ang6*d
     q[6,0]=5531.0/8192.0
     q[6,1]=6067.0/8192.0
     q[6,2]=cos(ang)
     q[6,3]=sin(ang)
     q[6,4]=@frac6*@frac
     q[6,5]=c*@rs6
     q[6,6]=@amp6
     f[6]=@flag6
 
 ; fBm level 8
 
     ang=@ang7*d
     q[7,0]=6131.0/8192.0
     q[7,1]=5479.0/8192.0
     q[7,2]=cos(ang)
     q[7,3]=sin(ang)
     q[7,4]=@frac7*@frac
     q[7,5]=c*@rs7
     q[7,6]=@amp7
     f[7]=@flag7
 
 ; fBm level 9
 
     ang=@ang8*d
     q[8,0]=5503.0/8192.0
     q[8,1]=6101.0/8192.0
     q[8,2]=cos(ang)
     q[8,3]=sin(ang)
     q[8,4]=@frac8*@frac
     q[8,5]=c*@rs8
     q[8,6]=@amp8
     f[8]=@flag8
 
 ; fBm level 10
 
     ang=@ang9*d
     q[9,0]=6133.0/8192.0
     q[9,1]=5477.0/8192.0
     q[9,2]=cos(ang)
     q[9,3]=sin(ang)
     q[9,4]=@frac9*@frac
     q[9,5]=c*@rs9
     q[9,6]=@amp9
     f[9]=@flag9
 
 ; fBm level 11
 
     ang=@ang10*d
     q[10,0]=5557.0/8192.0
     q[10,1]=6053.0/8192.0
     q[10,2]=cos(ang)
     q[10,3]=sin(ang)
     q[10,4]=@frac10*@frac
     q[10,5]=c*@rs10
     q[10,6]=@amp10
     f[10]=@flag10
 
 ; fBm level 12
 
     ang=@ang11*d
     q[11,0]=6029.0/8192.0
     q[11,1]=5581.0/8192.0
     q[11,2]=cos(ang)
     q[11,3]=sin(ang)
     q[11,4]=@frac11*@frac
     q[11,5]=c*@rs11
     q[11,6]=@amp11
     f[11]=@flag11
 
 ; fBm level 13
 
     ang=@ang12*d
     q[12,0]=5527.0/8192.0
     q[12,1]=6073.0/8192.0
     q[12,2]=cos(ang)
     q[12,3]=sin(ang)
     q[12,4]=@frac12*@frac
     q[12,5]=c*@rs12
     q[12,6]=@amp12
     f[12]=@flag12
 
 ; fBm level 14
 
     ang=@ang13*d
     q[13,0]=6121.0/8192.0
     q[13,1]=5483.0/8192.0
     q[13,2]=cos(ang)
     q[13,3]=sin(ang)
     q[13,4]=@frac13*@frac
     q[13,5]=c*@rs13
     q[13,6]=@amp13
     f[13]=@flag13
 
 ; fBm level 15
 
     ang=@ang14*d
     q[14,0]=5569.0/8192.0
     q[14,1]=6043.0/8192.0
     q[14,2]=cos(ang)
     q[14,3]=sin(ang)
     q[14,4]=@frac14*@frac
     q[14,5]=c*@rs14
     q[14,6]=@amp14
     f[14]=@flag14
 
 ; fBm level 16
 
     ang=@ang15*d
     q[15,0]=6089.0/8192.0
     q[15,1]=5519.0/8192.0
     q[15,2]=cos(ang)
     q[15,3]=sin(ang)
     q[15,4]=@frac15*@frac
     q[15,5]=c*@rs15
     q[15,6]=@amp15
     f[15]=@flag15
 
 ; Now initialise the height arrays ready for fBm creation.
 
     int r=@seed              ; initialise the random variable
     float r1=r
     int l=0                  ; level count
     int step=16384           ; initially assume all fBm
 
     while l<@levels
       int i=0
       while i<4
         h[l,i,0]=0                            ; set entry 0 to 0
         h[l,i,16384]=0                        ; and entry 16384
 
 ; If using Div 2, Div 4 or Div 8 initialise further array
 ; entries and adjust the binary step to be used later
 ; accordingly.
 
         if @mode>0
           h[l,i,8192]=0
           step=8192
           if @mode>1
             r=random(r)
             h[l,i,4096]=r/#randomrange
             r=random(r)
             h[l,i,12288]=r/#randomrange
             step=4096
             if @mode>2
               r=random(r)
               h[l,i,2048]=r/#randomrange
               r=random(r)
               h[l,i,6144]=r/#randomrange
               r=random(r)
               h[l,i,10240]=r/#randomrange
               r=random(r)
               h[l,i,14336]=r/#randomrange
               step=2048
               if @mode>3
                 r=random(r)
                 h[l,i,1024]=r/#randomrange
                 r=random(r)
                 h[l,i,3072]=r/#randomrange
                 r=random(r)
                 h[l,i,5120]=r/#randomrange
                 r=random(r)
                 h[l,i,7168]=r/#randomrange
                 r=random(r)
                 h[l,i,9216]=r/#randomrange
                 r=random(r)
                 h[l,i,11264]=r/#randomrange
                 r=random(r)
                 h[l,i,13312]=r/#randomrange
                 r=random(r)
                 h[l,i,15360]=r/#randomrange
                 step=1024
               endif
             endif
           endif
         endif
         i=i+1
       endwhile
       l=l+1
     endwhile
 
 ; Now calculate the number of extra (dummy) dice rolls to use
 ; (The dummy rolls mean the shape of the fBm will not change
 ; in great jumps as the number of dice used is changed -
 ; provided @dice is <= @dummy)
 
     int nd=0
     if @dummy>0
       nd=@dummy-ceil(@dice)
       if (nd<0 && (!@morph))||(nd<-1 && @morph)
         $define DEBUG
         print("Not enough dummy rolls")
         $undef DEBUG
         nd=0
       endif
     endif
 
 ; Now proceed with the actual fBm creation
 
     l=0
     float th=0                    ; For the "Total height"
     while l<@levels
       i=0
       while i<4
         float rs=1.0              ; Initial fBm scale factor
         int s=step                ; initial step
         float mx=0                ; for the maximum
         float mn=0                ; for the minimum
         while s>1                 ; we've finished when s=1
           int o=floor(s/2)        ; offset is s/2
           int p=o                 ; start index
           while p<16384
 
 ; Now roll up the next random
 
             if @morph
               float nr=@dice
               if nr<=@dummy
                 while nr>=1
                   r=random(r)
                   nr=nr-1
                 endwhile
                 r1=r
                 if nr>0
                   r=random(r)
                   r1=(1-nr)*r1+nr*r
                 endif
               else
                 r=random(r)
                 r1=r
                 nr=nr-1
                 while nr>=1
                   r=random(r)
                   nr=nr-1
                 endwhile
                 r1=nr*r1+(1-nr)*r
               endif
             else
               r1=0
               float nr=@dice
               while nr>=1
                 r=random(r)
                 r1=r1+r/#randomrange
                 nr=nr-1
               endwhile
               if nr>0
                 r=random(r)
                 r1=r1+nr*r/#randomrange
               endif
               r1=r1/@dice
             endif
 
 ; Do any dummy rolls
 
             int n=nd
             while n>0
               r=random(r)
               n=n-1
             endwhile
 
 ; Height = (previous+next)/2 + random*scale factor
 ; or cubic interpolation + random*scale factor
 
             if @average==0
               h[l,i,p]=(h[l,i,p-o]+h[l,i,p+o])/2+rs*r1
             else
               int w=(p-o-s)%16384
               if w<0
                 w=w+16384
               endif
               float hh0=h[l,i,w]
               float hh1=h[l,i,p-o]
               float hh2=h[l,i,p+o]
               w=(p+o+s)%16384
               float hh3=h[l,i,w]
               h[l,i,p]=(5*(hh1+hh2)-(hh0+hh3))/8+rs*r1
             endif
 
 ; Check for max and min
 
             if h[l,i,p]>mx
               mx=h[l,i,p]
             endif
             if h[l,i,p]<mn
               mn=h[l,i,p]
             endif
 
 ; Next position
 
             p=p+s
           endwhile
 
 ; Now modify the scale factor
 
           rs=rs*q[l,4]
 
 ; Next binary step
 
           s=floor(s/2)
         endwhile
 
 ; Now adjust the array so the minimum height is zero and the
 ; maximum is set to the amplitude for the fBm level.
 
         s=0
         while s<16384
           h[l,i,s]=((h[l,i,s]-mn)*q[l,6]/(mx-mn))^@exp
           s=s+1
         endwhile
         i=i+1
       endwhile
 
 ; Now sum the total height value (if this level is enabled)
 
       if f[l]
         th=th+4*q[l,6]^@exp
       endif
       l=l+1
     endwhile
 
 ; Now adjust all heights according to the total height (th)
 ; to attempt to keep the fBm amplitude fairly constant no
 ; matter the number of layers, and finally duplicate heights
 ; 0, 1 and 2 at positions 16384, 16385 and 16386
 
     l=0
     while l<@levels
       if f[l]
         i=0
         while i<4
           s=0
           while s<16384
             h[l,i,s]=h[l,i,s]/th
             s=s+1
           endwhile
           s=0
           while s<3
             h[l,i,s+16384]=h[l,i,s]
             s=s+1
           endwhile
           i=i+1
         endwhile
       endif
       l=l+1
     endwhile
 
   endfunc
 
 ; GetfBm is the function that returns a texture value (float) based
 ; on a given complex number. Note that in this particular class the values
 ; returned are restricted to the range 0....1 but this should not be relied
 ; on with derived classes so the returned value should normally then be
 ; processed with a transform.
 ; @param pz the z value for which to get an fBm value
   float func GetfBm(complex pz)
     float v=0
     int lvl=0
     while lvl<@levels
       if f[lvl]
 
 ; Scale z by the frequency
 
         complex z=pz*q[lvl,5]
 
 ; Rotate
 
         float x=real(z)*q[lvl,2]-imag(z)*q[lvl,3]
         float y=imag(z)*q[lvl,2]+real(z)*q[lvl,3]
 
 ; Scale x+y and x-y
 
         float xpy=(x+y)*q[lvl,0]
         float xmy=(x-y)*q[lvl,1]
 
 ; Convert to (float) indexes
 
         x=x%16384
         y=y%16384
         xpy=xpy%16384
         xmy=xmy%16384
 
 ; Convert to indexes
 
         int ix=floor(x)
         int iy=floor(y)
         int ixpy=floor(xpy)
         int ixmy=floor(xmy)
 
 ; Convert x, y, xpy and xmy to fractions
 
         x=x-ix
         y=y-iy
         xpy=xpy-ixpy
         xmy=xmy-ixmy
 
 ; Linear or cubic interpolation
 
         if @inter==0
 
 ; The indexes could be -
 
           if ix<0
             ix=16384+ix
           endif
           if iy<0
             iy=16384+iy
           endif
           if ixpy<0
             ixpy=16384+ixpy
           endif
           if ixmy<0
             ixmy=16384+ixmy
           endif
 
 ; Linear interpolation
 
           v=v + h[lvl,0,ix]+(h[lvl,0,ix+1]-h[lvl,0,ix])*x \
               + h[lvl,1,iy]+(h[lvl,1,iy+1]-h[lvl,1,iy])*y \
               + h[lvl,2,ixpy]+(h[lvl,2,ixpy+1]-h[lvl,2,ixpy])*xpy \
               + h[lvl,3,ixmy]+(h[lvl,3,ixmy+1]-h[lvl,3,ixmy])*xmy
 
         else
 
 ; n-1 as we require the height at index-1 for cubic interpolation.
 
           ix=ix-1
           while ix<0
             ix=16384+ix
           endwhile
           iy=iy-1
           while iy<0
             iy=16384+iy
           endwhile
           ixpy=ixpy-1
           while ixpy<0
             ixpy=16384+ixpy
           endwhile
           ixmy=ixmy-1
           while ixmy<0
             ixmy=16384+ixmy
           endwhile
 
 ; Cubic interpolation
 
           float h0=h[lvl,0,ix]
           float h1=h[lvl,0,ix+1]
           float h2=h[lvl,0,ix+2]
           float h3=h[lvl,0,ix+3]
           v=v+(h3-h2+h1-h0)*x^3+(2*(h0-h1)+h2-h3)*x^2+(h2-h0)*x+h1
           h0=h[lvl,1,iy]
           h1=h[lvl,1,iy+1]
           h2=h[lvl,1,iy+2]
           h3=h[lvl,1,iy+3]
           v=v+(h3-h2+h1-h0)*y^3+(2*(h0-h1)+h2-h3)*y^2+(h2-h0)*y+h1
           h0=h[lvl,2,ixpy]
           h1=h[lvl,2,ixpy+1]
           h2=h[lvl,2,ixpy+2]
           h3=h[lvl,2,ixpy+3]
           v=v+(h3-h2+h1-h0)*xpy^3+(2*(h0-h1)+h2-h3)*xpy^2+(h2-h0)*xpy+h1
           h0=h[lvl,3,ixmy]
           h1=h[lvl,3,ixmy+1]
           h2=h[lvl,3,ixmy+2]
           h3=h[lvl,3,ixmy+3]
           v=v+(h3-h2+h1-h0)*xmy^3+(2*(h0-h1)+h2-h3)*xmy^2+(h2-h0)*xmy+h1
         endif
       endif
       lvl=lvl+1
     endwhile
 
 ;          if vx<0.5
 ;            vx = 0.5*((2.0*lx)^2.0)
 ;          else
 ;            vx = 0.5+0.5*((2.0*(lx-0.5))^0.5)
 ;          endif
     if @gamma
       if v<@mid
         v = @mid*(v/@mid)^@lowp
       else
         v = @mid + (1.0-@mid)*((v-@mid)/(1.0-@mid))^@highp
       endif
     endif
 
     return v*@mainamp
 
   endfunc
 
 private:
 ; 4 linear arrays are used per level of fBm.
 ; N/S, E/W, NE/SW and NW/SE (ie. x, y, x+y and x-y)
 ; Each linear height array is 16384 in size, but defined as
 ; 16387 to repeat 3 points so they can be indexed without
 ; needing to use n%16384.
 
   float h[@levels,4,16387]
 
 ; Arrays for the fBm level data
 
   float q[16,7]            ; various
   bool f[16]               ; "enabled" flags
 
 default:
   title = "MMF Alternative fBm"
   int param v_mmfaltfbm
     caption = "Version (MMF Alternative fBm)"
     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 = "Main fBm options"
   endheading
   int param mode
     caption = "Method"
     enum = "Normal" "Div 2" "Div 4" "Div 8" "Div 16"
     default = 4
   endparam
   int param seed
     caption = "Seed"
     default = 123456
     hint = "The seed for the random, change for different patterns."
   endparam
   float param rs
     caption = "Overall Frequency"
     default = 1.0
     min = 1e-5
     hint = "Controls the scale of the patterns."
   endparam
   float param frac
     caption = "Overall Sharpness"
     default = 0.7071
     min = 1e-5
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results, if the result of multiplying \
             this value by the sharpness for a given layer is >=1 then \
             that layer will effectively be completely random."
   endparam
   float param mainamp
     caption = "Overall Amplitude"
     default = 1.0
     hint = "Adjust to modify the amplitude of the fBm."
   endparam
   heading
     caption = "Advanced fBm options"
     expanded = false
   endheading
   int param average
     caption = "Averaging"
     enum = "Normal" "Cubic"
     default = 0
     hint = "Using Cubic is a bit slower but tends to produce \
             slightly smoother results."
   endparam
   int param inter
     caption = "Interpolation"
     enum = "Linear" "Cubic"
     default = 0
     hint = "Cubic is probably just overkill only really needed \
             when at high magnification."
   endparam
   float param dice
     caption = "#Dice to use"
     default = 1.0
     min = 1.0
     max = 64.0
     hint = "Changing the number of dice used will affect the \
             character of the fBm."
   endparam
   int param dummy
     caption = "#Dice to roll"
     default = 0
     min = 0
     max = 65
     hint = "Anything greater than #Dice to use forces the \
             total dice rolled whether they are all used or \
             not. This means gradual changes to #Dice to use \
             will produce gradual changes in the fBm provided \
             #Dice to use stays <= #Dice to roll."
   endparam
   bool param morph
     caption = "Morphing"
     default = false
     hint = "When enabled, eg. if the #Dice to use is 2.3 then the \
             1st dice roll is ignored, the second and third dice rolls \
             are mixed - 0.7*second + 0.3*third - this allows true \
             morphing of the fBm from one state to the next, provided \
             #Dice to roll + 1 > #Dice to use."
   endparam
   float param exp
     caption = "Exponent"
     default = 1.0
     hint = "Changes the nature of the fBm."
   endparam
   bool param gamma
     caption = "Apply double gamma"
     default = false
   endparam
   float param mid
     caption = "Gamma midpoint"
     default = 0.5
     min = 0.0
     max = 1.0
     hint = "Normally values below the midpoint will be accented towards zero \
             and values above the midpoint will be accented towards 1."
     visible = @gamma
   endparam
   float param lowp
     caption = "Dark power"
     default = 1.5
     min = 0.0
     hint = "Using values >1.0 will accent the darker values towards zero, \
             using values <1.0 will accent the darker values towards the \
             'Gamma midpoint'."
     visible = @gamma
   endparam
   float param highp
     caption = "Light power"
     default = 0.66666666667
     min = 0.0
     hint = "Using values <1.0 will accent the lighter values towards 1, \
             using values >1.0 will accent the lighter values towards the \
             'Gamma midpoint'."
     visible = @gamma
   endparam
   int param levels
     caption = "Number of levels"
     default = 8
     min = 1
     max = 16
     hint = "The number of levels of fBm to mix."
   endparam
   bool param showmaps
     caption = "Show fBm levels"
     default = false
   endparam
   heading
     caption = "fBm level 1"
     visible = @showmaps
   endheading
   bool param flag0
     caption = "Level 1 status"
     default = true
     hint = "Use to enable/disable fBm level 1."
     visible = @showmaps
   endparam
   float param frac0
     caption = "Sharpness #1"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && @flag0
   endparam
   float param rs0
     caption = "Frequency #1"
     default = 1.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && @flag0
   endparam
   float param amp0
     caption = "Amplitude #1"
     default = 1.0
     min = 0
     hint = "Controls the relative effect of fBm level #1."
     visible = @showmaps && @flag0
   endparam
   float param ang0
     caption = "Rotation #1 (degrees)"
     default = 0.0
     hint = "Rotates the pattern."
     visible = @showmaps && @flag0
   endparam
   heading
     caption = "fBm level 2"
     visible = @showmaps && (@levels>1)
   endheading
   bool param flag1
     caption = "Level 2 status"
     default = true
     hint = "Use to enable/disable fBm level 2."
     visible = @showmaps && (@levels>1)
   endparam
   float param frac1
     caption = "Sharpness #2"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>1) && @flag1
   endparam
   float param rs1
     caption = "Frequency #2"
     default = 1.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>1) && @flag1
   endparam
   float param amp1
     caption = "Amplitude #2"
     default = 1.0
     min = 0
     hint = "Controls the relative effect of fBm level #2."
     visible = @showmaps && (@levels>1) && @flag1
   endparam
   float param ang1
     caption = "Rotation #2 (degrees)"
     default = 22.5
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>1) && @flag1
   endparam
   heading
     caption = "fBm level 3"
     visible = @showmaps && (@levels>2)
   endheading
   bool param flag2
     caption = "Level 3 status"
     default = true
     hint = "Use to enable/disable fBm level 3."
     visible = @showmaps && (@levels>2)
   endparam
   float param frac2
     caption = "Sharpness #3"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>2) && @flag2
   endparam
   float param rs2
     caption = "Frequency #3"
     default = 1.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>2) && @flag2
   endparam
   float param amp2
     caption = "Amplitude #3"
     default = 1.0
     min = 0
     hint = "Controls the relative effect of fBm level #3."
     visible = @showmaps && (@levels>2) && @flag2
   endparam
   float param ang2
     caption = "Rotation #3 (degrees)"
     default = 11.25
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>2) && @flag2
   endparam
   heading
     caption = "fBm level 4"
     visible = @showmaps && (@levels>3)
   endheading
   bool param flag3
     caption = "Level 4 status"
     default = true
     hint = "Use to enable/disable fBm level 4."
     visible = @showmaps && (@levels>3)
   endparam
   float param frac3
     caption = "Sharpness #4"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>3) && @flag3
   endparam
   float param rs3
     caption = "Frequency #4"
     default = 1.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>3) && @flag3
   endparam
   float param amp3
     caption = "Amplitude #4"
     default = 1.0
     min = 0
     hint = "Controls the relative effect of fBm level #4."
     visible = @showmaps && (@levels>3) && @flag3
   endparam
   float param ang3
     caption = "Rotation #4 (degrees)"
     default = 33.75
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>3) && @flag3
   endparam
   heading
     caption = "fBm level 5"
     visible = @showmaps && (@levels>4)
   endheading
   bool param flag4
     caption = "Level 5 status"
     default = true
     hint = "Use to enable/disable fBm level 5."
     visible = @showmaps && (@levels>4)
   endparam
   float param frac4
     caption = "Sharpness #5"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>4) && @flag4
   endparam
   float param rs4
     caption = "Frequency #5"
     default = 1.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>4) && @flag4
   endparam
   float param amp4
     caption = "Amplitude #5"
     default = 1.0
     min = 0
     hint = "Controls the relative effect of fBm level #5."
     visible = @showmaps && (@levels>4) && @flag4
   endparam
   float param ang4
     caption = "Rotation #5 (degrees)"
     default = 16.875
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>4) && @flag4
   endparam
   heading
     caption = "fBm level 6"
     visible = @showmaps && (@levels>5)
   endheading
   bool param flag5
     caption = "Level 6 status"
     default = true
     hint = "Use to enable/disable fBm level 6."
     visible = @showmaps && (@levels>5)
   endparam
   float param frac5
     caption = "Sharpness #6"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>5) && @flag5
   endparam
   float param rs5
     caption = "Frequency #6"
     default = 1.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>5) && @flag5
   endparam
   float param amp5
     caption = "Amplitude #6"
     default = 1.0
     min = 0
     hint = "Controls the relative effect of fBm level #6."
     visible = @showmaps && (@levels>5) && @flag5
   endparam
   float param ang5
     caption = "Rotation #6 (degrees)"
     default = 39.375
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>5) && @flag5
   endparam
   heading
     caption = "fBm level 7"
     visible = @showmaps && (@levels>6)
   endheading
   bool param flag6
     caption = "Level 7 status"
     default = true
     hint = "Use to enable/disable fBm level 7."
     visible = @showmaps && (@levels>6)
   endparam
   float param frac6
     caption = "Sharpness #7"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>6) && @flag6
   endparam
   float param rs6
     caption = "Frequency #7"
     default = 1.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>6) && @flag6
   endparam
   float param amp6
     caption = "Amplitude #7"
     default = 1.0
     min = 0
     hint = "Controls the relative effect of fBm level #7."
     visible = @showmaps && (@levels>6) && @flag6
   endparam
   float param ang6
     caption = "Rotation #7 (degrees)"
     default = 28.125
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>6) && @flag6
   endparam
   heading
     caption = "fBm level 8"
     visible = @showmaps && (@levels>7)
   endheading
   bool param flag7
     caption = "Level 8 status"
     default = true
     hint = "Use to enable/disable fBm level 8."
     visible = @showmaps && (@levels>7)
   endparam
   float param frac7
     caption = "Sharpness #8"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>7) && @flag7
   endparam
   float param rs7
     caption = "Frequency #8"
     default = 1.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>7) && @flag7
   endparam
   float param amp7
     caption = "Amplitude #8"
     default = 1.0
     min = 0
     hint = "Controls the relative effect of fBm level #8."
     visible = @showmaps && (@levels>7) && @flag7
   endparam
   float param ang7
     caption = "Rotation #8 (degrees)"
     default = 5.625
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>7) && @flag7
   endparam
   heading
     caption = "fBm level 9"
     visible = @showmaps && (@levels>8)
   endheading
   bool param flag8
     caption = "Level 9 status"
     default = true
     hint = "Use to enable/disable fBm level 9."
     visible = @showmaps && (@levels>8)
   endparam
   float param frac8
     caption = "Sharpness #9"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>8) && @flag8
   endparam
   float param rs8
     caption = "Frequency #9"
     default = 2.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>8) && @flag8
   endparam
   float param amp8
     caption = "Amplitude #9"
     default = 0.5
     min = 0
     hint = "Controls the relative effect of fBm level #9."
     visible = @showmaps && (@levels>8) && @flag8
   endparam
   float param ang8
     caption = "Rotation #9 (degrees)"
     default = 19.6875
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>8) && @flag8
   endparam
   heading
     caption = "fBm level 10"
     visible = @showmaps && (@levels>9)
   endheading
   bool param flag9
     caption = "Level 10 status"
     default = true
     hint = "Use to enable/disable fBm level 10."
     visible = @showmaps && (@levels>9)
   endparam
   float param frac9
     caption = "Sharpness #10"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>9) && @flag9
   endparam
   float param rs9
     caption = "Frequency #10"
     default = 2.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>9) && @flag9
   endparam
   float param amp9
     caption = "Amplitude #10"
     default = 0.5
     min = 0
     hint = "Controls the relative effect of level #10."
     visible = @showmaps && (@levels>9) && @flag9
   endparam
   float param ang9
     caption = "Rotation #10 (degrees)"
     default = 36.5625
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>9) && @flag9
   endparam
   heading
     caption = "fBm level 11"
     visible = @showmaps && (@levels>10)
   endheading
   bool param flag10
     caption = "Level 11 status"
     default = true
     hint = "Use to enable/disable fBm level 11."
     visible = @showmaps && (@levels>10)
   endparam
   float param frac10
     caption = "Sharpness #11"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>10) && @flag10
   endparam
   float param rs10
     caption = "Frequency #11"
     default = 2.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>10) && @flag10
   endparam
   float param amp10
     caption = "Amplitude #11"
     default = 0.5
     min = 0
     hint = "Controls the relative effect of fBm level #11."
     visible = @showmaps && (@levels>10) && @flag10
   endparam
   float param ang10
     caption = "Rotation #11 (degrees)"
     default = 8.4375
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>10) && @flag10
   endparam
   heading
     caption = "fBm level 12"
     visible = @showmaps && (@levels>11)
   endheading
   bool param flag11
     caption = "Level 12 status"
     default = true
     hint = "Use to enable/disable fBm level 12."
     visible = @showmaps && (@levels>11)
   endparam
   float param frac11
     caption = "Sharpness #12"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>11) && @flag11
   endparam
   float param rs11
     caption = "Frequency #12"
     default = 4.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>11) && @flag11
   endparam
   float param amp11
     caption = "Amplitude #12"
     default = 0.25
     min = 0
     hint = "Controls the relative effect of fBm level #12."
     visible = @showmaps && (@levels>11) && @flag11
   endparam
   float param ang11
     caption = "Rotation #12 (degrees)"
     default = 25.3125
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>11) && @flag11
   endparam
   heading
     caption = "fBm level 13"
     visible = @showmaps && (@levels>12)
   endheading
   bool param flag12
     caption = "Level 13 status"
     default = true
     hint = "Use to enable/disable fBm level 13."
     visible = @showmaps && (@levels>12)
   endparam
   float param frac12
     caption = "Sharpness #13"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>12) && @flag12
   endparam
   float param rs12
     caption = "Frequency #13"
     default = 4.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>12) && @flag12
   endparam
   float param amp12
     caption = "Amplitude #13"
     default = 0.25
     min = 0
     hint = "Controls the relative effect of fBm level #13."
     visible = @showmaps && (@levels>12) && @flag12
   endparam
   float param ang12
     caption = "Rotation #13 (degrees)"
     default = 14.0625
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>12) && @flag12
   endparam
   heading
     caption = "fBm level 14"
     visible = @showmaps && (@levels>13)
   endheading
   bool param flag13
     caption = "Level 14 status"
     default = true
     hint = "Use to enable/disable fBm level 14."
     visible = @showmaps && (@levels>13)
   endparam
   float param frac13
     caption = "Sharpness #14"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>13) && @flag13
   endparam
   float param rs13
     caption = "Frequency #14"
     default = 8.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>13) && @flag13
   endparam
   float param amp13
     caption = "Amplitude #14"
     default = 0.125
     min = 0
     hint = "Controls the relative effect of fBm level #14."
     visible = @showmaps && (@levels>13) && @flag13
   endparam
   float param ang13
     caption = "Rotation #14 (degrees)"
     default = 30.9375
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>13) && @flag13
   endparam
   heading
     caption = "fBm level 15"
     visible = @showmaps && (@levels>14)
   endheading
   bool param flag14
     caption = "Level 15 status"
     default = true
     hint = "Use to enable/disable fBm level 15."
     visible = @showmaps && (@levels>14)
   endparam
   float param frac14
     caption = "Sharpness #15"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>14) && @flag14
   endparam
   float param rs14
     caption = "Frequency #15"
     default = 16.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>14) && @flag14
   endparam
   float param amp14
     caption = "Amplitude #15"
     default = 0.0625
     min = 0
     hint = "Controls the relative effect of fBm level #15."
     visible = @showmaps && (@levels>14) && @flag14
   endparam
   float param ang14
     caption = "Rotation #15 (degrees)"
     default = 2.8125
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>14) && @flag14
   endparam
   heading
     caption = "fBm level 16"
     visible = @showmaps && (@levels>15)
   endheading
   bool param flag15
     caption = "Level 16 status"
     default = true
     hint = "Use to enable/disable fBm level 16."
     visible = @showmaps && (@levels>15)
   endparam
   float param frac15
     caption = "Sharpness #16"
     default = 0.7071
     min = 1e-5
     max = 1.0
     hint = "Controls the sharpness of the fBm, lower values \
             produce smoother results."
     visible = @showmaps && (@levels>15) && @flag15
   endparam
   float param rs15
     caption = "Frequency #16"
     default = 32.0
     hint = "Controls the scale of the patterns."
     visible = @showmaps && (@levels>15) && @flag15
   endparam
   float param amp15
     caption = "Amplitude #16"
     default = 0.03125
     min = 0
     hint = "Controls the relative effect of level #16."
     visible = @showmaps && (@levels>15) && @flag15
   endparam
   float param ang15
     caption = "Rotation #16 (degrees)"
     default = 42.1875
     hint = "Rotates the pattern."
     visible = @showmaps && (@levels>15) && @flag15
   endparam
 }
 


Constructor Summary
MMF_AltfBm()
           
MMF_AltfBm(Generic pparent)
           
 
Method Summary
 float GetfBm(complex pz)
          GetfBm is the function that returns a texture value (float) based on a given complex number.
 void GlobalInit(complex pz)
          Initialisation of the texture variables.
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

MMF_AltfBm

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

MMF_AltfBm

public MMF_AltfBm()
Method Detail

GlobalInit

public void GlobalInit(complex pz)
Initialisation of the texture variables.

This is designed to be called once per change of texture, so normally just once say in a global section or in a constructor but it could be recalled if initiators were included in the class that could be set up in the constructor and modified later - allowing reconfiguration of the fBm.

The initialisation is done here (in it's own function) instead of in the constructor mainly so that it's possible to avoid the init when texturing is disabled at run time e.g.
if @fBm
GlobalInit(value)
endif

Here pz is actually unused but is included in case derived functions want to initiate based on an external value.

Parameters:
pz - a complex value for initialisation of the fBm

GetfBm

public float GetfBm(complex pz)
GetfBm is the function that returns a texture value (float) based on a given complex number. Note that in this particular class the values returned are restricted to the range 0....1 but this should not be relied on with derived classes so the returned value should normally then be processed with a transform.

Parameters:
pz - the z value for which to get an fBm value