-
Notifications
You must be signed in to change notification settings - Fork 37
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
Obtaining all hits #17
Comments
Hi, thanks, I'm happy you like the project! yes, it is possible to let the ray pass through spheres, but not with You need to write a new geometric primitive type. Untested and partly copied from an older project:
If you in addition want to use BVHs, the primitive type needs to implement
With that code How secondary rays are spawned is described in a kernel. Check here: https://github.com/hlrs-vis/covise/tree/master/src/OpenCOVER/plugins/ukoeln/PointRayTracer and specifically that file: https://github.com/hlrs-vis/covise/blob/master/src/OpenCOVER/plugins/ukoeln/PointRayTracer/PointRayTracerKernel.h for code where ray tracing for point clouds (only primary visibility, no shading) is implemented. You could adapt this kernel and e.g. spawn new rays with reflect() or refract(). It would be helpful to know if you need shading etc. - then you could maybe use one of the builtin kernels. Hope this helps, please let me know if you need more examples or help with a specific task. |
May however be that I slightly misread your question. a.) in order to get the 0,1, or 2 possible intersections of the ray with the sphere, you need something like the b.) another way to get the 2nd intersection (the one where the ray travels through the sphere and hits the far side of the surface) can however also be obtained by calculating the refracted ray that goes from the first hitpoint into the material, like e.g. the Maybe you can provide a slightly more detailed description of your use case. Do you e.g. need shading at the surfaces? If so, only perfect specular phenomena (mirror reflection, perfect refraction)? If so, maybe the Cheers, |
Thanks for the detailed response. Basically the spheres are "irrelevant" in terms of shading and material properties. They are just used to the ray tracer has something to intersect. I am looking for the ray to intersect the sphere (so I can derive the x-y image coordinates of this sphere in the image), I then want the ray to pass-through the sphere and intersect any co-linear sphere in the model which would map to the same pixel should the first sphere not have been there. Having this information I can then mark the spheres in the model which were occluded by different parts of the model. So for instance, if a tree occluded some ground points, I can then go and colour these ground points in the model. Then if I take a second view of the scene I can assess which ground points now become visible in the new view of the scene, that weren't visible in the first view. In my application different types of occlusions have different properties to understanding the image. Thus I need to have the ray continue through the sphere (only intersect the front surface of the sphere, and then move onto the next sphere in the model if one exists. In the more advanced case I'd like to say if the ray intersects the sphere, the above-explained occurs, but a second ray is also propagated which is a reflection off the sphere. But I think I'd be able to solve this once I have a better grip on how to solve the first part.
|
This sounds pretty much as if the The gist of it (TL;DR):
gives you an array with the 16 first hits along the ray. You need to figure out an upper bound for N (can be large, template parameter is size_t). You then get a sorted list of all the hits, sorted by ray parameter
DetailsMaybe your code can look like the following (basically pseudo) code. See the smallpt example (https://github.com/szellmann/visionaray/tree/master/src/examples/smallpt) for dealing with spheres, and the multi-hit example (https://github.com/szellmann/visionaray/tree/master/src/examples/multi_hit) for multi-hit and for using BVHs. (Please use BVHs. Ray tracing millions of spheres will take forever otherwise.) You can go with
Then build a bvh from that, e.g. like that:
The thing with Visionaray is that BVHs are actually (compound) primitives, too. This gives flexibility. So rather than traversing a list of sphere primitives with multi-hit, you traverse a list of BVHs (only your list has only size one). You should construct the list like so (i.e. use bvh-refs, basically POD pointers to BVHs):
See also: https://github.com/szellmann/visionaray/wiki/Acceleration-data-structures-and-traversal for details and rationale. I assume your application generates the rays on its own (probably from the surfaces of some other geometry present in the scene), right? So you can, somewhere in your C++ code, come up with a list of rays:
Then write a loop over all rays. Try to isolate this part so that you can have this loop over all rays, rather than tracing individual rays from within your app (the latter is of course possible, but looping over the ray list is faster for certain):
When you iterate over the list, using index RemarksWith that you have a CPU implementation. Going from there to the GPU with CUDA is straightforward and can be done within 30min or so. You basically use Your workload sounds rather coherent. If you opt for using CPU, consider using If you have really large workloads (like billions of spheres), it may actually be better not to make a copy of all the spheres, but rather promote your own sphere type (which your C++ application has for sure) to be compatible with Visionaray. But that's probably something to consider in the future. Not sure if your application should exactly look like this, but from my understanding this should at least give you lots of pointers. Please feel free to ask if there's more questions, problems, or you need help! |
Hi,
Firstly this project is great, really excellent work!
I have a problem I am trying to solve, and currently have a solution using POVRay, however, the solution is slow and bulky and I think visionaray could help speed it up but I'm a bit lost on the approach to take.
Basically, I have a very low-resolution point cloud, made up of spheres, and I need to know to which x-y image coordinates each sphere gets projects to, as well as whether the sphere is occluded by other parts of the scene. Is there a way to get the intersection with a sphere, but then allow the ray to pass through that sphere, as well as reflect off of it (so I can get which pixels in the image plane are combinations of which scene pixels?)
My current POVRay approach is to raytrace each sphere independently of the others, and then apply a lot of post-processing and additional simulations to get all the information required. However, even when running on 40 cores, it can take weeks for the 3million points I have.
Thanks :)
The text was updated successfully, but these errors were encountered: