StrandedKitty / three-csm

☀️ Cascaded shadow maps (CSMs) implementation for Three.js
MIT License
296 stars 21 forks source link

Materials CSM #5

Closed dennemark closed 4 years ago

dennemark commented 4 years ago

Hi, I am have been following the PR to three js and am looking forward to the integration. Congrats!

I might miss a bit of knowledge on three js, but does the setupMaterial function consider duplicate materials? Furthermore, does the CSM need a function to remove materials? If a material is deleted from the scene, it might stay in the CSM materials array right?

I am asking, since I might need to assign CSM materials to imported assets such as .obj files. These obj files might even change throughout runtime.

Best!

StrandedKitty commented 4 years ago

As far as I know, materials created using Material#clone() are like any other instances of Material, so they must work normally. Also you should take into account that this implementation handles only Phong and Standard materials.

Though there is an array with materials in CSM class, it is only used in updateUniforms() method. If you don't need to change properties like number of cascades or split mode in runtime then you can safely delete any materials.

dennemark commented 4 years ago

Thanks a lot! I think I can work with it. Hope I can share some results soon! Best!