With the illuminance function we can get some interesting surface
effects. In the examples below fractional brownian motion noise
was applied to the surface point value; and the spline function
was used to manipulate color and opacity.
Opal Version One
Opal Version Two
Version one uses color splines to manipulate surface
color. The final version and other renditions were achieved by
setting the opacity equal to the surface color and manipulating
the color values for the color spline (see right).
In the version above, the frequency of the opal is too high to look
anything like a real opal. I want to be able to adjust this frequency
in Maya, so have added in a variable to get the differing results
below.
Code
#include "H:/vsfx727/shaders/noise.h"
/* Shader description goes here */
surface
spline_test(float Kd = 1,
lucanarity = 1,
gain = 1,
detail = 1,
freq = 1;
color c1 = color(1.0,0.4,0.0),
c2 = color(1.0,1.0,0.0),
c3 = color(1.0,0.6,1.0),
c4 = color(1.0,1.0,0.8),
c5 = color(0.4,0.0,0.4),
c6 = color(1.0,0.4,0.0),
c7 = color(1.0,1.0,0.0),
c8 = color(1.0,0.6,1.0),
c9 = color(1.0,1.0,0.8),
c10 = color(0.4,0.0,0.4)
)
{
normal n = normalize(N);
normal nf = faceforward(n, I);
color surfcolor = 1;
point p = transform(object,P); /*reset coordinate space*/
color c = color noise(P); /*effect color with surface point*//*manipulate the way light reacts to the surface*/
illuminance(P, nf, PI/2) {
/*add the dot product of the Light ray an d normal to the surface point*/
p += nf.normalize(L);
/*set phase01 to point p with applied fractional brownian motion (noise.h) */
float phase01 = fbm(p,detail,lucanarity,gain);
/* set phase02 to phase01 plus broken up light */
float phase02 = phase01 + cellnoise(L) * .005;
/* set surface color to a color spline value*/
surfcolor = spline(phase02,c1,c1,c2,c3,c4,c5 ,c6,c7,c8,c9,c10,c10);
/* set the opacity equal to surface color */
Oi = surfcolor;
}
/*Calculate the surface color*/
color diffusecolor = Kd * diffuse(nf);
Ci = Oi * Cs * surfcolor * diffusecolor;
}