Keep in mind you’re creating thousands–if not millions–of instances that all have to be rendered frame by frame. Unfortunately there’s no way to get around this, as it’s considered largely inefficient to do work like this.
If you’re trying to reach an end goal, I’d suggest doing it some alternative method that still gets the idea across.
it’s possible, and I already did it, now I copied the previous code, replaced the pixel with an instance frame, and that’s it. I don’t understand what is wrong
You should add a wait() or something to stop stack overflow and breaking the UI. Frames can be very laggy. I have my own script where I do this:
local RAND = 36 --higher number means lower wait times/more crashes
if math.random(1,15*RAND/resolution) == 1 then
game["Run Service"].RenderStepped:Wait()
end
Creating Frames individually like this is notoriously power hungry, I’m sure once everything is created it will be all good with a general frame drop, however creating thousands of instances like this all in one go is obviously going to be a problem.
Unless you have a NASA computer, I don’t know how this is the case for you.
Sure, adding a wait will probably help out, however it would turn time consuming.
This is a real problem, I don’t know why, I copied the previous code, and generally replacing object({}) with frame instance makes it still easier, no? Yes, I even have a 512x256 render
If you can, maybe generate the pixels at set resolution, and change the color of the pixels you need after without deleting and remaking them. Add a setting to generate at the beginning. I don’t know if you are making a raytracing engine or something but Frames create Frame drops. (funny wordplay) There is another thing I don’t know if works but you could half the amount of pixels by creating a pixel with a UiGradient with 2 colors in it.
You have indeed put a task.wait() inside the x iterator, sure, but 256 frames being created instantly…dunno about that.
Especially since task.wait() is not frame dependent.
the color of the pixel is determined either by the color of the object + the overlay of light and specular with shadows, or if it does not hit the object, it is given the color of the sky
ALSO I SUGGEST FOR A STATIC COLOR BACKGROUND YOU HAVE ANOTHER SCREENGUI WITH A FULL BACKGROUND FRAME INSTEAD OF TRYING TO RENDER THE BACKGROUND IN EVERY PIXEL.
The best thing to do I suppose is to limit raycasts to a certain amount and decrease pixel resolution each frame. It is what many RTX engines do nowadays. You add more detail and reflections every frame or 2.
Just don’t make the pixel if it doesn’t hit anything on the first raycast.
If I may ask, how did you get the light to be so perfect with the brightness and darkness on the pixels? I just use a magnitude between the pixel and color the brightness using that.
local mag = ((workspace.Light.Position-RayResult.Position).Magnitude/Far)*500
Color = Color3.fromHSV(h,s,(v*5)/mag)
No, there would be no overlapping. As using table.insert(tab, value) will automatically place the value in the table +1 of the previous index.
Even so it would not cause a crash.
If inserting tables is exactly what is crashing it, it may be due to memory. Empty tables with no keys inside them take up little memory, but it’s still memory to be taken.
In this case I would revert inserting pixels into the table, and working around this problem to try and get your end goal.
Unfortunately, there’s no keen way to solve this besides decompiling Roblox Studio and changing the way it handles these things…lol.