Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

three.js R71 - ambient removed, how configure to get same rendering results?

In three.js r71 the ambient property has been removed from THREE.Material.

Previously I used ambient to set correct rendering (lighting) effect of the materials that I used on my meshes. Now the appearance of all my meshes changed dramatically.

How can I get my materials rendered exactly as before r71?

like image 719
Wilt Avatar asked Dec 08 '25 00:12

Wilt


1 Answers

Here comes the why...

According to @WestLangley; I quote from his post in the discussion (link from @pprchsvr):

material.ambient was the ambient reflectance of the material. For real-world objects, it should normally match material.color, the diffuse reflectance of the material. (Objects, after all, do not know where the photons came from.)

We chose to simplify the API, and hardwire material.ambient to match material.color. Consequently, material.ambient has been removed.

This means you will no longer be able to set an ambient color that differs from the material color and there is as far as I know no "quick fix" to get the same rendering results for those materials as before.


  • A possible solution would be to try make the material appear as before by tuning/changing the material color and the ambient lighting in your scene.
    See also the three.js documentation for THREE.AmbientLight and THREE.MeshBasicMaterial (and the other materials) for reference.

  • Alternatively you could create your own shader material using THREE.ShaderMaterial where you (re)create a shader that allows you to explicitly set an ambient color.

like image 124
Wilt Avatar answered Dec 12 '25 07:12

Wilt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!