top of page

## OSL BUBBLE SHADERS WITH CODES

srf_mt_bubbles_v46.osl

// To become familiar with pattern creation and texture mapping by coding repeating patterns in OSL.
// Micaa Thomas
// 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.

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.4/float(m)*sin(float(m)*p+Time/24.0+0.3*float(m))+20.0;              //casting points to the vector newp.
newp+=0.4/float(m)*sin(float(m)*p+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+p-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.
}