Page 1 of 1

GPU and Raycasts

Posted: Thu Jan 14, 2016 11:17 am
by RifleRound
Hi there :-)

I am writing my Bachelor-Thesis about pathfinding with Raycasting (Raycasting to check the object intersected by a ray)
and .... well it would be great if you could give me some answers^^


1. Are Raycasts in Bulletphysics processed by GPU or CPU?
2. Is it possible to make them processed by GPU (if CPU) / or CPU (if GPU)?
3. Could you give me a link of the proof of the answer I can put in my Bachelorthesis ... like... you know... something "official". Like an article from one of the dev's or something. Or a class in the Engine's Documentation which is telling that the Raycasts are processed by CPU (or GPU)
4. Do you know another Engine which processess Raycasts with GPU ? (or CPU)?

i would be very very very thankful :-)

cheers!

Re: GPU and Raycasts

Posted: Sun Jan 17, 2016 3:15 am
by Evan407
RifleRound wrote:Hi there :-)

I am writing my Bachelor-Thesis about pathfinding with Raycasting (Raycasting to check the object intersected by a ray)
and .... well it would be great if you could give me some answers^^


1. Are Raycasts in Bulletphysics processed by GPU or CPU?
2. Is it possible to make them processed by GPU (if CPU) / or CPU (if GPU)?
3. Could you give me a link of the proof of the answer I can put in my Bachelorthesis ... like... you know... something "official". Like an article from one of the dev's or something. Or a class in the Engine's Documentation which is telling that the Raycasts are processed by CPU (or GPU)
4. Do you know another Engine which processess Raycasts with GPU ? (or CPU)?

i would be very very very thankful :-)

cheers!
An entire thesis on ray casting seems a bit much but I'll fill you in on my methods. When a user clicks on the screen there are two points a near and a far point. The near point is closest to the screen and the far point is farthest away. The screen coordinates have to be converted to the world coordinates and this can be done by the use of an inverse matrix. (The inverse of the "mvp" or whatever. I use row operations to calculate the inverse matrix) After getting the near and far point hero's formula can be used to calculate the distance any giving point is from the line of sight. This is very accurate :D
and comprehensive compared to alternative methods

see the attached image or look at this one
Image
Point A is the near point and B is the far point. Line AB is the line of sight. To calculate how far point C is from the line of sight:
1. find the area of triangle ABC using HERO's formula after calculating the distances of the triangle's sides (<3 hero's formula)
2. use the area of the triangle to calculate the height where AB is the base (area = base * height / 2)
That height is the distance from the line of sight point C is.
An elementary check can be performed to test if the point is behind the camera, simply if angle A is obtuse then the point is behind the camera.
Finding the distance between two 3d points is not so bad.

I hope you enjoyed learning about my methods :)

Re: GPU and Raycasts

Posted: Sun Jan 17, 2016 3:25 am
by Evan407
on another note about using the GPU to do it "OpenGL picking using the selection buffer is deprecated."

Re: GPU and Raycasts

Posted: Sun Jan 17, 2016 12:48 pm
by RifleRound
Thanks for the answer (though its not an answer to my questions)

i need that answers - its very important.

Can I somehow contact the devs or something? :/

Re: GPU and Raycasts

Posted: Tue Jan 19, 2016 3:36 am
by Evan407
Using the GPU for heavily multithreaded tasks is really nice but also rather hacker. If a large number of ray casts needed to be computed then yes it could be done on the GPU for improved performance. However if it was only a single ray cast the normal CPU would probably be better.

Re: GPU and Raycasts

Posted: Tue Jan 19, 2016 1:04 pm
by RifleRound
but where do I know I can trust your answer?
(not that i wouldnt believe you)
i need some official stuff.
Like some official dokumentation for my prof.
you know what i mean?

Re: GPU and Raycasts

Posted: Thu Jan 21, 2016 5:48 pm
by Evan407
I stumbled upon this video where they use a lot of ray casting to simulate realistic light reflection.
https://youtu.be/4BeqGY2RwcI?t=4m10s

It is much more official I think it would be good for your paper.

Re: GPU and Raycasts

Posted: Fri Jan 22, 2016 9:05 pm
by RifleRound
You mean Raytracing.
Its to simulate the reality of the 3D - like the reflection.

BUT Thanks for that Video :-)

its helping me for a few other matters :-)

Re: GPU and Raycasts

Posted: Mon Feb 01, 2016 4:12 pm
by Evan407
I came across this today while reading the manual
https://github.com/bulletphysics/bullet ... Manual.pdf
(if it doesn't work click on "Raw")
see page 38

https://en.wikipedia.org/wiki/OpenCL
cool stuff :wink: