PySoy: Shader Collision Testing
completed by: Samuel Kim
mentors: Arc Riley
Write a shader which, for each 4-value float texel in the format of XYZR, compares the distance squared of that value and all following values in the texture, and for each which collide set an appropriate bit in the output texture.
If body data for a scene isn't being stored in a texture yet (this is a different task) use dummy data to test your shader. You can assume a limit of 16 bodies per scene as we'll be implementing binary space partitioning, so GLushort is sufficient for output texture type.
As we work our way into shader-based physics, we need basic body data in each Scene stored as texture data. Immediately before collision detection, copy the following data for each body into a 1D float texture;
- position x
- position y
- position z
- radius squared
The radius squared of two respective bodies will be compared to distance squared to determine whether the two bodies may be colliding. For a Box
, use one of the outer edges of the box as the radius.
There will have to be some way to reference a body from a given position when the output texture is returned from the GPU.
While working on this task you should join and remain in #PySoy on Freenode to get help, feedback, and guidance from mentors and other developers. Code updates which may affect your work are also announced here as they happen.
When you've done, commit your work and post the resulting changeset url to this task.