Compute shader strange error.

Hi all,

I’m not really used to ask for help as i prefer roaming the docs and already proposed solutions but here i’m getting quite stucked
Here it is i have a compute shader and the C# script which goes with it used to modify an array of vertices on the y axis simple enough to be clear.

but despite the fact that it runs fine the shader seems to forget the first vertex of my shape (except when that shape is a closed volume?)

so here it is the C# class :

    Mesh m;
	public bool stopProcess = false;
	MeshCollider coll;
	public ComputeShader csFile;
	Vector3[] arrayToProcess;
	ComputeBuffer cbf;
	ComputeBuffer cbfOut;
	int vertexLength;
	// Use this for initialization
	void Awake() {
		coll = gameObject.GetComponent<MeshCollider>();
		m = GetComponent<MeshFilter>().sharedMesh;
		vertexLength = m.vertices.Length;
		arrayToProcess = m.vertices;
	}

	void Start () {

		cbf = new ComputeBuffer(vertexLength,32);
		cbfOut = new ComputeBuffer(vertexLength,32);
		csFile.SetBuffer(0,"Board",cbf);
		csFile.SetBuffer(0,"BoardOut",cbfOut);

	}
	
	// Update is called once per frame
	void Update () {
			csFile.SetFloat("time",Time.time);
			cbf.SetData(m.vertices);
			csFile.Dispatch(0,vertexLength,vertexLength,1);
			cbfOut.GetData(arrayToProcess);
			m.vertices = arrayToProcess;
			coll.sharedMesh = m;
	}

And my compute shader script :

#pragma kernel CSMain

RWStructuredBuffer<float3> Board : register(s[0]);
RWStructuredBuffer<float3> BoardOut : register(s[1]);

float time;

[numthreads(1,1,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
	float valx = (sin((time*4)+Board[id.x].x));
	float valz = (cos((time*2)+Board[id.x].z));
    Board[id.x].y = (valx + valz)/5;
    BoardOut[id.x] = Board[id.x];
}

At the beginning i was reading an writing from the same buffer but as i had my issue i tried having separate buffers, but no success still the same…

Maybe i misunderstood the way compute shaders are supposed to be used (and i know i could use a vertex shader but i just want to try compute shaders for further improvements…)

To complete what I said, I suppose it is related with the way vertices are indexed in the Mesh.vertices Array…

I tried a LOT of different Blocks/Threads configuration but nothing seems to solve the issue combinations tried :

Block            Thread   
60,60,1         1,1,1
1,1,1           60,60,3
10,10,3         3,1,1

and some others i do not remeber… but i thing the best configuration should be something with a good balance like :

Block : VertexCount,1,1 Thread : 3,1,1

About closed volume i’m not sure about that because with a Cube {8 Vertices} Everything seems to move accordingly but with a shape with an odd number of vertices, the first (or last did not checked that yet) seems to not be processed

I Tried with many different shapes but subdivided Planes are the most obvious, one corner is always not moving…