Hi so I feel kinda dumb saying that but I have no idea how compute shaders work. All I know is that they run on gpu instead of cpu and here I shot myself in the foot. I have downloaded a low poly water model from the asset store but after some backtracking I noticed it the waves are generated using a c# script. I an attempt to optimize I wanted to open a new thread though I can’t read the position then, so now I am here. If someone could optimize it or post resources for me I would love that.
This is the asset I use and here is the code for the waves:
for (int i = 0; i < vertices.Length; i++)
{
Vector3 v = vertices[i];
//Initially set the wave height to 0
v.y = 0.0f;
//Get the distance between wave origin position and the current vertex
float distance = Vector3.Distance(v, waveOriginPosition);
distance = (distance % waveLength) / waveLength;
//Oscilate the wave height via sine to create a wave effect
v.y = waveHeight * Mathf.Sin(Time.time * Mathf.PI * 2.0f * waveFrequency
+ (Mathf.PI * 2.0f * distance));
//Update the vertex
vertices[i] = v;
}
//Update the mesh properties
mesh.vertices = vertices;
mesh.RecalculateNormals();
mesh.MarkDynamic();
meshFilter.mesh = mesh;
Thats the entire wave code thats causing trouble. In Update is nothing but this method.
