/* This shader must be used with its displacement shader datol.slo. */ /* By Cemil Turun, a modified marble shader. */ #include "rmannotes.sl" surface atol( float Kd = .6, Ka = .1, roughness = .1, txtscale = 1;) { /* this is a modified marble shader, now it looks like an island in the Pacific */ point PP; /* scaled point in shader space */ float csp; /* color spline parameter */ point Nf, V; /* forward-facing normal */ float pixelsize, twice, scale, weight, turbulence; /* Obtain a forward-facing normal for lighting calculations. */ Nf = faceforward( normalize(N), I); V = normalize(-I); PP = transform("shader", P) * txtscale; pixelsize = sqrt(area(PP)); twice = 2 * pixelsize; turbulence = 0; for (scale = 1; scale > twice; scale /= 2) turbulence += scale * noise(PP/scale); /* Gradual fade out of highest-frequency component near limit */ if (scale > pixelsize) { weight = (scale / pixelsize) - 1; weight = clamp(weight, 0, 1); turbulence += weight * scale * noise(PP/scale); } /* * Modified colors now give the island's look + sea. */ csp = clamp(3 * turbulence - 3, 0, 1); Ci = color spline(csp, color (0.0, 0.03, 0.1), color (0.0, 0.03, 0.1), /* color (0.1, 0.6, 0.65),*/ color (0.8, 0.8, 0.95), color (0.3, 0.28, 0.1), color (0.3, 0.28, 0.1), color (0.1, 0.4, 0.1), color (0.2, 0.35, 0.0), color (0.15, 0.3, 0.0), color (0.0, 0.2, 0.02), color (0.3, 0.4, 0.15), color (0.2, 0.5, 0.05), color (0.2, 0.2, 0.05), color (0.2, 0.2, 0.05) ); /* Multiply this color by the diffusely reflected light. */ Ci *= Ka*ambient() + Kd*diffuse(Nf); /* Adjust for opacity. */ Oi = Os; Ci = Ci * Oi; }