scene.environmentBRDFTexture vs scene.environmentTexture

Hey, question :slight_smile:
What is the difference between scene.environmentBRDFTexture and scene.environmentTexture?
I’m asking because, as I said in a different topic, I’m having some issues on create new PBRMaterial because of this environmentBRDFTexture. And if I skip creation of this texture from material constructor seems to work, but I don’t know if in this way I broke something or not.

Hi MarianG,

@sebavan can correct me if I’m wrong here, but I believe the environmentBDRFTexture is essentially a lookup table for use in the bidirectional reflectance lighting function. The environmentTexture is more similar to other textures on the model and is used to determine how “blurred” the environment lighting should appear on particular piece of the model. It’s hard to say whether your material is broken without a Playground or a screenshot or something; but if it looks right and it’s not throwing a bunch of errors, I wouldn’t worry about it too much. :slightly_smiling_face:

Out of curiosity, if you’re looking into making materials, have you checked out the new Node Material Editor? @deltakosh put out a video recently showing how to take materials made from that and use them directly in Babylon.js projects, in case that would be of help to you.

2 Likes

All perfect @syntheticmagus

Great. More questions comming :slight_smile:
So, can I set this environmentBRDFTexture from the scene then, from code? Like the environmentTexture? Should have the same effect, no?
I didn’t find a pg where this is explicitly set

scene.environmentBRDFTexture = new Texture(...)

only
scene._environmentBRDFTexture
or set directly on material
material.environmentBRDFTexture

And fullFloatEnvironmentBrdf.dds texture from the doc is right for this?,
Or maybe I can use this directly in getBRDFTexture function instead of base64?
As usually thanks alot for your help!:beers:

@sebavan, I need some help please :slight_smile:

You should normally never set it :slight_smile: it is all automated and handled for you in the code. The problem is probably coming from somewhere else. Could detail more what is happening or how we could repro ?

Ok. Thank you. I’ll try to reproduce it somewhere.
I’m having an error in my reactNative project when this function ‘CreateFromBase64String’ is called :(. And this function is called exactly to create this environmentBRDFTexture


Actually this is a warning, but because of this warning gltf files doesn’t apear
image
And if I understood well this is because somewhere is using an Image(which is html elem, and here we don;t have html elem) - because of this even to create a simple texture I’m using LoadFromDataString function, I cann;t use directly texture because it is using Image too inside. I hope to make sense what I wrote here :slight_smile:

ohhhhhh I see so you could try the dds approach to prefill the cache before you do anything else:
scene.environmentBRDFTexture = … with the DDS ?

I already add an env texture like this at the begining after I created the scene.

    const envTexture = CubeTexture.CreateFromPrefilteredData('https://preview.smarteam3d.com/build/environment.dds', scene);
    envTexture.name = "envTex";
    envTexture.gammaSpace = false;
    scene.environmentTexture = envTexture;

and put a return at the begining of function GetEnvironmentBRDFTexture. Aaaand all good
Because of this I asked if I still have to set environmentBRDFTexture too.
So shall I add it like this

scene.environmentBRDFTexture = CubeTexture.CreateFromPrefilteredData('https://preview.smarteam3d.com/build/environment.dds', scene);

?

Yup, this will prevent to create the default one but you should use one of the environmentBRDF from the assets folder: like \Babylon.js\assets\environments\correlatedBRDF_RGBD.png and load it as a regular texture not cube, or prefiltered.

You need to set the flag isRGBD to true on the texture and all good :slight_smile:

Hi.
Or I didn’t understand or I missed something, but it doesn’t look too good :frowning:
https://playground.babylonjs.com/#8MGKWK#170

Here you go: https://playground.babylonjs.com/#8MGKWK#172

You were not using the texture adapted to your current BRDF configuration :slight_smile:

1 Like

Yeeeeeaaaah!!! :beers:
It is working like this in my reactNative project too.
Thank you both!
New mistery solved :yum:

ps: I don’t know if this is important or not or if maybe others need or not these informations, but till now I didn’t know about the existance of these textures, maybe we can update the list with available textures from doc

Those are really specifics to the pbr internal use and might be subject to changes. In all case, aside yours :wink: they should not be touched by hand.

I understood… and I promise I won’t touch them anymore :joy::joy::joy:

1 Like