slim 1 extensions hosuk { extensions scad ho { template color env { parameter string mapname { default "" } parameter string coordname { default "world" } parameter float kenv { default 1 } parameter float samples { detail "uniform" default 64 } parameter float reflectionBlur { detail "uniform" default 0.1 } parameter float raytracedReflectionAmuont { default 0.5 } parameter color result { access output display hidden default 0 } RSLSource StaticFunction { void hoenv( string mapname; string coordname; float kenv; float samples; float reflectionBlur; float raytracedReflectionAmuont; output color result) { color envcolor = 0; //raytrace reflection result = 1; color ray = 0; color surfColor = 0; if(mapname != "") { normal n = normalize(N); vector i = normalize(I); normal nf = faceforward(n, i); vector R = reflect(i, nf); //R = transform(coordname, R); envcolor = environment(mapname, R) * kenv; float samples = 16; /* often from a shader parameter */ float blur = radians(reflectionBlur); /* often from a shader parameter */ if (N.I < 1) { /* only trace from points facing the eye */ color hitcolor = 0; gather("illuminance", P, R, blur, samples, "volume:Ci", hitcolor) { surfColor += hitcolor * raytracedReflectionAmuont; } else { surfColor += envcolor; } surfColor/= samples; } } result = surfColor; } }}}}