Env texture but no light from it?

Hi,

Is it expected to have this code:

scene.environmentTexture = new CubeTexture("/p/sky.env", scene)
scene.createDefaultSkybox(scene.environmentTexture);

not giving any light to meshes on the scene?

As an example I use a box in its simplest form:

 const box = MeshBuilder.CreateBox("box", {height: 1, width: 0.75, depth: 0.25}, scene);

I need to use an Hemi or anything else to get some light.

The sky is perfectly visible.
Meshes as well. But all black, since they get no light. Not a normals issue since when I add an Hemi or any light really, they look like they should.

Is there an option I missed?

I guess it depends. Is it a pbr material you are using on your box? In case, I would say not normal.
However, I believe a standard material would require you to add a light first, yes?

I will check that and report when I am back :+1:

I added:

    let mat1 = new StandardMaterial("m", scene);
    mat1.diffuseColor = new Color3(1, 0, 0);
    box.material = mat1;

but it is still black…

Well, there are already a couple of things that won’t work here.
First thing is you picked an .env texture which is a prefiltered data texture for HDR (not a simple cube texture). So your code for setting this in your environment should be something like:

var hdrTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(“textures/environment.env”, scene);

scene.environmentTexture = hdrTexture;

Next, you are using a standardMaterial but you didn’t set any reflectionTexture on it. So it will not reflect anything.
I suggest you quickly tour these links of the doc and PGs

Else, you can set-up a quick PG and I will make amends for you…

Ahaha:
PBRMetallicRoughnessMaterial is what I needed!

in 3js, standardmaterial is already PBR enabled, but apparently BJS is different here and lead me wrong.

Now, it works in my scene :slight_smile:

Thanks a lot,

1 Like

not necessarly. It could be just PBR or even a standardMaterial. However on a standardMaterial you need to set your environment as a reflectionTexture (because the standardMaterial has no env texture).
Glad you found a way to make it work for you anyways. Have a great day :smiley:

1 Like

No, not here. Not just now. The standard material is NOT pbr enabled. It’s a different class of material with a completely different set of textures and algorithm.

1 Like

Yes Mawa,
thanks for you lightning fast answers, you rock :+1:

No worries. U r welcome. I hope you are enjoying your new experience with BJS.
Feel free to hop in and also contribute (even with simple suggestion) anytime you like. :sunglasses:

3 Likes

→ :ok_hand: :wink:

1 Like