`ambientColor` is not worked in PBRMaterial

Hi everyone. It seems that .ambientColor does not work in PBRMaterial. Here is the reproduction:

Is it expected or am I missing something? Thanks for reading!

1 Like

Hi!
materialPBR.metallic = 0 otherwise it reflects the non existing environment.

2 Likes

Thanks for your reply! After adding .metallic=0, the .ambientcolor does work.

However, I find that the parameter of .metallic in the inspector panel is inconsistent.

What is the default value of .metallic? If I comment the line of setting metallic to 0, the inspector still shows that the metallic value is 0. However, when I uncommented the code, the rendering results changed.

From what I’ve seen, if I hadn’t added this line, the rendering result would be like the
metallic value is 1. I finally knew why I couldn’t reproduce the rendering result of Blender. Why the default value is 1? This is unusual and seems not to be documented.

It also means that each PBRMaterial in Babylon.js should manually set metallic to 0 which is really unexpected since Three.js, Unity, Blender, and other 3D software all set PBR metalness to 0 by default.

Here is the playground you can replay:

metallic is null by default, that’s why you need to set a value.

Yes. When the .metallic value is null, it will eventually set the value to 1. From this perspective, if we don’t set the value, its effect is equal to setting the value to 1.

Is it possible to improve this behavior? It is a little bit uncommon and I guess it may confuse some users.

There could be so many apps running in production which relies on the default value of 1 already. I don’t see this as a technical bug more like a discrepancy from the specification. I’d like to have the default value as written in the specs too, however it would introduce a breaking change.

Let’s wait for the others…

1 Like

OK. The ambientColor problem is solved, and it works on PBRMaterial after setting the .metallic value to 0.

For the PBR default metallic value problem, I’m posting it at: PBR default metallic value is not 0 which is unusual

And notice that the inspector’s inconsistent metallic display value issue is still not resolved.

This is only the case if you have a texture so the texture value multiplies with 1 ensuring you can set the texture only. In other cases you won t use the metallic workflow.

We won t change the default as it is too big of a breaking change.

2 Likes

Hi, thank you for your reply. The playground posted above explains that if an empty PBRMaterial is created, its rendering result is equivalent to metallic set to 1. So it doesn’t seem to matter if there’s texture. When a user creates PBRMaterial without any other operation, its metallic effect is equal to 1. I think this behavior may be clarified in the documentation.

By default you are using the Spec/Gloss workflow, those steps are needed to use a metal/rough one:
https://doc.babylonjs.com/features/featuresDeepDive/materials/using/masterPBR#from-metallicroughness-to-pbrmaterial

In spec/gloss the reflectivityColor (aka specular) defaults to white.

I wonder whether the confusion is more about the current default value (white) or the default workflow ? Asking to better target the doc update.

1 Like

The playground above has already set .roughness to 1, which means it uses Metallic/Roughness mode.

Even if PBRMetallicRoughnessMaterial is being used, the default metallic value is still 1.

Make sense, I ll update the doc.

2 Likes

I agree with @sebavan (and sure we can always improve the doc). In the end I think (my opinion) we are doing a lot of ‘fuss’ (sry) around something that need to be learned ‘per app’ or ‘per design’ no matter what. But then again, that’s just my opinion.

You are probably right. Maybe this is just a ‘fuss’. But it took me several days to tune the rendering just because I didn’t know the metallic value was 1. I feel like it could also happen to someone else. Are there any other default parameters in Babylon.js that differ from common expectations? Now I’m even less sure. The design principle seems to be based on historical reasons rather than user experience.

Of course, Babylon.js team definitely has more contextual information on this, so I’m just passing on what I perceive.

This is a choice we made to allow setting textures without factors issues. It is also 1 to be consistent with the specular case or any case where this is used as a factor so it prevents to set a value when a texture is used. If we were setting 0 by default, you would probably have posted that you use a texture and do not understand the value is unused and you spent several days figuring it out :slight_smile:

Also if you think about common expectations, GLTF is probably one of the few standard nowadays and it is 1 as well:

So, yes, this is an arbitrary choice aligned with an ISO standard simplifying the use of textures so as long as the doc explains it it should not be an issue. If you want to be sure the doc is the most helpful, feel free to do the PR there and I will gladly merge it.

1 Like

I can’t agree more.

You have the answer:

and you have a solution to your problem:

and you’re still fussing around :smiley:

Dude, it took years for hundreds of contributors to give you babylon.js, for free.

Peace!

1 Like

OMG. I can feel the heat :thermometer: May be you should cool down a little with a fresh beer and a break :beer: :beach_umbrella:?

Hum? :face_with_raised_eyebrow: Likely true and then, I wasn’t here at the beginning neither :stuck_out_tongue_closed_eyes: I don’t think this kind of comment is appropriate (sry). We should be happy that there are people wanting to help improve and normalize the framework to push it even further and to the next level, shouldn’t we? In my opinion, it’s just a matter of finding a balance between the pros and cons. Nothing easy, nothing easy for sure. :student:

What heat? I’m OK :slight_smile: I believe @yar2001 will not take it personally because I didn’t mean to harm anyone’s feelings. You know me, I’m the clown, the comedian, the jester, the punster, the meme maker around here :smiley:

@yar2001 one more time - sry if you’ve had bad feelings after you saw my meme - but it’s damned funny and you’ll take it as an advice just to move on for now with that what we have available…

1 Like

If it’s not neither his comment about spending days to find out something is appropriate. Trying to convince others of your truth by how much time you spent on it is not appropriate. That’s why I responded like that.

@yar2001 's other technical observations are ABSOLUTELY appropriate.

1 Like

Well, one would first have to define “common expectations”. Common in which sense? A 3D engine, a real time 3D engine? Unity, unreal, three.js (they are already all different)? Common expectation as you say, is not a norm or a convention.

Well, as far as I know, the design principle is historical in that it is based on the pillars of the BJS experience: Open, free, simple, reliable, powerful. One of these pillar being ‘reliable’ (read ‘backwards compatible’). So if your question is: “Are there choice of design made for ‘simplicity’ or to ensure the largest use case, per design?” The answer is “absolutely”.

If your question is: “Are there some disparities, approximations in the names or default values of parameters?” The answer is “I’m afraid there is”.

If your question is: “Is BJS going to change it all at once and while doing so, break its promess and temper with one or more of the pillars that’s part of its DNA?” The answer is: “I sure hope it won’t… I sure hope the Team won’t allow this to happen… and if so, you’re gonna hear my voice for sure :sweat_smile:”.

Fair enough. That’s what we all do in the beginning. I totally remember doing this for a while. But in the end, the framework and the values aren’t just based on ‘perception’. They cannot be. I believe the most important is that it remains both ‘consistent’ and ‘true to its values’. Again, as always, my opinion only. :smiley: And meanwhile, have yourself a great day :sunglasses: