Backface Culling & Light Direction for custom loaded models & Models going all black

  • Hi,

    I loaded a flower plant into the game via a self-made mod, just somehow it has only 1 light value which seems to be based on the overall rotation of the model, not on the individual normals.

    The other problem is that that backsides of the leaves don't get rendered because of backface culling, is there some way to enable rendering the backsides too?

    And last but not least a problem I have is that the model I hold in my hand and the model placed on the terrain are the same (same .obj and texture files, but they don't share the same ModelInformation instance etc.) - When I switched the item in my hand to another item suddenly all flowers are going black. When I switch back and forth they sometimes become colored again and then when I keep switching they go back black again, weird.

    I attached two screenshots of the all black issues and the lighting issue.

  • Hmm... I guess the plants are placed as World3DModel? When holding them in your hands, they're probably implemented as CustomItem? Did you call setLightingEnabled(true) on the world models? Does the .obj file actually contain normals (some 3D models apparently export to .obj without including the normals)?

    It's a bit difficult to say what's causing this exactly :thinking: Could you maybe send me your plugin (e.g. via PM), so I could try to reproduce this issue?

    is there some way to enable rendering the backsides too?

    That's possible, but unfortunately this isn't exposed to the API yet. We could change that, but unfortunately we have no ETA for the next update for the Java version...

    However, if backface culling is disabled, they would still use the same normals (facing the wrong direction in this case). This would be treated differently in the new version (and I will put this on our todo-list for the new version), but if you're targeting the Java version, I'd recommend to just create the backface in the modeling application for the time being ;)

  • Oh I think the model is really missing normals. Downloaded it somewhere and didn't think it'd be that bad, also noticed that it has waaay too much vertices. I'll try again with another model next days. If it's still not working I'll post again. ^^ You'd think the 3d artist cares about keeping it low-poly etc., but nah....

    The code is basically the same as your Custom Model Loading plugin. So it must be a problem with the model.

  • red51 It actually was a problem with the model, regarding the lighting.

    But it seems like the flower going black sometimes when I switch between tools and the flower item in my hand, still persists.

    This is the source code: (work in progress)

  • hi kannst du mir mal das moddel leihen
    dann könnte ich mal schauen wegen dem moddel ob ich den beleuchtungs fehler auch hin bekomme

    könnte es sein das du ein stück des moddels im boden hast bzw den 0 pungt zu tief hast

    ich habe mal normale pflanzen gepflanzte
    und die dann die erde hoch gesetzt da wurden die auch schwarz

    die haben auch noch bunte lampen unten drunter gesetzt das sie weider etwas farbe bekommen

  • Thanks for the source code! I was able to reproduce the issue and it's indeed a bug =O It happens if a model is used for both custom items and world elements. We will fix it with the next update, but unfortunately we have no ETA for the next Java update :thinking:

    However, there is a small workaround to avoid this issue: Instead of using the same model file for the world element and custom item, you could just use two versions of it. For example, you could use "flower_01.obj" for the World3DModel, and a copy of that file called "flower_01_item.obj" for the CustomItem. Of course this adds some small overhead since both models need to be downloaded by the client (even though it's basically the same model), but this shouldn't be a big issue. You can still reuse the textures.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!