I'm working on a raycasting system that processes a 31x31x31 grid. For each of the approximately 5,766 directions, I check 15 points in the array to determine if they're solid. When a solid point is found, I set all points beyond that to shadow. Although each ray takes just nanoseconds due to some optimizations, the sheer volume of these checks adds up quickly, especially since I need to run this multiple times. I'm looking for ways to achieve less brute force and improve efficiency without compromising the results.
2 Answers
Have you thought about using larger colliders? If you set those up, you could skip raycasting altogether in areas with no collision. It’s often more efficient to check big sections instead of individual points.
It sounds like you're creating a line of sight (LOS) system. Have you considered how casting rays from every cell simultaneously might be slowing you down? For example, if you have several cells lined up and the middle one is solid, you need to think about how to handle the shadows correctly. If the sequence is empty, solid, empty, it could lead to shadows being set incorrectly. Simplifying the casting logic might help!
Yeah, exactly! If you cast from the center to the edges and register shadows based on hits, it should correctly represent light dynamics — something like shadow on both sides of a solid.

What do you mean by that? Can you explain how colliders would replace raycasts?