0
votes

my name ist Tom (Ger) and i am developing a small 3D game with libGDX.

when i am using a Model, ModelInstance with a ModelBatch and the Environment, i can render different ModelInstances (with different Models) with there right textures.

But i need to use a shader for some wobble effects.

But when i use a shader everything works finde, except for the textures. there are the same for every ModelInscance i want to render.

i guess there is a texture binding problem. I load my Models this way:

assets = new AssetManager();
assets.load("blob.g3db", Model.class);

and fetch them with a simple:

public static Model getModel(String name) {
    return assets.get(name + ".g3db", Model.class);
}

So i guess the assetsManager is loading the textures as well (cause it works without the shader).

My Question is: How can i render differend 3D Objects with a Shader with there correct Textures?

Thanks in Advance... Tom

1

1 Answers

0
votes

The Models and the ModelInstances have a Material, where you can set a Texture, Color and other things to it.
So if 2 ModelInstances share the same Model you can set different Materials to their ModelInstances. By doing this you have different Textures. The DefaultShader implementation takes care about them. If you create your own Shader you need to take care about them.
Important: It does not work without Shader, cause you always render with Shader. You don't set the Shader manually, but libgdx uses DefaultShader by default.
I suggest you read some of Xoppas tutorials.