Skip to content

u/erickweil

In this archive from May 2020 to Oct 2023

2
posts
8
comments
2
media
330
score

Top posts

Top comments

(Source on https://github.com/erickweil/GodotTests/tree/v4.2-beta1)

This demo shows how it is possible to generate millions of vertices of procedural geometry using compute shaders, without requiring a single CPU read.

It works by creating a Texture2DRD texture with a RGBA float as-is format, it means I can store any float values on this texture, the compute shaders then proceed to calculate the torus Signed Distance Field (found on https://iquilezles.org/articles/distfunctions/) over the span of the grid (128*128*128), when a cell is found to contain the surface, it outputs the corresponding quads, writing their vertex positions and normals on the texture (1024*1024). Then a normal .gdshader takes this texture and using texelFetch (to prevent sampling issues) gathers the correct position and normal it should have. the key thing here is: NO CPU READS, since that would degrade the performance to unaceptable amounts.

There are some caveats, first this only works on 4.2 beta 1 because of the only way of doing this without a viewport is using the new Texture2DRD (Also the viewport would not have the floating point format so idk if is feasible either), another problem with this approach is somewhat high memory usage (One texture per mesh like this) and that the mesh needs to have as many vertices as the maximum that will be ever produced to prevent glitching, leaving a lot of vertices that read (0,0,0,0) pixels and just create overhead.

21 points

Keep in mind since this uses compute shaders, will not work on all hardware, and I only tested in two setups: Linux with Intel i5-1245U onboard graphics and Windows with GTX 1650.

In my main project i'm working on (4D Game) I have working alternatives that doesn't use compute shaders, even if they are inefficient it's better to give not the best performance than a error screen.

And finally I want to apologise for your stress trying run untested crappy patched random reddit linked github code.

2 points

Subreddits

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.