Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Accessing pose-space vertex data prior to GPU skinning

Discussion in 'Shaders' started by BayouSoftware, Mar 25, 2016.

  1. BayouSoftware

    BayouSoftware

    Joined:
    Oct 7, 2012
    Posts:
    15
    Hi, I was looking to creating a damage system similar to left 4 dead 2 one outlined here:
    http://www.valvesoftware.com/publications/2010/gdc2010_vlachos_l4d2wounds.pdf
    As you can see in the paper they cull sections of the model by subtracting an ellipsoid from the mesh when it is in pose-space, I was looking to do this in Unity but I cant find much information on the skinning pipline.

    I assume the gpu skinning is done in a vertex shader pass prior to rendering but I cant find anyway to access it without scrapping the skinnedmesh renderer component and writing an entirely custom gpu skinning shader which is way outside the scope of this project as its just a bit of fun.

    Can anyone shed any light on whether its possible to achieve this within the existing unity skinning pipeline?

    Thanks,
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    Unity does CPU skinning normally, or with DX11 does GPU skinning in a way that pre transforms the mesh before the shader sees it. Either way there's no way to get the vertex positions unmodified.

    It's still possible to do what you want though. Just store the initial vertex positions in the vertex color, across two texture uv slots, or in another texture assuming you have unique UVs for the character. Vertex color would be the easiest, and you can use an interpolated half3 instead of the incoming fixed4 value to get smooth positional information in the pixel shader.
     
    BayouSoftware likes this.
  3. BayouSoftware

    BayouSoftware

    Joined:
    Oct 7, 2012
    Posts:
    15
    Ahhhh I didnt think of that at all, thats a great idea thanks bgolus!