- Home /
Can I receive values from Compute Shader?
Hello,
I am interested in Compute Shader.
I know Compute Shader used to post effect, but I wonder if it can use for simple calculation.
For example, can I input 2 floats to Compute Shader and get the sum of them?
Answer by HarshadK · Nov 18, 2014 at 10:06 AM
Yes, you can.
You need to use the ComputeShader.GetData() function for this.
Pass an empty floats array to the shader and then access that floats array using GetData function above.
But Compute Shaders should not be used for such a trivial tasks because of the high latency between GPU and CPU.
For more details read this thread: ComputeBuffer.GetData
Thanks Harshad$$anonymous$$.
I have seen some Compute Shader samples, but they don't return value. So I wondered if Compute Shader can return value.
GetData function and that thread are what I want.
Thank you very much!
Your answer
Follow this Question
Related Questions
Debugging Tools for Unity Compute Shaders 2 Answers
Do uninitialized RenderTexture areas lead to wrong texturing (tiled RenderTexture problem)? 1 Answer
Differences between DrawMeshInstanced & DrawMeshInstancedIndirect 0 Answers
GraphicsBuffer for vertices inquiry 0 Answers
How to map AsyncGPUReadbackRequest to the buffer it read from? 0 Answers