/*========== Planet Rings Shader ==========*/ /*========== by Brandon Onstott ==========*/ /*========== ==========*/ /*========== Apply to a disk around your ==========*/ /*========== procedural planet. Mixez Cs ==========*/ /*========== with sline color map using ==========*/ /*========== given ratio. ==========*/ /*========== ==========*/ /*========== February 11, 1999 ==========*/ /*========== VIZA 616 - Rendering and Shading ==========*/ /*========== Visualization Laboratory ==========*/ surface rings (float Ka = .2, Kd = .8, ratio = 0.5) { float tt; color Ct; /* Adjust surface parameters to go from 0 to 1 */ /* over 1/4th of the surface. */ tt = clamp(t*4.0, 0, 1); Oi = (1.0 - smoothstep(0.23, 0.25, t))* 0.4; /* Mix spline() color with surface color Cs. */ Ct = Cs*ratio + (1-ratio)* spline (tt, color (.9, .39, .2), color (.5, .39, .9), color (.9, .9, .2), color (.2, .3, 1), color (.085, .2, .04), color (.0, .22, .04), color (.5, .42, .28), color (.6, .5, .0), color (1,1,1), color (1,1,1)); /* Shade using matte model */ Ci = Ct * (Ka * ambient() + Kd * diffuse(faceforward(normalize(N),I))); Ci *= Oi; }