How do I use a ShaderProgram on a custom ModelInstance?

Hello guys, now I’m working at a voxel based game(not a Minecraft clone) in LibGDX. All the blocks have the same texture but different colors.
There are some special “blocks” too(they aren’t cubes). I read them from an obj file and use a 10x10 heightmap for collision.

Here’s how my engine renders the map:
-read map data from a file
-build a huge ModelInstance:
-the map is divided into 16x16x16 chunks
-generate a MeshPart for each chunk, using MeshPartBuilder
-apply colors and texture coordinates to each triangle
-start the rendering loop

I’ve recently learned GLSL (it’s great!) and I thought that adding shaders to my ModelInstance/MeshParts would make my game look much better.

My question is: What is the easiest way to bind a ShaderProgram to a ModelInstance, MeshPart or Mesh? Please include some code to make me understand better if you can :slight_smile:

Any help is much appreciated :slight_smile:

Please, I need an answer as soon possible

From my experience using ModelInstance is that its very hard to make your own, I found this small tutorial online https://xoppa.github.io/blog/using-materials-with-libgdx/

But you have to realize that the ModelInstance is a built in renderer so if you start messing around with the low end stuff aka shaders, the ModelInstance may not work as expected for example (Normal Mapping, Diffuse light, Ambient light etc etc) as you will need to code these yourself

I believe the tutorial above shows you how to get it working with a few things light Diffuse lighting, however my suggestion would be to make your own renderer