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

Building and shading a procedural mesh on GPU

Discussion in 'Shaders' started by JamesAlliban, Dec 6, 2016.

  1. JamesAlliban

    JamesAlliban

    Joined:
    Mar 12, 2014
    Posts:
    4
    HI All. I'm quite new to Unity but have a fair amount of graphics programming experience. I'm planning a project in which a lot of geometry will be generated and then animated on the GPU. This needs to involve dynamic shadows, texture mapping, other shading/post processing effects and dynamic smoothed normal calculation. I've achieved this previously using OpenGL via openFrameworks and am excited to try it in Unity with Compute Shaders and DX11.

    Is this possible while keeping everything on the GPU? If so, what would be my best route (ideally using Unity's built in shadows)? My first thought would be to share a ComputeBuffer directly with a MeshFilter but I learned that this is not possible unless you copy the buffer from the GPU and pass it in from CPU. I came across several other limitations (particularly with shading in geometry shaders) which make me wonder if I'm asking too much of the platform.
     
  2. andrewgotow

    andrewgotow

    Joined:
    Dec 28, 2013
    Posts:
    18
    I haven't experimented with it myself (Mostly a Mac / iOS developer), but Unity exposes this functionality through Graphics.DrawProceduralIndirect, which should allow you to build geometry within a Compute Shader, and render it without every crossing the GPU / CPU line.