Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm writing a shader and I just wanna ask if it's possible to get the ID of the vertex that is currently being manipulated. I read something about gl_vertexID, but I couldn't find out if that is something I can use.

share|improve this question

1 Answer 1

Answer: Added the vertexIDs in a second uv(set x value to the id) channel in the mesh(from my c# code), and then in the shader I could use the ids as I needed, example:

     void function(inout appdata_full v) 
     {     
          int vertexID = v.texcoord1[0]; 
          ...
     }
share|improve this answer
    
Be sure to accept your own answer. –  Alex M. 19 hours ago
    
Will do! Have to wait 20 hours apparently. Thanks for the reminder tho :) –  sebbn 19 hours ago
    
VertexID is auto-generated as a system variable in Direct3D Shader Model 4.0 (Feature Level 10.0 hardware or later), but for older shader models you have to generate it yourself as was done in this answer. –  Chuck Walbourn 13 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.