top of page

OSL BUBBLE SHADERS WITH CODES

Without OSL Shader

With OSL Shader

srf_mt_bubbles_v46.osl   

                                                                                        
// To become familiar with pattern creation and texture mapping by coding repeating patterns in OSL.                
// Micaa Thomas                                                                                                       
// SCAD-Atlanta                                                                                                       
// Programming Models and Shaders I-VSFX-319-A01                                                                   
// May 29, 2019                                                                                                    
// THIS FILE CREATES a bubble swirl shader by casting points to a vector with an array                             

//This was definitely one of the hardest shaders that I have made by far because I wanted to go a bit beyond what  
 //was taught in class.  I am glad that we did this project so now I can show off my beautiful shader.             

                                                                                                       
// LIST OF TODOS                                                                                                    
//1) create a couple of variables that the user can interact with, such as Vector, Time, Scale, and MaxIterations  
//2) I did not animate the shader.                                                                                   
  

shader srf_mt_bubbles_v46(
    vector Vector = P,                                                                   //creates the vector called P for the shader     
    float Scale = 0.2,                                                                
    float Time = 1.0,                                                                     //could be animated by keying time
    int MaxIterations = 64,                                                           //This parameter limits the number of iterations of the cutting plane
    output color Color = 0.8)
{
    vector p = Vector * Scale;                                                       //the position of the shader position

    for(int m=1; m < MaxIterations; m++)                                              //creates an array 
    {
        vector newp = p;                                                                                                           //start of vector newp
        newp[0]+=0.4/float(m)*sin(float(m)*p[1]+Time/24.0+0.3*float(m))+20.0;              //casting points to the vector newp.  
        newp[1]+=0.4/float(m)*sin(float(m)*p[0]+Time/24.0+0.3*float(m+10))-5.0;          //newp is being called in and creates a sin wave with time that can make it become animated.
        p=newp;
    }

    Color = color(sin(Time+p[1]+p[0]-M_PI*color(0,2,4)/(4.0+sin(Time)))*0.3+0.5);     //my newly created color is being output and creates a zig zag like shader for the bubble that I plug into Pixar's bubble material.
}

 

Without OSL Shader

With OSL Shader

srf_mt_bubbles_bowl_v20.osl 

                                                                                          
// To become familiar with pattern creation and texture mapping by coding repeating patterns in OSL.                
// Micaa Thomas                                                                                                       
// SCAD-Atlanta                                                                                                       
// Programming Models and Shaders I-VSFX-319-A01                                                                   
// May 29, 2019                                                                                                    
                                                                                                              
                                                                                                                
// THIS FILE CREATES a bubble swirl shader by casting points to a vector with an array                             

//This was definitely one of the hardest shaders that I have made by far because I wanted to go a bit beyond what  
 //was taught in class.  I am glad that we did this project so now I can show off my beautiful shader.         

   

//        My Original Code, but did receive help from a few sites:                                                   

//            *Open Shading Language 1.10                                                                               
//            *http://www.fundza.com/rfm/osl/velvet/index.html                                                       
//            *https://blenderartists.org                                                                               
//            *http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/math.h.html    
//           *https://octave.org/doc/v4.2.1/Three_002dDimensional-Plots.html                                                                                                             
                                                                                                                   
                                                                                      
// LIST OF TODOS                                                                                                   
//1) create a couple of variables that the user can interact with, such as Vector, Time, Scale, and MaxIterations  
//2) I did not animate the shader.                                                                                   

 

shader srf_mt_bubbles_bowl_v20(
       point Pos = P,                                                                                                    // creates points with an indication of P
    color ColA = color(1, 0, 0),
    color ColB = color(0, 1, 0),
    float Offset = 0.0,
    output color ColOut = color(0, 0, 1)
    
)
{
    float x = Pos[0];
    float y = Pos[1];
    float z = Pos[2];
    
    point myPoint = point(x, 0, 0);
    
    float f = distance(Pos, myPoint) + noise(Pos, Offset);
    
    ColOut = mix(ColA, ColB, sign( tan( f * 4 ) ));
}

bottom of page