reb
Class REB_TrapShapeGnarlTexture

Object
  extended by common:Generic
      extended by common:TrapShape
          extended by reb:REB_TrapShapeGnarlTexture

class 
TrapShape:REB_TrapShapeGnarlTexture

This texture is based upon the code of Mark Townsend
Convolution code added 10/10/08


Ultra Fractal Source

Toggle UF Source Code Display

 class REB_TrapShapeGnarlTexture(common.ulb:TrapShape) {
  ; This texture is based upon the code of Mark Townsend  <br>
  ; Convolution code added 10/10/08 <br>
  public:
    import "common.ulb"
 
 ; constructor
    func REB_TrapShapeGnarlTexture(Generic pparent)
      TrapShape.TrapShape(pparent)
    endfunc
    
   ; Call this for each iteration being trapped.
    float func Iterate(complex pz)
     TrapShape.Iterate(pz)
     complex z = 0
     float x = 0
     float y = 0
     float xx = 0
     int i = 0
     int j = 0
     int jmax = 0
     float a = 0
     float sum = 0
     float distance = 0
     if @mode == 0
       jmax = 1
     else
       jmax = 5
     endif
 
     while j < jmax
       z = pz*@scaleg
       if @mode == 1 || @mode == 2
         if j == 0
           a = @cbl + @ctl + @cbr + @ctr + @cc
         elseif j == 1
           z = z + @eps*(-1,-1)
           a = -@cbl
         elseif j == 2
           z = z + @eps*(-1,1)
           a = -@ctl
         elseif j == 3
           z = z + @eps*(1,-1)
           a = -@cbr
         elseif j == 4
           z = z + @eps*(1,1)
          a = -@ctr
         endif
       else
         a = 1
       endif
       j = j + 1
       x = real(z)
       y = imag(z)
       xx = 0
 
       while (i < @iters)
         xx = x
         if @formula == 0
          ; Martin
           x = y - sin(x)
           y = @a - xx
         elseif @formula == 1
          ; Popcorn
           x = x - @h * sin(y + tan(@a * y))
           y = y - @h * sin(xx + tan(@a * xx))
         elseif @formula == 2
           ; Vine
           if @flavor == 0
             x = x - @h * sin(y + sin(@a * y ))
             y = y + @h * sin(xx + sin(@a * xx))
           elseif @flavor == 1
             x = x - @h * sin(y^@b + sin(@a * y))
             y = y + @h * sin(xx^@b + sin(@a * xx))
           elseif @flavor == 2
            x = x - @h * sin(y + sin(@a * (y + sin(@a * y))))
            y = y + @h * sin(xx + sin(@a * (xx + sin(@a * xx))))
           else
             float newx = y
             float newy = x
             int j = 0
             while j < @flavor
               j = j + 1
               newx = y + sin(@a * newx)
               newy = x + sin(@a * newy)
             endwhile
             x = x - @h * sin(newx)
             y = y + @h * sin(newy)
           endif
         elseif @formula == 3
           ; Gnarl
           x = x - @h * real(@gn1(y + @gn2(@a * (y + @gn3(@b * y)))))
           y = y + @h * real(@gn1(xx + @gn2(@a * (xx + @gn3(@b * xx)))))
         endif
         i = i + 1
       endwhile
       z =  ((real(pz) - (@scaleg * x)) + flip((imag(pz) - (@scaleg * y))))*@strengthg
       distance = cabs(z)
       if @mode != 2
         sum = sum + a*distance
       else
         sum = sum + a*abs(distance)
       endif
       distance = 0
     endwhile
 
     if @mode == 2
       sum = 3*abs(sum)
     endif
 
     if @mode == 1
       distance = sum/(10*@eps*(abs(@cbl + @ctl + @cbr + @ctr)+1))
     else
       distance = sum
     endif
     m_LastZ = z
     return distance
    endfunc
    
  default:
    title = "Gnarl Textures"
   int param v_trapshapegnarltextures
     caption = "Version (Trap Shape Gnarl Textures)"
     default = 102
     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_trapshapegnarltextures < 102
   endparam
   param formula
     caption = "Formula"
     enum = "Martin" "Popcorn" "Vine" "Gnarl"
     default = 1
   endparam
   param a
     caption = "Alpha"
     default = 3.0
   endparam
   param b
     caption = "Beta"
     default = 2.0
     visible = (@formula == 2 || @formula == 3)
   endparam
   param iters
     caption = "Iterations"
     default = 20
   endparam
   param flavor
     caption = "Vine flavor"
     default = 2
     min = 0
     visible = @formula == 2
   endparam
   param h
     caption = "Step size"
     default = 0.1
     visible = (@formula == 1 || @formula == 2 || @formula == 3)
   endparam
   param scaleg
     caption = "Scale"
     default = 10.0
     hint = "Changes the size of the shapes."
   endparam
   param strengthg
     caption = "Strength"
     default = 0.05
   endparam
   func gn1
     caption = "Gnarl function #1"
    default = sin()
     visible = @formula == 3
   endfunc
   func gn2
     caption = "Gnarl function #2"
     default = tan()
     visible = @formula == 3
   endfunc
   func gn3
     caption = "Gnarl function #3"
     default = cos()
     visible = @formula == 3
   endfunc
   param mode
     caption = "Mode"
     default = 0
     enum = "Normal" "Convolution" "Absolute Convolution"
   endparam
   param cc
     caption = "Center Extra Weight"
     default = 0.0
     visible = @mode != "Normal"
   endparam
   param cbl
     caption = "Bottom Left Weight"
     default = 1.0
     visible = @mode != "Normal"
   endparam
   param ctl
     caption = "Top Left Weight"
     default = 0.0
     visible = @mode != "Normal"
   endparam
   param cbr
     caption = "Bottom Right Weight"
     default = 0.0
     visible = @mode != "Normal"
   endparam
   param ctr
     caption = "Top Right Weight"
     default = 0.0
     visible = @mode != "Normal"
   endparam
   param eps
     caption = "Epsilon"
     default = 0.006
     visible = @mode != "Normal"
   endparam
  }
 


Constructor Summary
REB_TrapShapeGnarlTexture()
           
REB_TrapShapeGnarlTexture(Generic pparent)
          constructor
 
Method Summary
 float Iterate(complex pz)
          Call this for each iteration being trapped.
 
Methods inherited from class common:TrapShape
GetColorChannel, GetTextureValue, GetTransformedPoint, Init, IterateSilent, SetThreshold
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

REB_TrapShapeGnarlTexture

public REB_TrapShapeGnarlTexture(Generic pparent)
constructor


REB_TrapShapeGnarlTexture

public REB_TrapShapeGnarlTexture()
Method Detail

Iterate

public float Iterate(complex pz)
Call this for each iteration being trapped.

Overrides:
Iterate in class TrapShape