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?

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