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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

GPU geometry processing/generation

Discussion in 'Shaders' started by DarthCoder, Mar 25, 2015.

  1. DarthCoder

    DarthCoder

    Joined:
    Aug 8, 2013
    Posts:
    6
    I'm working on a few effects that are going to require generating geometry on the GPU for each frame and then rendering it in a separate draw call. I'd like to be able to use some sort of append buffer that gets filled by the vertex shader on each object and just draw it at the very end as a post-processing step. What I'd like to do is basically this:
    1. In object's vertex shader, add selected points to a global buffer
    2. After all objects have drawn, draw the buffer of points over the screen with a geometry shader to generate triangles
    What would be the best way to accomplish this in Unity? In C++ and DX11 I always just used stream output for this kind of effect, but I can't figure out how to get data out of the vertex/geometry shader in Unity.
     
  2. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Theres no stream output stage (DirectX) or transform feedback (OpenGL) support from scripting in Unity as far as I am aware.

    You can get the same results if using dx11 however.

    You can run the geometry shader and append the data you want into a append buffer and just dont output anything from the geometry stage so the fragment stage wont run. Pretty much the same effect as stream output.

    There is a dx11 example project from Aras which can be found on this page. I think it has a example that is very similar to what you want.
     
    DarthCoder likes this.
  3. DarthCoder

    DarthCoder

    Joined:
    Aug 8, 2013
    Posts:
    6
    Thanks, that's just what I needed.