Skip to content

u/erickweil

In this archive from May 2020 to Oct 2023

2
posts
8
comments
2
media
330
score

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

(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

I'm migrating a slice based 4D Game I was developing in Unity, and two days in managed to get the first shader working and I'm already with a 4D rotating cube.

In all definitions the game VIEW is 3D, but the world and physics isn't, it's like if you could play 2d mario in a 3d world, where the 2d plane he sits in rotate to allow movement in the third axis and see the rest oc the scenario otherwise hidden.

Things that made me think twice:

  • I choose C# because 90% of my logic isn't Unity dependent at all, so I hope it will be minor refactorings. But webGL builds doesn't work yet when using C#, so I'm limited to Desktop
  • Because I choose C# and my use case involves generating procedural Mesh Data, I'm worried about performance issues with interop and Marshaling, maybe the 'game mode' would lag only at start but the 'editor mode' will be just too slow (should I lose all hopes in webGL and use Compute shaders and/or C++?)
  • I found that yet Vector4 is supported, when passing data to ArrayMesh it expects a Godot.Variant, and a array of Vector4 aren't accepted, So I needed to do a c# marshaling hack to convert it to a Span of floats before sending (Almost all other types are accepted as Variant, seems like whoever added Vector4 to the engine just forgot this)
  • This one is a Unity migration minor issue, components in Vector2,3,4 are capitalised (v.X ) unlike Unity. Also took a bit of googling to find that Godot's Projection is equivalent to Unity's Matrix4x4

The Godot project I just started working on is on Github on https://github.com/erickweil/Godot4D

1 points

End of this list.

Back to top

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.