Hey guys, i have a question : What is the fastest way to render a bunch of pixels on the screen?
I have to render an 1024x1024 image at least 30 times / second, and the all pixels change every frame.
Using Texture2D, SetPixels and Apply causes massive lag. I do not care about depth, alphas, lighting, other objects, anything. All I need to do is to manually assign the color values of the pixels on the screen in the fastest manner possible. Something like SetPixels() but directly for the screen.
What would be the best way to do this? Is there a way to get the GPU involved? (The Pixel calculation will have to be done on the CPU tho as it is too demanding)
Would RenderTextures do the trick?
If non-power of two resolutions would be possible, that would be fantastic
Thank you!
Try Texture2D.LoadRawTextureData
It appears not to change the colors at all… It’s just a blank white image. And it does not throw any errors either. Any idea why?
Do i need a specific texture format?
This is what i’m using right now :
Texture = new Texture2D(1024, 1024, TextureFormat.RGB24, false);
Thank you very much for your answer!
Ah, my bad… Forgot to apply! Wow, thanks a lot, it is way faster than SetPixels!
Point sprites might be fastest way to render a lot of pixels to the screen. Be aware that in Unity there is a minor bug where point sprites will not be bigger than a pixel. This is due to driver differences. The point sprite specification doesn’t really guarantee they can be bigger. They are supported on all platforms to my knowledge.
I filed a bug report on it a while ago but it only affects sprites which will be larger than 1 pixel. So if pixels are your aim, you’ll be fine with point sprites.
1,048,576 pixels per frame is a lot though. Are you sure you can calculate that much data outside of a compute shader?
Thanks a bunch, hippocoder, i’ll look them up! I’m pretty new to the new Unity 2D things.
Yes, sure, i have the rest pretty much set up, all I needed was a quick way to render. And LoadRawTextureData seemed to do the trick quite well too.