TokisanGames / Terrain3D

A high performance, editable terrain system for Godot 4.
MIT License
2.1k stars 122 forks source link

Implement GPU Painting #174

Open TokisanGames opened 1 year ago

TokisanGames commented 1 year ago

Painting large areas like a mountain is quite difficult, and smoothing is impossibly slow.

There are some pending issues in Godot that may be needed before it is feasible:

However there are these possibilities right now:

  1. Zylann reports that his GPU painter can read and write 32-bit floats, with some encoding, but it's lossless and sufficient to allow GPU painting
  2. Bastian Olij recently merged updates to compute shaders and says we now have everything we need. He made a demo showing a compute shader texture
  3. Completed: Vulkan: Cannot retrieve HDR texture from Viewport (LDR texture is returned instead)
Saul2022 commented 1 year ago

And also when using a bigger brush size, it becomes too laggy to even move, because of the lack of that.

Oracuda commented 1 year ago

couldn't this just be done by drawing to a canvasitem then using get_texture and reuploading the texture to gpu? wouldn't be more ideal than using sub texture but its what zylan's implementation does afaik

TokisanGames commented 1 year ago

@Oracuda drawing to a canvas item means drawing to a viewport, which requires a 16-32 bit viewport, and hasn't been available until recently. See # 3 which provides 16-bit viewports. That still might produce artifacts under certain circumstances, and we may still need partial updates on textures.

I think the compute shader is going to be the way to go as we won't be limited by format.

ArtyIF commented 9 months ago

I'd suggest letting the user increase the size manually by typing in a bigger value into the textbox. I've gotten tolerable performance on brushes as big as 500m after increasing the brush size limit.

TokisanGames commented 9 months ago

@ArtyIF allowed in 1ff769d