Backface culling (set as false for a material) problem when model has a texture (glb/gltf)

Hi everyone!

I have a small pickle with my game project. I have several pieces that I’m building the game map with. What I want to do is to have the top part of the pieces colored with a single dark color so they aren’t affected by light/shadow at all (since the game rooms have a different lighting setup each).

I’ve been trying to achieve this by turning the top parts of the wall meshes upside down. The problem can be seen from the picture below; if I give a material and a texture to a model in Blender and export it as glb, and set material.backFaceCulling = false in Babylon, the wall pieces that do not have a texture do work, but the ones with texture don’t. It seems that what I get is the texture backwards instead of a single dark color… Any ideas how to fix this or to provide an alternative solution for the problem? :slight_smile:

the easiest might be to dupplicate the mesh cause you won t be able to easily disable texture from one face to another.

I guess you could clone the mesh and assign a different material with the opposite culling as well as being just a flat color.

1 Like

I see I see… I’m trying to avoid duplicating though since I need to crank all the performance out I can get :smiley: One thing that I will probably do if everything fails is just rip out the top parts from the wall meshes and create them separately… But that also introduces some extra work in Blender and in code!

One other thing I thought was maybe trying to use emission texture for the top parts to keep lit at all times. Like have the albedo texture color be black but then set the emission color at the same place to the max? Would that work I wonder :thinking:

probably not as it is fully mirrored :slight_smile: but worth a try

1 Like

Hello @Panuchka just checking in, was your question answered?

Well, it was answered but there was not a viable solution to the problem other than I already had in mind from the start. I decided to separate the top parts away from the walls, so I have a separate mesh for the actual wall and then the black top part as a separate one. A bit extra work but it had to be done :slight_smile:

2 Likes