RenderKit / embree

Embree ray tracing kernels repository.
Apache License 2.0
2.32k stars 383 forks source link

Why does RTC_RAY_QUERY_FLAG_INVOKE_ARGUMENT_FILTER not apply to user-defined geometries? #478

Open Tradias opened 3 months ago

Tradias commented 3 months ago

Given a user-defined geometry (RTC_GEOMETRY_TYPE_USER) added to a scene with RTC_SCENE_FLAG_FILTER_FUNCTION_IN_ARGUMENTS then the following code:

RTCIntersectArguments args
// ...
args.filter = some_filter;
args.flags = RTC_RAY_QUERY_FLAG_INVOKE_ARGUMENT_FILTER;
rtcIntersect1(scene, &rayhit, &args);

never invokes some_filter even though the documentation says that:

The callback is only invoked for geometries that enable the callback using the rtcSetGeometryEnableFilterFunctionFromArguments call, or enabled for all geometries when the RTC_RAY_QUERY_FLAG_INVOKE_ARGUMENT_FILTER ray query flag is set.

Even enabling rtcSetGeometryEnableFilterFunctionFromArguments has no effect.

This issue describes a workaround https://github.com/embree/embree/issues/441 but it would be nice to either change the documentation or change the behavior.

embree version 4.3.0

svenwoop commented 3 months ago

You are right, filter functions are newer called for user defined geometries automatically. You either have to add some rtcInvokeIntersectFilterFromGeometry call to invoke the filter function stored inside the geometry by hand, or pass the function set inside the RTCIntersectArguments manually through the context and call it.

Tradias commented 3 months ago

I am doing doing the latter, but it took me a while to figure out because the documentation confused me and does not mention the latter approach to my knowledge.