0

I have created a 3d object using a blender. and I exported it as a g3db and gsdj types and used with libgdx. everything works fine but the colors of the object are not rendering as expected.

I tried using various ways to create an object and exporting with a blender. and In the past, I’ve tried libgdx-fbx-conv to convert fbx to g3db. and its also not working.

public class experiments extends ApplicationAdapter {

    private ModelBatch modelBatch;
    private Environment environment;
    private PerspectiveCamera cam;
    private Model model;
    private ModelInstance instance;
    private CameraInputController camController;

    @Override
    public void create() {
        modelBatch = new ModelBatch();
        environment = new Environment();
        environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
        float color = 0.0001f;
        environment.add(new DirectionalLight().set(color, color, color, -1f, -0.8f, -0.2f));

        cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        cam.position.set(3f, 3f, 3f);
        cam.lookAt(0, 0, 0);
        cam.near = 1f;
        cam.far = 300f;
        cam.update();

        G3dModelLoader loader = new G3dModelLoader(new UBJsonReader());
        model = loader.loadModel(Gdx.files.internal("test.g3db"));
        instance = new ModelInstance(model);

        camController = new CameraInputController(cam);
        Gdx.input.setInputProcessor(camController);
    }

    @Override
    public void render() {
        camController.update();

        Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

        modelBatch.begin(cam);
        modelBatch.render(instance, environment);
        modelBatch.end();
    }

    @Override
    public void dispose() {
    }
}

this is what blender shows https://drive.google.com/open?id=1WAjrP_Z4IVjohk-CZSFeLk5st8PNOQGz

and this is what I have

https://drive.google.com/open?id=1AbRGLathCuESesTpcTFvKue49V1k533Z

BDL
  • 21,052
  • 22
  • 49
  • 55
Russel
  • 29
  • 2
  • 7
  • Please upload all your images into your SO question. Links to off-site resources are only allowed as supplementary material. – BDL Aug 08 '19 at 07:41

1 Answers1

0

That has most likely just something to do with the way it is being rendered. Blender renders it with either Cycles or Eevee (with Belender 2.8), while LibGDX uses OpenGl. It's like you make a photograph of the same object with two different cameras.

edgelord
  • 43
  • 4
  • thanks for your response, i used converting tool to convert for fbx to g3db. before convert it previews g3db files as follows. so i read the codes and i couldn't find any difference with its preview module. and that module can preview without any issue. https://github.com/ASneakyFox/libgdx-fbxconv-gui this is the repo and it is written by libgdx. same file renders as difference in same codes. https://drive.google.com/open?id=1j3gqhGA6_mY0lQJTq8iuau7Ai0RVChQ5 – Russel Aug 07 '19 at 17:35
  • @Russel Okay, I don't have an answer to your problem then, sorry. – edgelord Aug 08 '19 at 15:41
  • I found a solution for this issue. but i cannot realize what it does theoretically. we have to remove emissive effect from libgdx which material used in blender. `for (Material m : model.materials) { m.remove(ColorAttribute.Emissive); }` – Russel Aug 10 '19 at 14:21