ScratchData LogoScratchData
Back to 0e7spaceship's profile

3D BBBSP Testing

0E0e7spaceship•Created June 1, 2025
3D BBBSP Testing
41
35
289 views
View on Scratch

Instructions

WASDQE to move Arrow keys to rotate hold Space to show the separation planes G to generate a random test scene with lots of intersecting planes T to view the BSP tree in a list H to hide the list

Description

Ok so I randomly had this idea two days ago and I got really motivated to start making projects on here again. Hopefully it lasts long enough for me to actually make a game out of this :) This is a test for a new 3d rendering system. My goal is to create a 3d game that runs at 30fps in scratch even on my slow laptop. One of the biggest challenges to create 3d games in scratch is figuring out what order to draw the objects. This system uses a modified version of Binary Space Partitioning (aka BSP) to sort the objects by depth. BSP solves this challenge by creating a tree of objects, where each plane keeps track of the set of objects that are in front and behind it. The modification I made to the BSP algorithm was to keep track of a bounding box at each node of the tree, and only split the polygon if its bounding box intersects the bounding box of the splitting plane. In the case where the bounding boxes do not intersect, it is easy to generate a splitting plane that does not split either polygon. (I call this method BBBSP for Bounding Box BSP) My hope with this method was to reduce the number of slices, which would hopefully reduce the number of triangles we need to draw. (I haven't actually done any testing to confirm if/how much it actually helps) I made this only use axis aligned rectangles as the objects because it is a lot simpler to code, but I think I could pretty easily extend this method to work with any flat polygons in any orientation.

Project Details

Project ID1183456380
CreatedJune 1, 2025
Last ModifiedJune 10, 2025
SharedJune 4, 2025
Visibilityvisible
CommentsAllowed