In the godot game engine (using opengl) it is not possible to define custom shader attributes.
A workaround is creating a sampler2D texture uniform instead and use vertexId (or in fact UV since vertexID also isn't exposed) to get the per vertex attributes.

I am wondering are there any downsides to this approach and/or caveats one should keep in mind ?

  • $\begingroup$ Wouldn't it make more sense to just switch to a game engine that isn't horribly limiting your ability to do what you need to do? $\endgroup$ – Nicol Bolas Feb 8 at 6:22
  • $\begingroup$ Sadly this is out of question. Besides godot gives me a lot of useful stuff. $\endgroup$ – SleepProgger Feb 8 at 18:10
  • $\begingroup$ "Besides godot gives me a lot of useful stuff." If it's not even allowing you to use basic aspects of a shader like gl_VertexID, then I would seriously contest that statement. I'm fairly sure that other engines can provide whatever "lot of useful stuff" that Godot does without Godot's pointless limitations. For example, my suggestion would be to use a buffer texture or an SSBO for such "attributes", but given that it doesn't even allow you to use gl_VertexID, I would be surprised if it let you use those features. $\endgroup$ – Nicol Bolas Feb 8 at 18:28
  • $\begingroup$ Godot allows the use of texture uniforms (thus the question...) and i can abuse UV and other existing attributes to smuggle the vertexID in. It isn't nice, but it works. BUT this question is not if godot is a good engine to use, but if there are technical concerns regarding that approach and what the downsides and caveats to this technique would be. $\endgroup$ – SleepProgger Feb 8 at 18:40
  • $\begingroup$ The problem is that I don't know what Godot will allow you to do, so I can't advise you. For example, I know how to make the texture-based idea work in a way that offers most if not all of the features of a vertex attribute. But I don't know if Godot will actually let you do those things needed to make it work. Again, if it's not letting you touch basic OpenGL functionality like gl_VertexID, who knows? Does it allow you to use floating-point image formats? What about integer textures? What about the GLSL functions for doing integer normalization? What about texelFetch? Etc. $\endgroup$ – Nicol Bolas Feb 8 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.