shaders question

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Asoth

Hello,
I am trying to write to code for my physics like getting vertex normal and stuff

it sounds like that could(?) be handled by GPU with shading language instead of by GD_script and then free the CPU from this work.

I still have ton of tutorial to view to learn by my self about it but I wish someone to tell me if yes or no, we can use shading language/GPU for things not directly related with graphics (like geometry physic) to speed up things.

is going through shading language is the only door to take advantage of the GPU?

thank you pals

:bust_in_silhouette: Reply From: Zylann

The engine does not currently implement other things than graphics with the GPU at the moment. Only classic vertex, fragment and light shaders are supported, with the addition of a special one for particles simulation.

You can still exploit shaders with an offscreen viewport and download results from it in order to do calculations that are not necessarily graphics related, but there is no official “compute shaders” API at the moment.

once again you provide me priceless answer thank you Zylann.

Asoth | 2018-12-01 04:47

Hi Zylann, this one is old now, but maybe something changed in v3.x
Can you point out to an example on how to get the data from the viewport texture?

Since i’m doing temporal steps simulation, i’m stuck on how to use the result of the shader calculation and pass it in the next step.
In CPU i would use a qty and a next_qty variabile, and swap them and the end of the calculation for each step, but in shader the result of the calculation is a viewport texture, and i cant find a way to pass it to the shader again for the next step :frowning:


edit: i created a question for this
https://forum.godotengine.org/99750/compute-shaders-hot-to-get-data-back

Andrea | 2021-04-02 08:53