I am trying to a achieve a smearing effect (example) on meshes and I am doing it via compute shader. While it works fine for a normal mesh. I can’t get it to work on a skinned mesh. The skinning process seems to overwrite all changes done by the compute shader. Is there any way to execute my compute shader after the skinning process?
I did some more digging and after installing RenderDoc I noticed that my compute shader allegedly has no bytebuffer set. Even though I set the buffer in LateUpdate.
Late Update Code
private void LateUpdate() {
GraphicsBuffer vertexBuffer = null;
if (renderer.vertexBufferTarget.HasFlag(GraphicsBuffer.Target.Raw)) {
vertexBuffer = renderer.GetVertexBuffer();
shader.SetBuffer(kernelID, "vertices", vertexBuffer);
shader.SetInt("stride", vertexBuffer.stride);
shader.SetInt("vertexCount", vertexBuffer.count);
} else {
Debug.LogWarning("Vertex buffer isnt set as raw!");
}
shader.Dispatch(kernelID, Mathf.CeilToInt(renderer.sharedMesh.vertexCount / 256f), 1, 1);
if (vertexBuffer != null) vertexBuffer.Dispose();
}
RenderDoc
Turns out GPU skinning was turned off. I assumed it was on. Turning it back on fixed the issue.
1 Like