Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtcSetGeometryIntersectFunction does not call it's intersect function #442

Open
mmomentum opened this issue Apr 25, 2023 · 3 comments
Open

Comments

@mmomentum
Copy link

This is probably just something I'm doing wrong with Embree, but i'm not really sure what the cause of it is.

I run the following two functions (DBG is a debug function):

rtcSetGeometryIntersectFunction(geometry,
	[](const RTCIntersectFunctionNArguments* args)
	{
		DBG("Calling the setGeometryIntersectFunction()'s internal function.");

		Sphere* const spheres = static_cast<Sphere*>(args->geometryUserPtr);
		const Sphere& sphere = spheres[args->primID];
		RTCRayHit& ray = *reinterpret_cast<RTCRayHit*>(args->rayhit);
		SphereIntersection(sphere, &ray);
	});

rtcSetGeometryBoundsFunction(geometry,
	[](const RTCBoundsFunctionArguments* args)
	{
		DBG("Calling the setGeometryBoundsFunction()'s internal function.");

		const Sphere& sphere = *static_cast<const Sphere*>(args->geometryUserPtr);
		RTCBounds& output_bounds = *args->bounds_o;
		SphereBounds(sphere, &output_bounds);
	},
	nullptr);

Everything else in the function is standard for dealing with custom user geometries, and I dont think that's what's relevant to my issue, but this is what returns in the console output when this code is run (at a higher level, it iterates through a function that runs these lines five times)


Calling the setGeometryBoundsFunction()'s internal function.
Calling the setGeometryBoundsFunction()'s internal function.
Calling the setGeometryBoundsFunction()'s internal function.
Calling the setGeometryBoundsFunction()'s internal function.
Calling the setGeometryBoundsFunction()'s internal function.

It never calls the intersection function.

Does anyone have any suggestions as to how to deal with this problem? Should I be defining some other function as well? I don't need any occlusion with this geometry, for instance, but maybe that has something to do with it?

@svenwoop
Copy link
Contributor

The bounds function is called when the acceleration structure is build, thus during rtcCommit of the scene. The intersect callback will get used when you trace rays and hit the box of one of the user defined primitives. Maybe you do not trace rays yet? Or the bounds you calculate are wrong? Or your rays to not hit any of the calculated boxes.

@mmomentum
Copy link
Author

It seems like the issue at hand is not that user intersections are not working (I've gotten them working on some occasions where the intersect function will call), but that running rtcCommitScene() with regular geometry seems to not be functioning properly.

I have a path tracer that checks if an intersection occurs with the scene and breaks if the intersection doesn't occur (by checking if the hit's geomID is not RTC_INVALID_GEOMETRY_ID, basically) and it seems like in some instances it works fine, but others it doesn't (and we're testing with the same code, same machine, same geometry, same everything).

Is there any way to see some kind of structured data that a RTCScene holds to help with potentially debugging this issue with breakpoints?

@svenwoop
Copy link
Contributor

You cannot look into the internal BVH structure. I assume the bounds you calculate for the spheres are not correct. Maybe an image of the artifacts could help. The sphere intersect function seems to be called at least for some pixels?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants