slim 1 extensions andrewwdb { extensions andreww awsl { template shadingmodel ThreeChannelTrick { description {A shader that outputs specular levels to the red channel, shadowing to the green channel and diffuse levels to the blue channel. © 2003 Andrew Whitehurst} parameter float Ks { label {Specularity} description {The level of specularity.} default 0.8 detail varying } parameter float Kd { label {Diffuse value} description {The diffuse level.} default 0.8 detail varying } parameter float Ka { label {Ambient component} description {The ambient component.} default 1 detail varying } parameter float roughness { label {Specular Roughness} description {The spread of the specular component} default 0.25 detail varying } collection shadingmodel shadingmodel { access output display hidden parameter color CI { detail varying default {0 1 0} access output } parameter color OI { detail varying default {1 1 1} access output } } RSLFunction { void awslThreeChannelTrick(float Ks; float Kd; float Ka; float roughness; output color CI; output color OI; ) { normal Nf; vector V; float red; float green; float blue; Nf = faceforward( normalize(N), I ); V = -normalize(I); red = comp ((Ks * specular(Nf,V,roughness)), 2); blue = comp ((Kd*diffuse(Nf)), 2); green = 1 - (red + blue); if (green < 0){ green = 0; } CI = color "rgb" (red, green, blue); OI = color "rgb" (1, 1, 1); } } } } } template environment AmbEnvMap { eval [::slimWorkGenMacro environment closed] parameter string MapName { label "File" description "The name of the Environment Map to use." provider variable subtype environment default "" } parameter string Filter { description { Use of gaussian should produce higher quality results. The disk filter is optimized for large blur sizes, and (unlike the other filters) is free of mipmap artifacts because it uses all mipmap levels in its computations; it is about twice as expensive as the other filters. The radial-bspline filter is specifically designed for optimally filtering displacement textures. } subtype selector range { box box gaussian gaussian disk disk radial-bspline radial-bspline } default box } parameter float Lerp { description { Selects whether to interpolate between adjacent resolutions of a multi-resolution texture in order to smooth the transition between resolutions. } subtype switch default 0 } parameter string Space { label "Coordinate System" description "A coordinate system for your environment map. When used with maps generated from the attached object, use \"_world_lefthanded\" or \"world\". If you have an arbitrary lat-long environment use \"_environment\". If you wish to independently manipulate the orientation of your environment, enter the name of a coordinate system object here." default _environment provider variable } parameter color result { access output detail varying display hidden } RSLFunction { void awslAmbEnvMap (uniform string mapname; uniform string filter; uniform float lerp; uniform string space; output color result;) { if(mapname == "") { result = color 0; } else { varying vector r; varying float blur; extern normal N; extern vector I; normal Nn = normalize(N); normal Nf = faceforward (Nn, I, Nn); if( 0 == surface ("__L", r) ) r = normalize ( faceforward(Nn,I) ); if( space != "" ) r = vtransform(space, r); if( 0 == surface ("__blur", blur)) blur = 0; result = color environment (mapname, r, "filter", filter, "lerp", lerp, "blur", blur); } } } } } }