Efficient passing variable from Unity script to shader
Hello everyone, I am using HTC VIVE and trying to build an app where users are able to color the volume by moving controller. The way I tackle this problem could be composed of 2 parts:
in the unity script, I create a list to store all controller's position in each frames;
Then, I would pass the list to a customized shader, which will set the fragment to the defined color (let's say red);
To pass the list to the shader, I used the Material.SetComputeBuffer() in the unity script. However this approach seems taking tremendous amount of time to pass data to shaders, causing frames are visually "choppy" in VR. Wondering what's the fastest way to pass data to shader (or mutate data that shader could access)? Any hints would be appreciated?
Thanks a lot!