Search Unity

Shader Graph Geometry Shader?

Discussion in 'Shaders' started by EagL-, Mar 19, 2019.

  1. EagL-

    EagL-

    Joined:
    Dec 9, 2016
    Posts:
    24
    Hello!
    Im really new to making shaders and would now like to create some kind or geometry shader to render grass. Currently Im just placing down a bunch of gameobjects. Ive heard that you can use a geometry shader to improve performance. Im currently using GPU instancing, but thought I could make it even better. However, I have found no guide to making geometry shaders in shader graph. Is it possible at all, or do I need to code a shader? If so, could anyone kindly point me in the right direction to do this?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    No.

    Yes.

    There's not a ton of documentation on geometry shaders in general as it's considered an advanced topic (i.e.: if you're playing with geometry shaders, you already understand shaders really, really well) and is just a DirectX 11 HLSL thing and not specific to Unity in any way. There are a number of examples out there on how to get them working for Unity for the built in forward or deferred pipelines.

    However, since you're asking about Shader Graph, I'm going to assume you're using either the LWRP or HDRP. This makes things significantly more complex as there's zero documentation on how either of these rendering systems work and very few public examples to work off of as they are quite new. The only way to know how the systems work, and what you would need to do to implement a geometry shader along side them is to read through all of the existing source code and become intimately familiar with those rendering systems on your own, then write a custom shader that supports those features and adds the geometry shader stuff.

    It's possible, but I would not suggest this as a direction to go for someone "really new to making shaders". Geometry shaders are a different beast, and one that many believe should be killed off. (Apple's Metal graphics API for iOS and OSX intentionally removed support for them, and their inclusion in Vulkan & DirectX 12 is a point of contention.) Stick with instancing for now, or maybe research compute shader based geometry generation at some point in the future.
     
    shegway likes this.
  3. Medusa-Zenovka

    Medusa-Zenovka

    Joined:
    Oct 1, 2014
    Posts:
    29
  4. nanoblubb

    nanoblubb

    Joined:
    Oct 29, 2016
    Posts:
    9
    I wouldnt Go so far by saying that you will Neeed to Unserstand The HDRP/LRP in Order to write New shaders for Them. The reason for that is, that shaders are written for a pipeline that means you just need to know wich kimd of input you get in your shader programs and wich output is awaited. For these information you could simply look in the source code of a generated shader in shadergraph. You will notice early that the hdrp eg uses a fragment/vert setup for it shadows. So except for inputs wich will be a different struct than in standard and the shader params there wont be significant chamges to an hlsl shader in prior render techniques
     
    chantey likes this.