ScratchData LogoScratchData
Back to GDOR11's profile

flashlight - bug fixes

GDGDOR11•Created January 19, 2024
flashlight - bug fixes
2
2
35 views
View on Scratch

Instructions

arrow keys to turn and move WASD to strafe and move I know the shadows still look a bit buggy, but I had to make a compromise between visuals and performance, even after implementing ray marching

Description

First of all, the shadows feel very buggy in the first project. Thats because only 100 rays were being cast, and each ray had a width of 5. That means that a single ray is responsible for too much of the screen, and since it only knows local information about the scene, it may end up making shadows appear where they shouldn't. I solved this issue by increasing the ray count to 166. Next was performance. With 100 rays, it wasn't really an issue, but as the ray count gets higher, the performance gets worse. So I precomputed a distance field for the scene so that ray marching may be used, which improved performance a bit. But another thing that was hitting performance was drawing the shadows: in the original version, each ray draws the shadow 10 steps at a time. The new version calculates the intersection between the ray and the edge of the screen in order to draw the entire ray in a single pass. Also another issue was that when you turned the camera, you could see some light for a frame. That was fixed by raymarching as soon as the player finishes turning using a broadcast, instead of having independent loops for the player and the raymarching. Also, the shape of the FOV allowed you to see some light even without turning, so I fixed that as well by modifying the sprite. Thats all I did, it took around a day to implement everything.

Project Details

Project ID953359077
CreatedJanuary 19, 2024
Last ModifiedSeptember 3, 2024
SharedJanuary 19, 2024
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root