Replace material on gltf import, no shadows

Hi all. I’m importing a gltf file into my scene. When I keep the original material, shadows cast on the ground just fine. But if I replace the material with another one, the shadows vanish. Here’s a playground example that illustrates what I mean:

https://playground.babylonjs.com/#PC8K51#4

Toggle the “replaceMatOnGLTF” variable to retain or replace the material. That way you can see for yourself that the shadows appear and disappear.

Any ideas how to modify the new material so it casts shadows too? Thanks!

Hello this is because the culling order of your material is reverse

Just make sure that the new material.sideOrientation=oldMaterial.sideOrientation

Much thanks for your help. I implemented your suggestion here:

https://playground.babylonjs.com/#PC8K51#6

When replaceMatOnGLTF = true, it now additionally applies the old material’s sideOritentation to the new material. But still no shadows. When replaceMatOnGLTF = false, it keeps the material from the gltf file, and shadows appear.

Thanks,

Jacob

ok my bad, I should have checked more precisely. Here is the answer:
https://playground.babylonjs.com/#PC8K51#7

You mesh has vertex alpha value so it is considered as transparent. The default PBR material was turning that off so you need to do the same but s you are not creating a PBR you ahve to turn it off on the mesh directly

1 Like

Thanks so much for your help with this! That was exactly it. All the best.

Woosh, I just learn that vertex could have alpha value ahah. Could be useful for terrain by making overlapped meshes using different materials but mixed with alpha, right?

I don’t see any vertex alpha painting option in Blender, if someone knows if it’s possible?

1 Like

Yes vertex painting can be really useful for this kind of scenario.
I used to work with a designer who loved using alpha on vertices :slight_smile:

1 Like

I saw someone complaining about it in a Blender artists Discord a couple months ago, and he said he opened a ticket for Blender 2.8, but as far as I know we’re still stuck with just RGB for Blender vertex painting unfortunately!

1 Like

I just see in 2.8 this:


But can’t succed to see if it works or not, frustrating :smiley:

1 Like

Hahaha yeah me neither, I tried messing with it a bit, but no such luck. I usually use vertex colors in the cycles shader using the “Attribute” node, but the converter only has a “Separate RGB” instead of a “Separate RGBA”, so I have no idea how to access it that way. Maybe it’s still a work in progress? :smile:

Mystery not-so-solved-but-a-little! #58711 - Viewport doesn't show or render vertex painted alpha. - blender - Blender Projects

Also worth noting is that the painting of vertex alpha is only possible in 2.79 master. It has never worked in 2.79 official.

1 Like