# Compute shader: Property at kernel index is not set

I am trying to follow this excellent Coding Adventure: https://www.youtube.com/watch?v=lctXaT9pxA0 in order to get a very simple mesh deformation on a mesh using a compute shader.

I'm getting an error that reads:

I'm calling runShader() in Update (maybe that's a terrible idea, but I don't think it's contributing to this specific problem yet).

Do I need to somehow pass my mesh's vertices into StructuredBuffer<float3> vertices;? If so, how am I supposed to do that?

This is the call to the compute shader in my .cs file.

void runShader() {
computeShader.Dispatch(kernelHandle, 512, 1, 1); //this is the line it appears to be complaining about
}


This is my .compute file.

#pragma kernel CSMain
StructuredBuffer<float3> vertices;
RWStructuredBuffer<float> heights;
uint numVertices;
float testValue = 20;

void CSMain (uint id : SV_DispatchThreadID) {
if(id >= numVertices) {

} else {
float3 vertexPosition = vertices[id];
heights[id] = 1 + sin(vertexPosition.y * testValue) * 0.05;
}
}


You need "link" your StructuredBuffer to a ComputeBuffer that you initialize in the CS script. In your code, you've never specified a compute shader to write to, so the compiler is basically saying, "yo, there's nowhere to write this data to!"

In your .cs file, you should have:

void runShader() {

//New Things here
ComputeBuffer vertexBuffer = new ComputeBuffer(mesh.vertices.Length, sizeof(float) * 3); //make new compute buffer with specified size, and specified "stride"
//stride is like the size of each element, in your case it would be 3 floats, since Vector3 is 3 floats.
vertexBuffer.setData(mesh.vertices); //set data inside buffer