Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Geometry Shader]Metal compile error vertex attribute missing, bug?

Discussion in 'Shaders' started by jister, Jun 5, 2017.

  1. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    getting this Metal compile error:

    trying to run this shader:
    Code (CSharp):
    1. Shader "Custom/PointShader"
    2. {
    3.     SubShader
    4.     {
    5.         Pass
    6.         {
    7.         CGPROGRAM
    8.         #pragma target 5.0
    9.         #pragma vertex vert
    10.         #pragma fragment frag
    11.  
    12.         #include "UnityCG.cginc"
    13.  
    14.         struct data
    15.         {
    16.             float3 pos;
    17.         };
    18.  
    19.         StructuredBuffer<data> buff_Points;
    20.         float3 _worldPos;
    21.  
    22.         struct v2f
    23.         {
    24.             float4 pos : SV_POSITION;
    25.             float3 color : COLOR0;
    26.         };
    27.  
    28.         v2f vert(uint id : SV_VertexID)
    29.         {
    30.             v2f o;
    31.             float3 worldPos = buff_Points[id].pos + _worldPos;
    32.             o.pos = mul(UNITY_MATRIX_VP, float4(worldPos, 1.0f));
    33.             o.color = worldPos;
    34.             return o;
    35.         }
    36.  
    37.         float4 frag(v2f i) : COLOR
    38.         {
    39.             float4 col = float4(i.color,1);
    40.             if(i.color.r <= 0 && i.color.g <= 0 && i.color.b <= 0)
    41.                 col.rgb = float3(0,1,1);
    42.             return col;
    43.         }
    44.         ENDCG
    45.         }
    46.     }
    47.     FallBack "Diffuse"
    48. }
    49.  
    shader does works on Windows.
     
    cabbibo_ likes this.
  2. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    Anyone experiencing the same compile problems?
     
    cabbibo_ likes this.
  3. aaronm37

    aaronm37

    Joined:
    Jun 9, 2017
    Posts:
    2
    Yes, same compile error, even using Unity Particle/Alpha Blended shader. It doesn't seem to be an error in the shader itself?

    I'm trying to get Antoine's XParticle running on Mac:

    https://github.com/antoinefournier/XParticle/

    Launching Unity with Metal support from Terminal with:
    /Applications/Unity/Unity.app/Contents/MacOS/Unity -force-metal
     
    cabbibo_ likes this.
  4. Terko

    Terko

    Joined:
    Apr 20, 2013
    Posts:
    32
    "Metal: Error creating pipeline state (Hidden/InternalErrorShader): Vertex attribute POSITION0(0) is missing from the vertex descriptor
    (null)"

    Having this error in Unity 5.6.1f1. Any news regarding this issue?
     
    cabbibo_ likes this.
  5. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    did launching from the terminal help?
     
    cabbibo_ likes this.
  6. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    I keep getting this error with every Geometry shader i write on mac, they all work fine on PC??
    someone please explain whats going on... :(
     
    cabbibo_ likes this.
  7. cabbibo_

    cabbibo_

    Joined:
    Jul 17, 2017
    Posts:
    4
    Hey jister!

    I have been having this problem non-stop and was going crazy as well.

    The answer ( at least for me )

    #pragma target 4.5


    target 4.5 is the highest supported on metal, and anything lowered won't give you structured buffers! I really hope this helps.
     
  8. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    hey @cabbibo_ thanks but it still won't compile for metal.
    if you have a working one, could you post it? so i can try and compile one i'm sure that should compile.
     
  9. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    even this metal won't compile:
    Code (CSharp):
    1. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
    2. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
    3.  
    4. Shader "test/MyShader"
    5. {
    6.     Properties
    7.     {
    8.         _MainTex ("Texture", 2D) = "white" {}
    9.     }
    10.     SubShader
    11.     {
    12.         Tags { "RenderType"="Opaque" }
    13.         LOD 100
    14.         Pass
    15.         {
    16.             CGPROGRAM
    17.             #pragma vertex vert
    18.             #pragma fragment frag
    19.             #pragma geometry geom
    20.             #pragma target 5.0
    21.  
    22.          
    23.             #include "UnityCG.cginc"
    24.             struct appdata
    25.             {
    26.                 float4 vertex : POSITION;
    27.                 float3 normal : NORMAL;
    28.                 float2 uv : TEXCOORD0;
    29.             };
    30.             struct v2f
    31.             {
    32.                 float4 vertex : SV_POSITION;
    33.                 float3 normal : NORMAL;
    34.                 float2 uv : TEXCOORD0;
    35.                 float3 worldPosition : TEXCOORD1;
    36.             };
    37.             sampler2D _MainTex;
    38.             float4 _MainTex_ST;
    39.          
    40.             v2f vert (appdata v)
    41.             {
    42.                 v2f o;
    43.                 o.vertex = UnityObjectToClipPos(v.vertex);
    44.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
    45.                 o.normal = v.normal;
    46.                 o.worldPosition = mul(unity_ObjectToWorld, v.vertex).xyz + float3(0,10,0);
    47.                 return o;
    48.             }
    49.             [maxvertexcount(3)]
    50.             void geom(triangle v2f input[3], inout TriangleStream<v2f> OutputStream)
    51.             {
    52.                 v2f test = (v2f)0;
    53.                 float3 normal = normalize(cross(input[1].worldPosition.xyz - input[0].worldPosition.xyz, input[2].worldPosition.xyz - input[0].worldPosition.xyz));
    54.                 for(int i = 0; i < 3; i++)
    55.                 {
    56.                     test.normal = normal;
    57.                     test.vertex = input[i].vertex;
    58.                     test.uv = input[i].uv;
    59.                     OutputStream.Append(test);
    60.                 }
    61.             }
    62.          
    63.             fixed4 frag (v2f i) : SV_Target
    64.             {
    65.                 // sample the texture
    66.                 fixed4 col = tex2D(_MainTex, i.uv);
    67.                 float3 lightDir = float3(1, 1, 0);
    68.                 float ndotl = dot(i.normal, normalize(lightDir));
    69.                 return col * ndotl;
    70.             }
    71.             ENDCG
    72.         }
    73.     }
    74.     Fallback "Diffuse"
    75. }
    compile report:
    Code (CSharp):
    1. // Compiled shader for PC, Mac & Linux Standalone
    2.  
    3. //////////////////////////////////////////////////////////////////////////
    4. //
    5. // NOTE: This is *not* a valid shader file, the contents are provided just
    6. // for information and for debugging purposes only.
    7. //
    8. //////////////////////////////////////////////////////////////////////////
    9. // Skipping shader variants that would not be included into build of current scene.
    10.  
    11. Shader "test/MyShader" {
    12. Properties {
    13. _MainTex ("Texture", 2D) = "white" { }
    14. }
    15. SubShader {
    16. LOD 100
    17. Tags { "RenderType"="Opaque" }
    18. Pass {
    19.   Tags { "RenderType"="Opaque" }
    20.   //////////////////////////////////
    21.   //                              //
    22.   //      Compiled programs       //
    23.   //                              //
    24.   //////////////////////////////////
    25. //////////////////////////////////////////////////////
    26. No keywords set in this variant.
    27. -- Vertex shader for "metal":
    28. // Compile errors generating this shader.
    29.  
    30. -- Fragment shader for "metal":
    31. // Compile errors generating this shader.
    32.  
    33. -- Geometry shader for "metal":
    34. // Compile errors generating this shader.
    35.  
    36. -- Vertex shader for "glcore":
    37. Shader Disassembly:
    38. #ifdef VERTEX
    39. #version 420
    40. #extension GL_ARB_explicit_attrib_location : require
    41. #extension GL_ARB_shading_language_420pack : require
    42.  
    43. uniform     vec4 hlslcc_mtx4x4unity_ObjectToWorld[4];
    44. uniform     vec4 hlslcc_mtx4x4unity_MatrixVP[4];
    45. uniform     vec4 _MainTex_ST;
    46. in  vec4 in_POSITION0;
    47. in  vec3 in_NORMAL0;
    48. in  vec2 in_TEXCOORD0;
    49. out vec3 vs_NORMAL0;
    50. out vec2 vs_TEXCOORD0;
    51. out vec3 vs_TEXCOORD1;
    52. vec4 u_xlat0;
    53. vec4 u_xlat1;
    54. void main()
    55. {
    56.     u_xlat0 = in_POSITION0.yyyy * hlslcc_mtx4x4unity_ObjectToWorld[1];
    57.     u_xlat0 = hlslcc_mtx4x4unity_ObjectToWorld[0] * in_POSITION0.xxxx + u_xlat0;
    58.     u_xlat0 = hlslcc_mtx4x4unity_ObjectToWorld[2] * in_POSITION0.zzzz + u_xlat0;
    59.     u_xlat1 = u_xlat0 + hlslcc_mtx4x4unity_ObjectToWorld[3];
    60.     u_xlat0.xyz = hlslcc_mtx4x4unity_ObjectToWorld[3].xyz * in_POSITION0.www + u_xlat0.xyz;
    61.     vs_TEXCOORD1.xyz = u_xlat0.xyz + vec3(0.0, 10.0, 0.0);
    62.     u_xlat0 = u_xlat1.yyyy * hlslcc_mtx4x4unity_MatrixVP[1];
    63.     u_xlat0 = hlslcc_mtx4x4unity_MatrixVP[0] * u_xlat1.xxxx + u_xlat0;
    64.     u_xlat0 = hlslcc_mtx4x4unity_MatrixVP[2] * u_xlat1.zzzz + u_xlat0;
    65.     gl_Position = hlslcc_mtx4x4unity_MatrixVP[3] * u_xlat1.wwww + u_xlat0;
    66.     vs_NORMAL0.xyz = in_NORMAL0.xyz;
    67.     vs_TEXCOORD0.xy = in_TEXCOORD0.xy * _MainTex_ST.xy + _MainTex_ST.zw;
    68.     return;
    69. }
    70.  
    71. #endif
    72. #ifdef FRAGMENT
    73. #version 420
    74. #extension GL_ARB_explicit_attrib_location : require
    75. #extension GL_ARB_shading_language_420pack : require
    76.  
    77. uniform  sampler2D _MainTex;
    78. in  vec3 gs_NORMAL0;
    79. in  vec2 gs_TEXCOORD0;
    80. layout(location = 0) out vec4 SV_Target0;
    81. vec4 u_xlat10_0;
    82. float u_xlat1;
    83. void main()
    84. {
    85.     u_xlat10_0 = texture(_MainTex, gs_TEXCOORD0.xy);
    86.     u_xlat1 = dot(gs_NORMAL0.xy, vec2(0.707106769, 0.707106769));
    87.     SV_Target0 = u_xlat10_0 * vec4(u_xlat1);
    88.     return;
    89. }
    90.  
    91. #endif
    92. #ifdef GEOMETRY
    93. #version 420
    94. #extension GL_ARB_explicit_attrib_location : require
    95. #extension GL_ARB_shading_language_420pack : require
    96.  
    97. in  vec3 vs_NORMAL0 [3];
    98. in  vec2 vs_TEXCOORD0 [3];
    99. in  vec3 vs_TEXCOORD1 [3];
    100. vec3 u_xlat0;
    101. vec3 u_xlat1;
    102. bool u_xlatb1;
    103. vec3 u_xlat2;
    104. float u_xlat9;
    105. int u_xlati9;
    106. layout(triangles) in;
    107. layout(triangle_strip) out;
    108. out vec3 gs_NORMAL0;
    109. out vec2 gs_TEXCOORD0;
    110. out vec3 gs_TEXCOORD1;
    111. layout(max_vertices = 3) out;
    112. void main()
    113. {
    114.     u_xlat0.xyz = (-vs_TEXCOORD1[0].zxy) + vs_TEXCOORD1[1].zxy;
    115.     u_xlat1.xyz = (-vs_TEXCOORD1[0].yzx) + vs_TEXCOORD1[2].yzx;
    116.     u_xlat2.xyz = u_xlat0.xyz * u_xlat1.xyz;
    117.     u_xlat0.xyz = u_xlat0.zxy * u_xlat1.yzx + (-u_xlat2.xyz);
    118.     u_xlat9 = dot(u_xlat0.xyz, u_xlat0.xyz);
    119.     u_xlat9 = inversesqrt(u_xlat9);
    120.     u_xlat0.xyz = vec3(u_xlat9) * u_xlat0.xyz;
    121.     for(int u_xlati_loop_1 = 0 ; u_xlati_loop_1<3 ; u_xlati_loop_1++)
    122.     {
    123.         gl_Position = gl_in[u_xlati_loop_1].gl_Position;
    124.         gs_NORMAL0.xyz = u_xlat0.xyz;
    125.         gs_TEXCOORD0.xy = vs_TEXCOORD0[u_xlati_loop_1].xy;
    126.         gs_TEXCOORD1.xyz = vec3(0.0, 0.0, 0.0);
    127.         EmitVertex();
    128.     }
    129.     return;
    130. }
    131.  
    132. #endif
    133.  
    134.  
    135. -- Fragment shader for "glcore":
    136. Shader Disassembly:
    137. // All GLSL source is contained within the vertex program
    138.  
    139. -- Geometry shader for "glcore":
    140. Shader Disassembly:
    141. // All GLSL source is contained within the vertex program
    142.  
    143. }
    144. }
    145. Fallback "Diffuse"
    146. }
    i doubt it's my specs, but anyway:
    MacBook Pro (Retina, 15-inch, Early 2013)
    2,7 GHz Intel Core i7
    16 GB 1600 MHz DDR3
    NVIDIA GeForce GT 650M 1024 MB

    i wish a moderator could help clear this up... :( @Aras ?
     
  10. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    ok so Unity set #pragma target automatically to 4.0 when using #pragma geometry and the docs say about 4.0 that it doesn't support metal.
    actually @cabbibo_ like you said above 3.5 only 4.5 supports metal. see docs.
    so how did anyone get to compile a geometry shader on metal is a mystery to me...
     
  11. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    still hung up on this...
    Can some one confirm that Geometry shaders work on OSX. and if so how they do it :) pretty please :p
    I can't seem to be able to find any statement by unity that says they do or don't...
     
  12. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    AFAIK Metal does not support geometry shaders at all, and Unity defaults to using Metal on OSX.

    You have to disable Metal and force OpenGL Core in the Player settings.
     
  13. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    @bgolus, if you keep this up i'll have to make you a statue or something!! :p
    so OpenGL Core does support Geometry shaders? i thought unity was behind on OpenGL?
    :eek: just found out I was wrong!

    but reading this, if I understand correct, it's or Geometry(openGL) or Compute(Metal) but not both at the same time? :( is that correct?

    EDIT: OK now I'm just getting confused...
     
    Last edited: Aug 15, 2017
  14. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    OpenGL Core basically means "use the latest version of OpenGL available on the platform".

    OpenGL 4.3 supports compute & geometry shaders, and nearly all DX11 class GPUs support at least that it or better.

    However OSX itself only supports up to OpenGL 4.1, so no compute, only geometry shaders, regardless of the GPU in use. If you bootcamp Windows 10 on a modern Mac it'll probably support OpenGL 4.5 and DX12, but those features simply aren't available to OSX.

    Metal can do compute, but not geometry shaders. Metal technically supports "tessellation shaders", but not in any way resembling tessellation shaders on other APIs and is effectively doing tessellation in a built in compute shader prior to rendering. Apple's line for using geometry shaders is "if you want a geometry shader, use a compute shader instead." Yo be fair PC hardware makers have been saying this for years too, the software side just hasn't been listening, so Apple is just forcing the issue.
     
    cecarlsen and jister like this.
  15. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    ok, so the answer is go with metal and use Compute shaders even if you want to do geometry o_O as if writing shaders isn't hard enough on its own...
    But hey @bgolus thans again, you the man!!! I feel I'm in your debt ;)
    now to find an example of a compute geometry shader in the abyss of graphics programming...
     
  16. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    jister likes this.
  17. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    @bgolus where is your bucket, so i can put some gold in it!! :D
    as soon as i have a working draft I'll post it here!
     
  18. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    and I'm back to square one :(
    so i disabled OpenGLCore to be sure to use Metal.
    I try this simple shader:
    Code (CSharp):
    1. Shader "Custom/BufferShader"
    2. {
    3.     SubShader
    4.     {
    5.         Pass
    6.         {
    7.             ZTest Always Cull Off ZWrite Off
    8.             Fog { Mode off }
    9.  
    10.             CGPROGRAM
    11.             #include "UnityCG.cginc"
    12.             #pragma target 5.0
    13.             #pragma vertex vert
    14.             #pragma fragment frag
    15.  
    16.             uniform StructuredBuffer<float3> buffer;
    17.             uniform float3 col;
    18.  
    19.             struct v2f
    20.             {
    21.                float4  pos : SV_POSITION;
    22.             };
    23.  
    24.             v2f vert(uint id : SV_VertexID)
    25.             {
    26.                 v2f OUT;
    27.                 OUT.pos = UnityObjectToClipPos(float4(buffer[id], 1));
    28.                 return OUT;
    29.             }
    30.  
    31.             float4 frag(v2f IN) : COLOR
    32.             {
    33.                 return float4(col,1);
    34.             }
    35.             ENDCG
    36.         }
    37.     }
    38. }
    with this Compute:
    Code (CSharp):
    1. #pragma kernel CSMain
    2.  
    3. AppendStructuredBuffer<float3> appendBuffer;
    4. float size;
    5. float width;
    6.  
    7. [numthreads(8,8,1)]
    8. void CSMain (uint3 id : SV_DispatchThreadID)
    9. {
    10.  
    11.     //Normalize pos
    12.     float3 pos = id / (width-1);
    13.  
    14.     //make pos range from -size to +size
    15.     pos = (pos - 0.5) * 2.0 * size;
    16.     //keep z pos at 0
    17.     pos.z = 0.0;
    18.  
    19.     if(id.x % 2 == 0 && id.y % 2 == 0)
    20.         appendBuffer.Append(  pos );
    21. }
    and this script:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class AppendBufferExample : MonoBehaviour
    5. {
    6.     public Material material;
    7.     public ComputeShader appendBufferShader;
    8.  
    9.     const int width = 32;
    10.     const float size = 5.0f;
    11.  
    12.     ComputeBuffer buffer;
    13.     ComputeBuffer argBuffer;
    14.  
    15.     void Start()
    16.     {
    17.  
    18.         buffer = new ComputeBuffer(width * width, sizeof(float) * 3, ComputeBufferType.Append);
    19.         buffer.SetCounterValue(0);
    20.  
    21.         appendBufferShader.SetBuffer(0, "appendBuffer", buffer);
    22.         appendBufferShader.SetFloat("size", size);
    23.         appendBufferShader.SetFloat("width", width);
    24.  
    25.         appendBufferShader.Dispatch(0, width/8, width/8, 1);
    26.  
    27.         argBuffer = new ComputeBuffer(4, sizeof(int), ComputeBufferType.IndirectArguments);
    28.  
    29.         int[] args = new int[]{ 0, 1, 0, 0 };
    30.         argBuffer.SetData(args);
    31.  
    32.         ComputeBuffer.CopyCount(buffer, argBuffer, 0);
    33.         argBuffer.GetData(args);
    34.  
    35.         Debug.Log("vertex count " + args[0]);
    36.         Debug.Log("instance count " + args[1]);
    37.         Debug.Log("start vertex " + args[2]);
    38.         Debug.Log("start instance " + args[3]);
    39.     }
    40.  
    41.     void OnPostRender ()
    42.     {
    43.         material.SetPass(0);
    44.         material.SetBuffer ("buffer", buffer);
    45.         material.SetColor("col", Color.red);
    46.         Graphics.DrawProceduralIndirect(MeshTopology.Points, argBuffer, 0);
    47.     }
    48.  
    49.     void OnDestroy ()
    50.     {
    51.         buffer.Release();
    52.         argBuffer.Release();
    53.     }
    54. }
    and GUESS WHAT I GET :)
    Code (CSharp):
    1. Metal: Error creating pipeline state (Hidden/InternalErrorShader): Vertex attribute POSITION0(0) is missing from the vertex descriptor
    2. (null)
    EDIT: Auwtch why did it put #pragma target 5.0, when i know it doesn't work for mac :oops::rolleyes:
    ok so it compiles without error, but show nothing o_O
     
    Last edited: Aug 20, 2017
  19. neilpurvey

    neilpurvey

    Joined:
    Feb 7, 2017
    Posts:
    8
    Hi,

    We are also seeking exactly what you require - compute pass generating verts to an append buffer with indirect rendering pass via a surface shader. On Metal for OSX/IOS.

    We are getting the same error: "Metal: Error creating pipeline state (Hidden/InternalErrorShader): Vertex attribute POSITION0(0) is missing from the vertex descriptor (null)"

    Did you get to the bottom of this?

    Thanks!

    Neil
     
  20. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    yes i actually managed to solve it. So a compute shader should work if you add #pragma target 4.5 to it.
    i had a hard time mostly because all this time i was trying to mix compute and geometry shaders until:
     
  21. neilpurvey

    neilpurvey

    Joined:
    Feb 7, 2017
    Posts:
    8
    My compute and append buffer passes are fine, but am baffled how your structuredbuffer works with a Metal targetted shader. I understand these are DirectX/HLSL constructs and when compiling with non DirectX targets in Unity does not like the structuredbuffer, which makes sense, we previously #ifdef'd out the structure buffers and fetching from them in the vertex shader to ensure all platforms compiled. Are you willing to share an example of how you are doing this, it would be extremely helpful :) One difference with our code and yours is that we need Surface shaders to take advantage of physically based lighting and all that jazz that Unity helps with, maybe this is a problem too.

    Thanks!
     
  22. neilpurvey

    neilpurvey

    Joined:
    Feb 7, 2017
    Posts:
    8
    Ah yes, seems surface shaders aren't friendly with Structuredbuffers! What a shame.. still get the original Metal vertex attribute errors though. :/
     
  23. neilpurvey

    neilpurvey

    Joined:
    Feb 7, 2017
    Posts:
    8
    Seems if you just want to feed any shader with the results of a compute pass you will always get the "Metal: Error creating pipeline state (Hidden/InternalErrorShader): Vertex attribute POSITION0(0) is missing from the vertex descriptor (null)" error. It goes away if you render a mesh, it is a combined problem of not referencing the position vertex attribute in the vertex shader (which causes the Metal code gen to remove the POSITION0 attribute from the vertex input) plus no mesh bound on input from unity side. This is a problem for indirect draws and or dispatches from fetched positions from compute passes.

    Besides that, when I create a standard unlit shader, and only apply the following changes to force a Metal compilation:

    #pragma target 4.5
    #pragma only_renderers metal

    all errors / warnings about metal go away, but my lovely capsule mesh does not render :[ Am I missing something obvious to get the Metal pipeline to render on OSX? I force all shaders to output Metal only.. still nothing renders. Ofcourse i verified it renders at all by setting target back to 5.0 and removing the explicit platform. pink capsule appears!

    Any further tips would be appreciated peeps.

    Neil
     
  24. neilpurvey

    neilpurvey

    Joined:
    Feb 7, 2017
    Posts:
    8
    Ah, ok rendering a mesh with Metal does work, it is not pink though, was white and disguised by the floor I had placed, so theres a bug I guess, the Game view does not render but the Scene view does.

    Ok, so conclusion is that the problem I have is primarily to do with having to render a mesh to get rid of the Metal POSITION0 error, and also having to reference the POSITION0 vertex attribute in the vshader to make sure the Metal cross compiler does not strip it out. 2 bugs there, especially preventing me to do indirect rendering of compute buffer data.
     
    cecarlsen likes this.
  25. Cherubim79

    Cherubim79

    Joined:
    May 3, 2014
    Posts:
    56
    Did anyone ever get this resolved? I'm having the same issue trying to follow this tutorial:

    https://github.com/antoinefournier/XParticle

    I'm new to compute shaders, have gotten RWStructuredBuffer and RWTexture2D to work the way I want, but this tutorial introduced a new wrinkle for me in doing material.SetPass(0); Graphics.DrawProcedural(MeshTopology.Points, 1, particleCount); Gives me the same error of POSITION0 is not passed, tried to put it into all of my structs just to test and see if I could get it to go through, #pragma target is set to 5.0. Running on Metal / OSX High Sierra (i5 MacBook Pro). Can't seem to get Geometry shaders to work on here either. Only thing I can seem to do so far is passing data between the above mentioned types and running code against it.

    Question, is this all still kind of experimental? Looks like I'm having a hard time getting clear and concise documentation around many matters regarding Compute Shaders outside of just the basics. A simple example of rendering a mesh and a particle system using Compute Shaders that will work would be grand.
     
  26. neilpurvey

    neilpurvey

    Joined:
    Feb 7, 2017
    Posts:
    8
    No, sadly I received no feedback from Unity internal support either. Priorities have now moved on, as they do when waiting for a long time for a resolution.
     
  27. Cherubim79

    Cherubim79

    Joined:
    May 3, 2014
    Posts:
    56
    Is there some proposed "next new thing" that is being worked on by the Unity staff? Seems like Compute Shaders should be a top priority, considering I just ran some code that offset a computation that took 10 minutes on my CPU down to < 10 seconds on a Compute Shader (roughly around 33 billion Euclidean distance calculations for a long image conversion using buffers).

    You could crunch statistical analyses of large Wall Street sized datasets with a single MacBook Pro with this thing it would appear. On my end I tried adding in a float3 POSITION0; on both the Compute and Vertex shader and copying over the same data as what's set on position just to see what would happen when passing to Graphics.DrawProcedural, but it had no effect. I guess the question is, is it actually a driver/implementation/target issue or is that some data that needs to be passed is not getting transposed into the correct properties/format?

    Whatever the next new thing is I hope it's a XAML layer for the UI design for designing nested data-driven components, that would make my day coming from a WPF/UWP/Xamarin world. :p
     
  28. Cherubim79

    Cherubim79

    Joined:
    May 3, 2014
    Posts:
    56
    Set the #pragma target 4.5 in your Vertex Shader instead of 5.0.

    Metal is not supported on a target 5.0, it's working for me now.

    Also note than with a limitation of 4.5 I don't think there's a way for Geometry or Tesselation shaders to work on Metal.