GPU and Raycasts

Post Reply
RifleRound
Posts: 4
Joined: Thu Jan 14, 2016 11:09 am

GPU and Raycasts

Post 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!
Evan407
Posts: 22
Joined: Sun Jan 17, 2016 2:37 am

Re: GPU and Raycasts

Post 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 :)
Attachments
Untitled.png
Untitled.png (11.78 KiB) Viewed 7318 times
Evan407
Posts: 22
Joined: Sun Jan 17, 2016 2:37 am

Re: GPU and Raycasts

Post by Evan407 »

on another note about using the GPU to do it "OpenGL picking using the selection buffer is deprecated."
RifleRound
Posts: 4
Joined: Thu Jan 14, 2016 11:09 am

Re: GPU and Raycasts

Post 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? :/
Evan407
Posts: 22
Joined: Sun Jan 17, 2016 2:37 am

Re: GPU and Raycasts

Post 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.
RifleRound
Posts: 4
Joined: Thu Jan 14, 2016 11:09 am

Re: GPU and Raycasts

Post 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?
Evan407
Posts: 22
Joined: Sun Jan 17, 2016 2:37 am

Re: GPU and Raycasts

Post 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.
RifleRound
Posts: 4
Joined: Thu Jan 14, 2016 11:09 am

Re: GPU and Raycasts

Post 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 :-)
Evan407
Posts: 22
Joined: Sun Jan 17, 2016 2:37 am

Re: GPU and Raycasts

Post 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:
Post Reply