Recovering vertex shader output (array of vec3) in GDScript in Godot 3.x
Asked Answered
B

3

0

Is there any way to run a vertex shader (calculating around 100-1000 individual vec3), recovering the results in GDScript?

Hacky/workaround stuff is okay.

Summary: I have a function that takes a point in 3D space (plus a bunch of other parameters) as an input and generates an ordered list of 3D points as an output. Each input is independent of others and can be parallelized, but the points for a given input cannot be calculated in parallel.

Background/why: I am trying to write a differential equation integrator for a VR physics visualization that can integrate starting from many points at the same time to draw field lines. I have a proof of concept running on CPU, but it's not very fast and is 100% doable with a compute shader, but as far as I know, compute shaders will only be supported in Godot 4.x and I can't wait until 4.x stabilizes for this project. In some sense, this is an attempt at a port (with improvements) of a compute shader I have access to in Unity.

Things I've looked into: I believe the current way to get data out of "compute shaders" in Godot is to write to textures. I haven't tried this yet, but if this is the best approach at the moment, I'll go ahead and do it this way. I want to check that I'm not missing something important or shooting myself in the foot...

Thank you!

Boelter answered 27/7, 2021 at 0:39 Comment(0)
A
0

I don't think there's a way to do that without textures, since shaders are effectively an one-way process (CPU -> GPU).

Algo answered 27/7, 2021 at 17:28 Comment(0)
S
0

Unless you output to a viewport(essentially a render target or a "RT Texture") and then read values from there.

Swanhildas answered 27/7, 2021 at 17:38 Comment(0)
B
0

Thanks for the information! Apologies for the delayed response. I will try outputting the generated data to a viewport.

Boelter answered 28/9, 2021 at 4:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.