FarazzShaikh / THREE-CustomShaderMaterial

Extend Three.js standard materials with your own shaders!
Other
846 stars 54 forks source link

Shader compilation failure if csm_Feature used is not compatible with base material #36

Closed chasedavis closed 1 year ago

chasedavis commented 1 year ago

Certain csm features like emissive, metalness, roughness, ao, bump only work with certain materials, makes sense!

It'd be great if rather than a shader compilation issue, there was graceful failure when those features are attempted to be used with an incompatible base material. A big use case for this would be for building material editors or otherwise offering some configuration options for materials as is popular.

I believe it can be worked around through patchmaps but might also be feasible or easy to consider doing nothing with the variable assignment (meaning, it's still declared in CSM compilation).

Thoughts?

Screen Shot 2023-04-18 at 11 28 02 PM

pictured: trying to use metalness/roughness with MeshBasicMaterial as base

FarazzShaikh commented 1 year ago

Good idea! Would be trivial to implement as we already store the base material type.

However, custom materials almost never set the type property to something accurate so this might only be possible to check for in first degree extensions which is completely okay

will add this to the next release

chasedavis commented 1 year ago

Wow so fast :D