Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. If you're a macOS 10.13 High Sierra user take be sure to read this before updating Unity.
    Dismiss Notice
  5. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  7. Unity 2017.3 beta is now available for download.
    Dismiss Notice

ios 11 metal2 has no geometry shader?

Discussion in 'Shaders' started by dreamerflyer, Oct 11, 2017.

  1. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    709
    I can not find geometry shader in metal2 api,why not include this?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    3,585
    Because Apple does not support geometry shaders in Metal or Metal 2.
     
  3. C_p_H

    C_p_H

    Joined:
    Nov 24, 2014
    Posts:
    69
    It does support it see chart here for OS versions.
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    20,382
    I did a bit of reading. I think the world is best off without geometry shaders which have crappy performance vs a compute shader mimicking the same approach (which has no drawbacks from what I can see).

    Is there anything that a geometry shader can do that a (couple) of compute shaders cannot?
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    3,585
    That chart does not list geometry shaders, due to Metal's lack of support for them. It does support tessellation, but that's different than geometry shaders. Tessellation in Metal is implemented as a compute shader pre-pass unlike added stages between the vertex shader and the fragment shader that tessellation and geometry shaders use in OpenGL and Direct3D. Metal doesn't support Hull or Domain shaders either, which are part of the "traditional" tessellation stages. This is why Unity still does not yet support tessellation in Metal as it is so fundamentally different.

    Ironically many AAA devs have already abandoned tessellation and geometry shaders in favor of using compute for everything due to the added flexibility, better performance, and easier scheduling. The last several Call of Duty games have used compute based tessellation for example.

    Nope. And a compute shader can do far more than a geometry shader can.
     
    hippocoder and C_p_H like this.
  6. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    709
    Any Example for tessellation with compute shader?Thanks in advanced!
     
  7. C_p_H

    C_p_H

    Joined:
    Nov 24, 2014
    Posts:
    69
    Discovered this guide and it was demoed at WWDC 2016.

    Edit: Using Metal 2 for Compute; 2017 Video Demonstrations.
     
    Last edited: Dec 7, 2017
    dreamerflyer likes this.
  8. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    20,382
    There's tess in the SRP HD pipeline asset, but I'm not at all sure if it's a modern compute shader version or still the same old. I'm hoping it's possible there at least.
     
  9. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    709
    hi,according your link ,can make metal 's
    setTessellationFactorBuffer in unity compute shader?
     
  10. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    646
    I don't want to derail the thread, but I'm pretty interested in this. I'm currently using a geometry shader in a project that operates on line mesh topologies; the geometry shader takes the two points in and creates a camera facing quad. This is useful for drawing uniform-width lines in 3D space (outlines of meshes, think the SketchUp look). This seemed like a good fit for a geometry shader because the line mesh does not change frame to frame, but the output quads to (based on camera direction and distance).

    How would this kind of thing be accomplished using a Compute Shader? Is it possible to each frame run the Compute Shader on the line mesh and then store the output as another mesh (which would be the quads)? I looked up how to store the output of compute shaders in meshes in Unity but didn't find much to help. It seems like if you could run a Compute Shader on a mesh and then store the output in another mesh, you could use Compute Shaders as an arbitrary pre-processing step that could basically do whatever it wants before the regular Vertex/Frag shaders run. Is this correct?
     
  11. C_p_H

    C_p_H

    Joined:
    Nov 24, 2014
    Posts:
    69
    I believe you're right but perhaps someone can test if Unity's built-in translator will convert properly when its loaded to the ComputeBuffer.
    According to this documentation, Unity has built-in portability (Shader Compiler) for converting DX11-style HLSL (currently d3dcompiler_47) to Metal-(Microsoft’s HLSL followed by bytecode translation) using HLSLcc.
     
  12. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    3,585
    You can currently write compute shaders that work on Metal, including writing your own custom tessellation, but if you want to use Metal's built in version you'll have to wait for 2018.1 according to their roadmap.

    https://unity3d.com/unity/roadmap
     
    C_p_H likes this.
  13. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    709
    How to get custom tessellation in compute shader? per 3 triangle vertex indexes to topologies?
     
  14. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    3,585
    High level version of using a compute shader to do tesselation (or really any mesh generation).

    1. Take mesh vertex & polygon data and put it into buffers in c# script.
    2. Run compute shader with that data to construct new mesh in another set of buffers.
    3. Render using DrawProceduralIndirect and a custom shader that uses the data in the buffers as vertex data.
    4. Profit!

    Obviously I’m skipping some major details there, but that’s the gist. Search around for DrawProcedualIndirect to see how to use it.
     
    Iron-Warrior likes this.