I was previously creating a heightmap in a shader, which I would vertically displace vertices with, and I'm changing this to instead alter the vertex position directly in the shader. I cant figure out how to actually read the vertices in my shader.
The old shader has this, it just calculates a height value and writes it to the texture
[numthreads(8,8,1)]
void CSMain(uint3 id : SV_DispatchThreadID)
{
float2 uv = GetUV(id);
int2 coord = int2(id.xy);
float h = Solve(uv);
Result[coord] = float4(h, 0.0, 0.0, 1.0);
}```
I'm trying to do the same, but get the xz position of each vertex to act like the UV, but running the new code, nothing appears to happen
```hlsl
struct Vertex {
float3 position;
};
int NumVerticesPerAxis;
RWStructuredBuffer<Vertex> VertexBuffer;
int NumVertices; // VertexBuffer length
[numthreads(8,1,8)]
void CSMain(uint3 id : SV_DispatchThreadID)
{
int index = (id.z * NumVerticesPerAxis) + id.x; // 2D to 1D
Vertex vtx = VertexBuffer[index];
float2 p = float2(vtx.position.xz);
float h = Solve(p);
vtx.position.y = h;
VertexBuffer[index] = vtx;
}```