So im still a noob so please forgive my learning baby steps.
I bought LYS to make a .dds HDRI , im loading it and it works, i used createDefaultSkybox and I could see it there. I did also set scene.environmentTexture so it should be used for IBL.
I loaded a glb i created in blender and targeted one mesh in it and set the material to a PBR material , this works and if I change the albedoColor or roughness or mettalic I can see the changes happening. I can also see the HDRI in the reflection so it is affecting the material rendering.
What does have me stumped is as mentioned in the title , setting ambientColor or setting environmentIntensity does not have any affect , the mesh material looks exactly the same. What am i doing wrong here??
(ps another bizarre aspect of this test is that when I set the material the normals get all messed up? Why does setting a different material have any affect on the face normal direction? that should never be happening The normals are fine when the glb loads , after I set this material it looks like the get inverted , although it looks like it does invert them totally … if someone could explain why this is happening i would be grateful )
Here is the code :
var testMaterial = new BABYLON.PBRMetallicRoughnessMaterial("testMaterial", scene);
testMaterial.environmentTexture = hdrTexture;
testMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
testMaterial.metallic = 0.105;
testMaterial.roughness = 0.08;
testMaterial.environmentIntensity = 0.1;
testMaterial.ambientColor = new BABYLON.Color3(.5,.5,.5);
testMaterial.backFaceCulling = false;
mesh.material = testMaterial;
As can be seen setting the environmentIntensity of the material has zero visual change. I didnt include shots for ambientColor but I can assure you it looks identical no matter what I set it to or no matter what environmentIntensity is set to … any combination of values … it does not matter the result is zero change in visual appearance. please hrlp what am i missing here?
the ambientColor is multiply with the scene ambient color, black by default, so your color * black = black
it seems you have a scene.environmentTexture + testMaterial.environmentTexture (which are both using the same file if I’m not wrong), so I guess, but I’m not sure, the environmentIntensity lower only the material one? You have to know it’s not necessary to reassign the environmentTexture on a material if the scene already have one. Try deleting the testMaterial.environmentTexture = hdrTexture; line for testing
about the normals orientation, it may have to do with sideOrientation where 0 == BABYLON.PBRMaterial.ClockWiseSideOrientation and 1 == BABYLON.PBRMaterial.CounterClockWiseSideOrientation
Thanks a million for the deep knowledge you are sharing , I will try remove it on the material and then do the testing again. ( maybe that should be in the docs, or inside the engine it should resolve itself regardless of where or how many times you set this value,. Is there a good reason why it can be set from two places?? )
I didnt know triangle index direction is set on the material? Seems a bit odd, I would think it should belong to the mesh and the material should not have anything to do with this.
This makes sense as i can have two objects share the same material and have different windings for example - because the winding belongs to each mesh. The material will work properly on both of them, also I only need to ever edit one material and the changes will propagate to both objects as they share a material
Currently the material having the setting means I have to create two materials , each with a different winding and then set them to each object. Now this means I no longer have the power that comes with both objects sharing one material when it comes to editing…
Based on the logic I stated above this doesnt seem ideal unless im missing something - if anyone wants to explain the pro reasons why this choice was made im all ears, i could be overlooking something, otherwise i guess we just stuck with the “not ideal logic”
ambientColor is definitely about the multiplication with the scene one.
environmentIntensity does not exist on PBRMetallicRoughnessMaterial, only on PBRMaterial. PBRMetallicRoughnessMaterial is meant to be an easier version: Babylon.js Documentation
About normals, if your material/mesh have been edited to be double sided you need to reproduce what is done in the loader:
if (material.doubleSided) {
babylonMaterial.backFaceCulling = false;
babylonMaterial.twoSidedLighting = true;
}