# A barebones template for a color node
# M.Kesson
# 17 Jan 2009
  
  
slim 1 extensions cutter {
extensions fundza cutr {
    template multiple Bombing {
        description {
            Description of the node goes here.
            }    
        previewinfo {
            shadingrate 1
            objectsize 1
            objectshape Plane
            frame 1
            }
  
        parameter float fuzz_custom {
            label "Edge Blur"
            description "No description."
            subtype slider
            range {0 0.2}
            detail varying
            default 0.005
            }                            
                            
                        
        parameter float layers {
            label "Dot Amount"
            description "No description."
            subtype slider
            range {0 20}
            detail varying
            default 10
            }        
                        
        parameter float noi_s {
            label "Position s"
            description "No description."
            subtype slider
            range {0 2000}
            detail varying
            default 1183
            }                
                    
        parameter float noi_t {
            label "Position t"
            description "No description."
            subtype slider
            range {0 2000}
            detail varying
            default 999
            }            
        
        parameter float offset_s {
            label "offset_s"
            description "No description."
            subtype slider
            range {0 1}
            detail varying
            default 0.5
            }                    
  
        parameter float offset_t {
            label "offset_t"
            description "No description."
            subtype slider
            range {0 1}
            detail varying
            default 0.5
            }        
            
        parameter float offset_x {
            label "offset_x"
            description "No description."
            subtype slider
            range {0 1}
            detail varying
            default 0.5
            }            
        
        parameter float jitter {
            label "Dot Randomness"
            description "No description."
            subtype slider
            range {-1 1}
            detail varying
            default 0.35
            }                
        
        parameter float circle_r {
            label "Dot Radius"
            description "No description."
            subtype slider
            range {0 1}
            detail varying
            default 0.2
            }    
            
        parameter float color_hue_start {
            label "Dots Hue Start"
            description "No description."
            subtype slider
            range {0 1}
            detail varying
            default 0.0
            }
            
        parameter float color_hue_end {
            label "Dots Hue End"
            description "No description."
            subtype slider
            range {0 1}
            detail varying
            default 1
            }
            
        parameter float color_saturation {
            label "Dots Saturation"
            description "No description."
            subtype slider
            range {0 1}
            detail varying
            default 1
            }
            
        parameter float color_value {
            label "Dots Color Value"
            description "No description."
            subtype slider
            range {0 1}
            detail varying
            default 1
            }
            
        parameter float color_noise {
            label "Dots Color Noise"
            description "No description."
            subtype slider
            range {0 100}
            detail varying
            default 50
            }
                        
        parameter color bg_color {
            label "bg_color"
            description "No description."
            default {1 1 1}
            detail varying
            }
    
        parameter color result_color {
            access output
            display hidden
            }
            
  
            
            
        RSLInclude "header.h"
            
        RSLFunction {
        
        
        void cutrBombing (
            float fuzz_custom;
            float layers;
            float noi_s;
            float noi_t;
            float offset_s;
            float offset_t;
            float offset_x;
            float jitter;
            float circle_r;
            float color_hue_start;
            float color_hue_end;
            float color_saturation;
            float color_value;
            float color_noise;
            color bg_color;
            output varying color result_color;
            )
        {
  
            float choice;
            float i;
            float freq;
            float fuzz;
            float ss, tt, tmps, tmpt;
            float col, row;
            float noi;
            color layer_opac;
            color layer_color;
  
            
            
             result_color = bg_color; /* background */
            
              for (i = 1; i <= layers; i += 1) { 
                /*amount*/
            
                /* set freq and fuzz of pattern based on layer # */
                
                freq = i;
                fuzz = fuzz_custom * freq; /* blur */
            
                /* base seed to udn on current row and column of tile */
            
                col = whichtile2(s, freq);
                row = whichtile2(t, freq);
                noi = noise(col * 10 + offset_s, row * 10 + offset_t) * noise(i * 10 + offset_x);
            
                /* repeat texture coords, jitter tiles by plus or minus 0.35, 
                   and rotate by random amount (0-360) */
            
                tmps = repeat2(s, freq) + udn2(noi * noi_s, -1 * jitter, jitter);
                tmpt = repeat2(t, freq) + udn2(noi * noi_t, -1 * jitter, jitter);
            
                rotate2d2(tmps, tmpt, radians(udn2(noi * 777, 0, 360)), 0.5, 0.5, ss, tt);
            
                /* generate tile 50% of the time & choose random hue */
            
                if (udn2(noi * 314, 0, 1) > 0.5) {
                  layer_color = color "hsv" (udn2(noi * color_noise, color_hue_start, color_hue_end), color_saturation, color_value);
                  layer_opac = circle(circle_r,fuzz,ss,tt);
                    /*intersection(pulse2(0.35, 0.65, fuzz, ss), pulse2(0.35, 0.65, fuzz, tt));*/
    
                result_color = blend2(result_color, layer_color, layer_opac);
  
                }
              }
        
        }
} } } }