0 votes

I'm trying to use shaders for speedy calculations, and I want to create a texture3D, set it as a uniform input variable to a shader, run the shader code once, and then read the texture3D data afterwards

How would one do so?

in Engine by (141 points)

1 Answer

0 votes

You can't read it directly from the shader.
You make use of a viewport.
add a sprite child to it.
add the shaders to it.
modify it all.
then get the texture from the viewport itself.

by (271 points)

Hm... yes, I know in particular how to setup a shader through the Editor. I use spatial shaders, so through the Editor I'm able to add a MeshInstance, a Mesh, a ShaderMaterial, and then finally a Shader to it. This much is clear.

My question has to do with having precise control over the Shader execution. Say that I setup the above through GDScript, and that I'm able to set a uniform input to the Shader. How then do I tell the code to say only run the Shader program once? Such that I set my input, I run the Shader only once, then I am able to read the output (in form of the texture). How does one do so?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.