In the OSL spec, there is a an optional parameter in a trace call for a 'traceset'.
I would like to restrict a trace to only hit the same object. The solution I have right now is to get the object name and test the trace object name after it hits like this:
// start OSL code fragment
string thisobjname = "";
getattribute("geom:name",thisobjname);
int hit = trace(P,
((_var_42 - 0.5) * 2.0),
);
string hitobjname = "";
getmessage("trace","geom:name",hitobjname);
if( hit && hitobjname==thisobjname)
printf("trace hit the same object");
// end OSL code fragment
I tried the following, but it does not work.
// start OSL code fragment
string thisobjname = "";
getattribute("geom:name",thisobjname);
int hit = trace(P,
((_var_42 - 0.5) * 2.0),
"traceset", thisobjname
);
string hitobjname = "";
getmessage("trace","geom:name",hitobjname);
if( hit)
printf("trace hit the same object");
// end OSL code fragment
How does the 'traceset' need to be formatted to work? Is there something else wrong?