Played with https://github.com/Unity-Technologies/ml-agents
I fed a cat line art and let the agents to learn the path from the middle of the texture. After a few hours they are able to go within the line xD
Tried another random cat generator without machine learning xD
(3D by StungaLab)
Using Graphics.DrawMeshInstancedIndirect so that I can calculate the fish positions with compute shader.
The moving tails are just vertex displacements in shader. Rotation are also done in the rendering shader.
Below is the look-at matrix that takes the normalized velocity to be the rotation, and to be the forward axis.
Continue reading “Fishes”
Originally I have in
_floatArray = new float;
_floatArray = 1f;
_floatArray = 0.5f;
And use ComputeShader.SetFloats() to pass the values from C# to Compute Shader.
Reading the values in Compute Shader, I found that only FloatArray has the value. So FloatArray will equals to 0.
Unity dev (Marton E.) replied me that:
Continue reading “ComputeShader.SetFloats()”
If you want to do something like this:
In C# : You need a for loop which
-> iterates a few ten-thousands vertices, and then
-> for each vertex, you need to calculate the distance between each bead…
All these instructions are run 1 by 1 on CPU. You can imagine the time needed for this.
But with compute shader, those several ten-thousands iterations can be done “at the same time” in GPU (it depends how you setup the data). And the result data will be transferred back to CPU, and directly apply to Mesh.vertices array.
And this is what you can see in this video, the fps stays above 70.
Update: This can be done much faster using AsyncGPUReadback. Visit here for example: https://github.com/cinight/MinimalCompute
Direct means CPU tells GPU to execute work, amount of work is given by CPU
Indirect means CPU tells GPU to execute work, amount of work is calculated in GPU
Continue reading “Indirect Compute Shader”