Click the green flag and wait to load This will run alright on Scratch, but it will take a very long time to load(it took me 30 minutes). Turbowarp link: https://turbowarp.org/872056937?stuck&hqpen&fps=60 WASDQE for movement Arrow keys for camera rotation Settings for "C: Raytraced Diffuse Baker": #Settings: Grid Divisor This value cubed will be how many voxels exist for the scene. Be careful with setting this volume too high, as the DFS algo can cause a browser JS error(in TurboWarp) #Settings: Traversal Algo 0 = No traversal algo; just test against every polygon 1 = Grid DDA 2 = Octree DDA
WHAT IS THIS? This build features a new "sub-engine" which uses raytracing to bake diffuse lighting. It features an octree DDA algorithm and global illumination(GI), most prominently. I started making this beginning of July 2023. So some hours over about 2 weeks of work. This raytracing engine can be muted, or even deleted, and the rest of the project should run fine. However, it is dependent on the shadow baker, and that sprite cannot be deleted. I also made minor changes to the shadow and basic diffuse baker engine, as well as some other sub-engines. There are settings in the raytraced baker which you can change and whatnot. The only global variable/list which the raytracer can edit is the "Lighting: Diffuse Primitive Lighting" variable. FURTHER NOTES AND SOME THANKS: Tysm @piano_miles for all your help over the years <3 @SpinningCube helped with some of this, as well as a couple other people. Pathtracing code is referenced from @sureornot's pathtracer: scratch.mit.edu/projects/553851466/. Octree code is based from 's implementation(the generation code is roughly the same): Also, I finally found a good use for 's Tri-AABB collision detection algo. Yes, of course it can be optimized, but I'm a bit lazy for that. I used various online sources to figure out a lot of the algos, especially stack exchange for uniform random distributions and whatnot. One of the issues I ran into while creating this project had to do with the step where each polygon was linked to the voxel grid. The algorithm went as followed: break every polygon into a triangle, take the first vertex of each triangle, and find which voxel contains it. Use this voxel as a seed for a Depth First Search(DFS) on the grid. The DFS rules are to find which adjacent voxels intersect with the triangle, and to traverse on the voxels which do. The problem which I encountered was that even with a small map size (>15^3), trying to traverse the whole map resulted in an internal browser JS error: "Maximum call stack size exceeded" This only happened on the TurboWarp compiler, as TW's recursion limit is what the browser's JS allows. So basically, there may be a chance of this project suddenly stopping at the voxel generation phase. Also, if you want to increase the voxel grid divisor(: Grid Divisor) in the raytracing engine, do so knowing that it might cause problems. Also, the grid divisor must be a power of 2 in order for octree gen to work properly. CREDITS: 3D BSP sort adapted from 's 2D BSP sort. Compare the code, which can be found here: I used 's tri-AABB code for triangle-voxel collision(found on 's profile): Triangle filler by (): The original octree gen/traversal algorithms by :