Runtime writing to huge (4K+) textures at realtime framerates achived with render region chunks.
Based on Parallelcube's article Inspired by: iUltimateLP's gist, give them a read.
The demo project lets you draw to a 8K texture at realtime.
Click
with the mouse to draw, Press C
to clear the canvas, press Space
to toggle chunked rendering on/off
Writing the whole map's groundwater levels to a texture to acess groundwater in materials
- Create a desired size Texture2D as a Drawing Canvas
- Divide the texture's area into desired number of chunks (render regions) for faster rendering
- Put the chunks into a 2D array where we can look up every pixel position's corresponding chunk via
array[pixelX][pixelY]
- Write to our texture's pixel data and mark it's chunk dirty
- Update collects all the dirty chunks since last frame and renders them to a Texture2D we can use in materials&stuff
- PROFIT!!
Performance: GTX1080Ti, Ryzen 9 5900X, 64GB 3200Mhz DDR4
Currently the brush's radius is not taken into account when checking for dirty chunks. I'll only ever write single pixels to the texture and a pixel is either in one chunk or another so it's good enough for me but if you want to make a drawing game or something here's some hints :)