Noise & Domain Ctrl Vex

domain
f(P)
f(P+domain)

noiseControl

Functionality: Script generates and controls various noise patterns applied to geometry in Houdini. It creates three distinct types of noise, blends or combines them, and outputs the result as the Cd attribute. Uses second inputs Cd or deformation attribute to deform noise space.

Parameters:

  • type (int): The type of noise to generate (0 for Aligator, 1 for Perlin, 2 for Sparse Convolution, 3Worley noise. 4:Voronoi noise)
  • deformDomain (float): Controls the amount of noise’s domain deformation. Instead of using @P uses (v@P + v@domainDeformation) for generation noise patern.
  • deformation (vector): Specifies the deformation vector parameter. By default, it uses the Cd attribute from the second input.
  • Noise1D: Determines the application of generated noise.
/*
Script:     noiseCtrl
Version:    1.0

Overview and Functionality
Script generates and controls various noise patterns applied to geometry in Houdini.
It creates three distinct types of noise, blends or combines them, and outputs the result as the Cd attribute. Uses second inputs Cd or deformation attribute to deform noise space. 

Parameters:
type (int): The type of noise to generate (0 for Aligator, 1 for Perlin, 2 for Sparse Convolution, 3Worley noise. 4:Voronoi noise.).
domainDeform (float): Controls the amount of noise's domain deformation. Instead of using @P uses (v@P + v@domainDeformV) for generation noise patern.
domainDeformV (vector): Specifies the deformation vector parameter. By default, it uses the Cd attribute from the second input.
Noise1D: Determines the application of generated noise.


*/

vector freq_A = chv("freq_A");                                              
vector offset_A = chv("offset_A");       

vector freq_B = chv("freq_B");                                              
vector offset_B = chv("offset_B");     

vector freq_C = chv("freq_C");                                              
vector offset_C = chv("offset_C");     

vector freq;
vector offset ;

//noisePrep                                             
                         
vector    noiseType =   chv("type_ABC");    


float   amp_A     =   chf("amp_A");                                          
float   rough_A   =   chf("roughness_A");                                         
float   atten_A   =   chf("attenuation_A");;                                              
float   turb_A    =   chf("turbulance_A");      

float   amp_B     =   chf("amp_B");                                          
float   rough_B   =   chf("roughness_B");                                         
float   atten_B   =   chf("attenuation_B");;                                              
float   turb_B    =   chf("turbulance_B");      

float   amp_C     =   chf("amp_C");                                          
float   rough_C   =   chf("roughness_C");                                         
float   atten_C   =   chf("attenuation_C");;                                              
float   turb_C    =   chf("turbulance_C");      


float noiseGen(int type; vector position; vector freq; vector offset;float amp ;float rough; float atten; int turb;   ) {

    float resultNoise ;
        vector jitter = set(1, 1,1); ;                                          
        vector noiseVal;                                                
        int seed;                                               
        float f1, f2, f3, f4;                                           
        vector pos1, pos2;                                              

    if (type==0)resultNoise = anoise((position * freq + offset ) ,  turb, rough, atten); //aligator  
    if (type==1)resultNoise = onoise((position * freq + offset ) ,  turb, rough, atten); //orig.Perline 
    if (type==2)resultNoise = snoise((position * freq + offset ) ,  turb, rough, atten); // Sparse Convolution       
    if (type == 3) {
                wnoise((position * freq + offset ) , seed, f1, f2, f3, f4);                                              
                resultNoise = f1;                                
        }
        if (type == 4) {
                vnoise( (position * freq + offset ) , jitter, seed, f1, f2, pos1, pos2);                                          
                pos1 = (pos1 - offset) / freq;                                          
                pos2 = (pos2 - offset) / freq;                                          
                float vnoise = f1;                                                                                               
                resultNoise = f1;                                
        }
        resultNoise*=amp;
        return resultNoise;
        
}

vector noiseVal;
int Noise1D = chi("Noise1D");    
float  domainDeform = chf("domainDeform");
vector domainDeformV ; 

if (domainDeform>0){
    domainDeformV = point(1,"Cd",@ptnum);
    domainDeformV  *= domainDeform;
}


if(Noise1D==0 || Noise1D==1 || Noise1D>3  ) noiseVal.x = noiseGen( noiseType.x , v@P+domainDeformV , freq_A , offset_A ,amp_A ,rough_A, atten_A, turb_A);
if(Noise1D==0 || Noise1D==2 || Noise1D>3  ) noiseVal.y = noiseGen( noiseType.y , v@P+domainDeformV , freq_B , offset_B ,amp_B ,rough_B, atten_B, turb_B);
if(Noise1D==0 || Noise1D==3 || Noise1D>3  ) noiseVal.z = noiseGen( noiseType.z , v@P+domainDeformV , freq_C , offset_C ,amp_C ,rough_C, atten_C, turb_C);                                  

noiseVal.x = chramp("ramp_A",noiseVal.x); 
noiseVal.y = chramp("ramp_B",noiseVal.y);                                               
noiseVal.z = chramp("ramp_C",noiseVal.z);                                                 
                                        
                                       
if(Noise1D!=0){                                         
if(Noise1D==1) noiseVal = noiseVal.x;                                           
if(Noise1D==2) noiseVal = noiseVal.y;                                           
if(Noise1D==3) noiseVal = noiseVal.z;                                           
if(Noise1D==4) noiseVal = length(noiseVal);       
if(Noise1D==5) noiseVal = (noiseVal.x*noiseVal.y*noiseVal.z);       
}                                               
                                                
                                                                
@Cd = noiseVal ;                                                

Leave a comment