Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

HLSL written SV_VertexID works different in opengl after automatic compile

Discussion in 'Shaders' started by segant, Jun 29, 2020.

  1. segant

    segant

    Joined:
    May 3, 2017
    Posts:
    179
    Shader is different from directx. I used hlsl in shader. I think unity converts it wrong.
     
    Last edited: Jun 29, 2020
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,668
    If you think shader compilation is incorrect, please submit a bug report.
     
  3. segant

    segant

    Joined:
    May 3, 2017
    Posts:
    179
    Allright, I'll upload it today.
     
    aleksandrk likes this.
  4. segant

    segant

    Joined:
    May 3, 2017
    Posts:
    179
    @aleksandrk I have uploaded it but forgot to tell. May I take some of your time ? Case 1259743
     
  5. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,668
    The bug will get processed by QA first, I'll take a look afterwards :)
     
    segant likes this.
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,668
    @segant Hi! I finally managed to take a look at your bug report. This is caused by OpenGL and other APIs having different rules for selecting a provoking vertex (the vertex that defines the value for fragment shading when this value is not interpolated). For GL it's the last vertex, all other APIs use the first.
    You can just change your geometry shader to output the ID of the first vertex for all three vertices you output there (e.g.
    o.vertexIdPassed=i[0].id;
    ).
     
unityunity