As described in the OSL specification, the main purpose of the
trace() function call is to be used within a shader to 'probe out' the surrounding geometry. When used in this way there is no need for the shader to perform the additional work of determining the shading of that 'hit' point - only whether there is something along that ray (and what/where it is). The default of the 'shade' parameter is 0 - ie, only determine whether geometry is 'hit', don't consider it's surface or shading. ie,
Optional parameters include:
"mindist" float Minimum hit distance (default: zero)
"maxdist" float Maximum hit distance (default: infinite)
"shade" int Whether objects hit will be shaded (default: 0)
"traceset" string An optional named set of objects to ray trace (if preceded by a ‘-’ character, it means to exclude that set).
From what I gather, setting 'shade' to 1 indicates that the additional work of actually shading the hit point on the surface (eg, calculate the normal, interpolation, etc.) also takes place (taking additional processing time).
So, in summary, it's an efficiency flag - leaving as 0 provides a quick and dirty trace whereas setting to non-zero acivates the 'full' trace, including hit surface properties.
EDIT : For a related question (see https://blender.stackexchange.com/a/106832/29586) I have been trying to trace through the source code for the
The trail seems to lead to the
trace() function with the comment
/* todo: options.shader support, maybe options.traceset */ which seems to confirm that the 'traceset' option is not implemented and the same function does not have any other reference to the 'shade' parameter - it would appear that the 'shader' mentioned in the comment is a typo (should be 'shade') and the 'shade' option is not implemented.