This was my first attempt at procedural shading (which remarkably worked out on the first try). All of my shading code is given as text below. For references, I used the Pixar Renderman Interface Specifications and the Renderman.org website. This used the shader "LLstripes"
This is my lava shader. I think it looks the best of all my shaders. It only works well for the teapot though unfortunately. Parameters could be adjusted to make it work for other models as well though. Basically what I did was generate a lot of yellow noise toward the bottom of the pot and gradually turned that into red noise toward the top. Where there wasn't already a threshold of noise, I also added red speckles to simulate rising sparks coming from real lava. This used the shader "LLdewsurface"
These were my two attempts at displacement shading. I was hoping that they would turn out to be smooth surfaces since the functions I was using were smooth. For the image on the top, I just used the sin() of the current v (parametric) coordinate. It seems like this should be a smooth to me. I did clamp the resulting displacement but that shouldn't result in the strange artifacts seen in this picture. The second image uses the mean curvature at any point K = (du/dt + dv/dt)/2 to decide displacement. Again, I clamped the resulting displacements but I don't understand why these artifacts are occurring. If you have any insight, I would love to hear it. The code for both of these is in "LLcurvedisplacement"
Here is the code:
/*Lisa's first texture - stripes LLstripes.sl*/
surface LLstripes(float a = 2)
{
if(mod(xcomp(P), a) < 1)
Ci = 1;
else
Ci = color(.3, .6, .8);
}
/*LLdewsurface*/
surface LLdewsurface()
{
point PP = transform("shader", P);
float r = noise(PP)*(6-ycomp(PP))/(10-ycomp(PP));
if (r < .6 && r > .5)
r = .6;
if (r <.5 && r > .4)
r = .4;
float g = 1.1*noise(PP)*(6-ycomp(PP));
if (g < .7 && g > .5)
g = .7;
if (g <.5 && g > .3)
g = .3;
if (r < g)
{
float temp = r;
r = g;
g = temp;
}
Ci = color(r, g, 0);
if (random() > .99 && r <= .4 && g < .4)
Ci = color(1.0, 0, 0);
}
/*LLcurvedisplacement*/
displacement LLcurvedisplacement()
{
point OP = transform("object", P);
point origin = point(0, 0, 0);
float d = distance(OP, origin)*.01;
float meanC = abs(du/dtime + dv/dtime)/2;
/*P = P - clamp(N*sin(dv), -.2, .2);*/
P = P - clamp(N*meanC, -.2, .2);
N = calculatenormal(P);
}
And here's the code for the teapot (I only change the shader line here):
/*LLcurvedisplacement*/
displacement LLcurvedisplacement()
{
point OP = transform("object", P);
point origin = point(0, 0, 0);
float d = distance(OP, origin)*.01;
float meanC = abs(du/dtime + dv/dtime)/2;
/*P = P - clamp(N*sin(dv), -.2, .2);*/
P = P - clamp(N*meanC, -.2, .2);
N = calculatenormal(P);
}