Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.96 KB

README.md

File metadata and controls

41 lines (28 loc) · 1.96 KB

Unreal-Fast-Dynamic-Texture

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

Practical Example (not included):

Writing the whole map's groundwater levels to a texture to acess groundwater in materials image

How it works:

  1. Create a desired size Texture2D as a Drawing Canvas
  2. Divide the texture's area into desired number of chunks (render regions) for faster rendering
  3. Put the chunks into a 2D array where we can look up every pixel position's corresponding chunk via array[pixelX][pixelY]
  4. Write to our texture's pixel data and mark it's chunk dirty
  5. Update collects all the dirty chunks since last frame and renders them to a Texture2D we can use in materials&stuff
  6. PROFIT!!

Performance: GTX1080Ti, Ryzen 9 5900X, 64GB 3200Mhz DDR4 image

Performance: Steam Deck image

Possible improvements:

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 :)

image