Chapter 7: Rendering Guidelines
127
light shadowspot ( float intensity = 1; color lightcolor = 1; point from = point "shader" (0,0,0); point to = point "shader" (0,0,1); float coneangle = radians(30); float conedeltaangle = radians(5); float beamdistrib = 2; float samples = 1; float blur = 0; float bias = -1; ) { uniform vector A = (to - from) / length(to - from); float cos_coneangle = cos( coneangle ); float cos_delta = cos( coneangle - conedeltaangle ); illuminate( from, A, coneangle ) { float cosangle = L.A / length(L); color atten = pow(cosangle, beamdistrib) / (L.L); atten *= smoothstep(cos_coneangle, cos_delta, cosangle); atten *= transmission( Ps, from, "samples", samples, "samplecone", 0, "bias", bias ); Cl = atten * intensity * lightcolor; } }
Listing 7.3: Ray traced shadows using transmission()
7.3.3 Ray Labels Ray labels are identifiers attached to traced rays. Labels are specified using the ‘label’ optional parameters that is supported by all ray tracing shadeops. A shader can then obtain the label of the current ray (the one that caused the shader evaluation) using the rayinfo() shadeop (see [rayinfo shadeop], page 116). ... uniform string ray_label = ""; rayinfo( "label", ray_label ); if( ray_label == "approx" ) { ... do something ... } else { .. do something more accurate } ...