Curious Events With billBoardMode And Material Type

As I continue to try and develop and continue Merlin and Morgana, I’m trying to create a possible second scene set on a little island (loosely based on a painting called the Island Of The Dead. The island has a lot of trees so I have been trying to use a simple vertical plane with a simple tree texture in a .png format (RGBA) that is Bill boarded so it always faces the camera. I created instances on the island with Geometry Nodes then billBoarded in code.

I build in Blender 3.3 and export to BJS using @JCPalmer 's exporter. I had taken to exporting in a PBR material format for materials (just a simple check button in the exporter). Anyway, unknowingly I ran into all kinds of grief. Only when I exported as a Standard material did I get more of the result that I was looking for.

Test 1 of billBoardMode with export from Blender with Standard material : Island with trees

Test 2 of billBoardMode with export from Blender with PBR material : Island with Trees

The javascript code is the same for both examples. The only difference is the .babylon file that I am importing, and the only difference between them is one uses Standard as opposed to PBR materials.

Watch blocks of trees appear to move around in the second test as you rotate the camera.

Anyone know what is happening? Why does the type of material have this impact

cheers, gryff :slight_smile:

And now, from my experiments this afternoon, it looks like there will be problems with using a fog node too with PBR materials :frowning:

cheers, gryff :slight_smile:

The PBR version has the property useAlphaFromAlbedoTexture set for tree materials, while the standard version does not (the property is named useAlphaFromDiffuseTexture in this case).

Because of this, the trees are considered transparent and do not write to the depth buffer, which leads to these artifacts. useAlphaFromAlbedoTexture should be set to false, or alternatively transparencyMode should be set to Opaque.

The fog should work with PBR materials, could you make a repro so we can see what is going on?

1 Like

@Evgeni_Popov : Thanks Evgeni, the " useAlphaFromAlbedoTexture`" trick worked fine, I just added a few lines of code to grab the material and then set the value to false. Done! :slight_smile:

And now the fog,

  1. With Standard Material : Island
  2. With PBR Material : Island (PBR)
    Both scenes use the same javascript code but much of the PBR scene looks washed-out so I reduced the fogDensity property for the PBR example : Reduced fog PBR island

The major oddity however is the terrain - no fog in PBR examples. Now the terrain is textured using the “MixMaterial” script. I know that the script does not allow normals - so I’m not sure what other limits there are that might screw up the MixMaterial or fog coding!

And thanks again for your explanation of the tree problem :slight_smile:

cheers, gryff :slight_smile:

In fact, there is fog in the terrain but it is barely visible because of the very small value you use (0.0005), whereas you use 0.0025 in the standard case.

It is difficult to mix standard and PBR materials in the same scene, because they do not behave the same way.

What you can try to do is to change the fogDensity to 0.0025 just before you render the terrain, and set it back to 0.0005 afterwards.