Can someone help me optimize my camera?

I’m working on making a low resolution camera so I can take pictures in my game. This is the viewport though which players will be looking at to take the pictures. Currently it runs at around 3 fps on my laptop. (Couldn’t imagine why lol)

How I'll take pictures (irrelevant)

I’ll add a button in the future, that’ll duplicate the pixelArray, and save the duplicate.

And when I want to view the pictures, I’ll just reconstruct it (hence why I have my pixels named the way they are)

---------------------------------------------------

seeInTheDark.rbxl (61.7 KB)

Thanks!

It’s not possible to optimise this because of how it’s done. You’re calculating 198 raycasts with a length of 1000 studs every single frame.

I’m not calculating 198 raycasts… I’m calculating 100^2 or 10,000 :joy:
So there isn’t a way to optimize my code further? Maybe there’s another method I can do? Thanks!