Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any example on the web how Collision Detection can be implemented with Shaders?

Is there any OpenGL, OpenGL ES or WebGL code example on the web how 3D Collision Detection can be implemented with Shaders (preferably GLSL)?

Thank you.

like image 529
Alon Gubkin Avatar asked Dec 28 '10 14:12

Alon Gubkin


1 Answers

GLGE has shader based collision detection. See this demo. (WASD,spacebar and mouse to move around. Notice how you collide with walls, etc.)

If you look at the source code, collision detection is handled with the code

var ray=gameScene.ray(origin,[0,0,1]);

If you follow this into glge.js you'll see how this is implemented with a special render mode GLGE.RENDER_PICK (which in turn uses a picking fragment shader in pkfragStr).

like image 104
brainjam Avatar answered Sep 21 '22 00:09

brainjam