surface slicePoint ( float Kd = 1.0; float Ks = 1; float roughness = 0.1; float near = 1; float far = 10000; float nearFadeWidth = 0.1; float farFadeWidth = 1; ){ normal nn = normalize(faceforward(N,I)); vector i = normalize(-I); color diff = diffuse(nn); color spec = specular(nn, i, roughness); diff *= Kd; spec *= Ks; float z = P[2]; float opacity = 0; float outNear = near - nearFadeWidth; float outFar = far + farFadeWidth; opacity = smoothstep(outNear, near, z); opacity *= 1 - smoothstep(far, outFar, z); Oi = opacity * Os; Ci = Cs * (diff* Kd + spec* Ks) * opacity; }