{"repo":"schteppe/gpu-physics.js","free":true,"listed":false,"github":"https://github.com/schteppe/gpu-physics.js","clone":"git clone https://github.com/schteppe/gpu-physics.js.git","description":"GPGPU physics for Three.js","language":"JavaScript","stars":299,"topics":["webgl","physics-simulation","javascript","threejs"],"license":null,"category":"game-templates","readme_excerpt":"GPGPU rigid body physics for Three.js ===================================== Launch demo or watch the video. NOTE: Works only on desktops with good GPUs. Full examples Single box Demos Many boxes Usage Include gp.js into your Three.js project HTML: Sample code below. See the examples/ directory for full examples. Implementation The demo is largely based on GPU Gems 3 ch. 29, Real-Time Rigid Body Simulation on GPUs. It heavily relies on the THREE.WebGLRenderTarget class and custom shaders. The simulation loop is in short: Create float render targets of size N N for bodies: position, quaternion, velocity, angular velocity, force, torque. Create float render targets of size M M for particles: local position, world position, relative position, force. Create float render target of size 4 M M for a broadphase grid. While running: Calculate particle properties: world position, body-relative position, velocity. Set up \"broadphase render target\". Stencil buffer is set up for stencil routing (see this presentation, slide 24 ) by clearing once (to set stencil values to zero) and drawing point clouds thrice to set values 1, 2 and 3 into the stencil buffer. An alternative is using PBOs to set these values, but it doesn't seem to be available in WebGL1. Particles are drawn to the \"broadphase render target\" using GL POINTS with point-size 2. This maps them into the correct \"grid bucket\" and writes the particle ID's there. The stencil routing guarantees four particle ID's can be drawn into th","default_branch":null,"files":null,"tree":[],"storefront":"/r/schteppe","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/schteppe/gpu-physics.js/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}