Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Send DirectCompute output (mesh vertex position) to vertex shader's POSITION

Discussion in 'General Graphics' started by ahmidou, Apr 18, 2018.

  1. ahmidou

    ahmidou

    Joined:
    Sep 17, 2012
    Posts:
    87
    Hi,
    I'm using a compute shader to deform Mesh and would like to directly send the position buffer to existing vertex/surface shaders without having customize/patch them.
    Is there a specific keyword to override the global POSITION buffer? Or maybe another way?

    like:
    Code (CSharp):
    1. computeShader.SetBuffer(deformKernel, "Output", output[0]);
    2. computeShader.Dispatch(deformKernel, threadGroupsX, 1, 1);
    3. _matPropertyBlock.SetBuffer("POSITION", output[0]); // what should I do instead?
    4. for (int i = 0; i < mesh.subMeshCount(); i++)
    5.       Graphics.DrawMesh(mesh, Matrix4x4.identity, material[i], 0, null, i, _matPropertyBlock);
    Thanks