- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
After intersecting a ray with a scene, what is the proper way to use the u, v coordinates to calculate the world coordinates (x, y, z) of the hit? I believe from the geomID and primID, I can identify the triangle which is hit and its corresponding v0, v1, v2. But now what do I do?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just calculate ray.org + ray.tfar * ray.dir to get the hit point in world coordinates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sidenote: calculating it from uv coordinates is MUCH more precise and will drastically reduce amount of selfintersections from subsequent secondary rays.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I agree, the accuracy can be much higher when you use the u/v coordinates to calculate the hit point.You can do this the following way: Ph = (1.0f-ray.u-ray.v)*p0 + ray.u*p1 + ray.v*p2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sven,
In your example p0, p1 and p2 are 3 vertices of the triangle right?
Another question: I am trying to iteratively shoot a ray until it escapes the triangle mesh. So basically what I am doing is, I will shoot a ray and if it hits a geometry I will shoot another ray from the hit in the same direction and I will keep doing this untill the ray does not hit anything. In this case, I am constructing a ray only once and at every iteration I am just changing the ray.tnear to the previous value of ray.tfar. Is this a good way to do this? or should I calculate the exact coordinates of the hit and then shoot the next ray?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, these are the triangle vertices.
What you describe is one way of finding all hits along the ray. However, depending on your application, a more efficient way of doing this is to use the intersection filter feature of the newer Embree versions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But even using intersection filter functions, I would still have to update the ray after every hit inside the filter function right? In that case should I use u,v coordinates or just update ray.tnear for the new ray? Which is a better way of doing it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Inside the filter function you would only reject the hit by setting ray.geomID to -1. You would further put the hit into some list. However, you will gather the hits in some unspecified order.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So that means I call rtcIntersect() only once and as long as I keep rejecting the hit, the ray keeps going through?
Also, once I call rtcSetIntersectionFilterFunction(), the filter function is set, after that how do I revert back to normal behaviour, i.e. how to I detach the callback filter function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you call rtcIntersect only once and get all hits reported.
Setting back the filter function can be done in two ways:
1) reset the filter function by using the rtcSetIntersectionFilterFunction call with NULL as filter function
2) or register one global wrapper filter function, which reads a function pointer out of the ray (you can extend the ray at the end with your own data) and call this function pointer if it is not NULL. This way the feature can essentially be enabled per ray.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page