jME VertexBuffer.Type limitations

I need to pass to my vertex shader a custom data (id, one int per vertex), but i’m only allowed to create VertexBuffers with hard-coded types (and names). May be i’m doing it wrong, but i think, i need to do it. Is there any advises?

Of course, I can simply override VertexBuffer for my project, but it is not gentle solution. I can use Type.MiscAttrib, but it is deprecated and can be removed in next jME versions.

It’s not the best system but it’s the one we’ve got.

Generally, one finds a type that is close and just uses that. There is relatively little semantic meaning to the names inside the engine and you can generally even pass different types than the default ones. I think only the Index buffer is treated specially inside the engine.

So maybe you can just pick one and use it.

Can I ask what you are using these IDs for?

Yes, I can use any of existing types, except Index (because it is not passed to shaders) but it not looks beautiful.

I guess, better way for jME was to define VertexBuffer.Type as class, not enum, with methods getId() and getName() and define static instances of default types. Of course, it will break compability. I decided to override VertexBuffer class for me.

I’m creating client for voxel-based game and i want to pass id of block to shader. Now I don’t really know what I will do with it, but it can be helpful sometimes. First idea is to use it as index for layer in TextureArray with textures of all blocks.

…in which case it could be the third value of a vector3f texture coordinate…

1 Like

This is why i posted question here: i’m new in all this graphics thins and sometimes can’t figure out simple solution. Thanks!

@Eirenliel said: This is why i posted question here: i'm new in all this graphics thins and sometimes can't figure out simple solution. Thanks!

You’re welcome. It’s why I asked the question. :slight_smile:

While I have occasionally been somewhat frustrated that I can’t create my own buffer types, I almost always find a sensible way to do what I want with the existing types without feeling too dirty.

1 Like