Call different geometry shader functions, for different primitive type: How?


I have a geometry shader that needs to work a bit differently depending on if the primitives are provided via GL.Begin(GL.lines) or GL.Begin(GL.quads).

I tried defining two version of the function in my shader, with the same name, but different parameters. Alas, this does not seem to be working properly. Perhaps I’m using the wrong primate type for GL.quads? I’ve tried both “triangle” and “lineadj”, but neither version ever gets called (unless I rename the “line” version as a sanity check).

My shader currently has both of the following function definitions, but only the second one is ever called, regardless of whether unity is drawing GL.lines or GL.quads

#pragma geometry GS_Main

…(vertex shader, struct definition, tags, etc)…
void GS_Main(lineadj v2g p[4], inout TriangleStream<g2f> pStream) //note the "lineadj" in first param.  Tried "triangle v2g p[3]" to, same result, never called.

void GS_Main(line v2g p[2], inout TriangleStream<g2f> pStream)  //note the "line" in first param

I don’t even know if I’m allowed to override the geometry shader, GS_Main, function like that, but it’s not giving my any compile errors.

Primary Question: How can I get the correct version of the geometry shader functions to run depending on weather Unity is using GL.lines vs Gl.quads? Or is it REQUIRED that each shader handle only one type of primitive (in which case I’m open to suggestions).

I don’t know for sure but, based on the comments in opengl - Geometry shader for multiple primitives - Game Development Stack Exchange , I don’t think it’s possible to overload a geometry shader to handle multiple primitive types (not in GLSL, anyway, but I suspect the same is true for Cg/HLSL)