three.js
three.js copied to clipboard
New Material Type For Threejs
This material is a much better approximation for diffuse materials for dusty/porous surfaces that exhibits back-scattering and saturation effects that are missing from prior diffuse models like Lambert. It has a very low cost as compared to MeshStandard /MeshPhysical material. Can be used as a cheap alternative for surfaces like skin/clouds/pots...etc .
The method :
It has been directly taken from the recent 2021 paper : https://d1qx31qr3h6wln.cloudfront.net/publications/lambertsphereBRDF.pdf
📦 Bundle size
Full ESM build, minified and gzipped.
Filesize dev |
Filesize PR | Diff |
|---|---|---|
| 678.5 kB (168.2 kB) | 684.7 kB (168.8 kB) | +6.16 kB |
🌳 Bundle size after tree-shaking
Minimal build including a renderer, camera, empty scene, and dependencies.
Filesize dev |
Filesize PR | Diff |
|---|---|---|
| 456.7 kB (110.3 kB) | 462.6 kB (111 kB) | +5.95 kB |
Can somebody help me with the unit test. Thanks !
Looking at the code, it seems the computations are less expensive than the standard material but more expensive than the normal lambert implementation. So I don't think it would be a candidate for replacing the so far cheap lambert material.
Besides, do you think it's possible to implement this in examples/jsm/materials instead.
Or even better, do you think you can implement this material with the new node based material system? If you write the shader code with TSL, it will work for WebGL and WebGPU at the same time.
At the current state of the project, it's probably better to not add more default materials in src (meaning just for WebGLRenderer) unless there is a good reason. TBH, I don't see this for MeshSphereLambertMaterial so far.
Looking at the code, it seems the computations are less expensive than the standard material but more expensive than the normal lambert implementation. So I don't think it would be a candidate for replacing the so far cheap lambert material.
Yes that is true but it should not be candidate for replacement for MeshLambertMaterial. As that is extremely cheap, this is just a few steps more but a lot better approximation .
Besides, do you think it's possible to implement this in examples/jsm/materials instead.
I think I can do that but should not it be a new materia in the Three.js library?
Or even better, do you think you can implement this material with the new node based material system? If you write the shader code with TSL, it will work for WebGL and WebGPU at the same time.
I have not looked into the node based material yet. I will look into it .
At the current state of the project, it's probably better to not add more default materials in src (meaning just for WebGLRenderer) unless there is a good reason. TBH, I don't see this for MeshSphereLambertMaterial so far.
Sure, I feel it's a good candidate as a separate cheap back-scattering material . Tell me if you feel otherwise .
Related #8354.
I think it would be nice to have a diffuse material that exhibits retro-reflection at grazing angles. The moon has often been used as a canonical use case.
Some interesting images here: https://www.rombo.tools/2021/12/15/lambert-sphere/.
If the material could be added as a Node Material, I think that would be great. If you need help, there are contributors here who can help you.
I think I can do that but should not it be a new materia in the Three.js library?
Well, not in the core. But putting it in examples/jsm/materials will make it usable like MeshGouraudMaterial which should be sufficient.
That said, a node-based implementation would be the preferred, more future-proof approach.
Closing. Please implement this via TSL as an addon material.