We can use
scene.overrideMaterial=normalMaterial to render all normal information to rendertarget, because normal is based on vertex position.
However, the metalness information is the specified property when creating this material, and each material is different. So a unified overrideMaterial cannot be used.
Is there any efficient way to do this? Must I traverse all objects or materials to change it then restore?
If you define an override material that needs to apply an existing material property like
metalness then yes. You have to traverse through the scene graph, check for all materials, create the override material, assign the
metalness value and then use it for rendering.
To clarify: Compared to
MeshNormalMaterial, you have to create an override material per existing material. Meaning you can’t use a global override material for the entire scene so
Scene.overrideMaterial will not work in this use case.
Thanks! With your confirmation, I’ll proceed to use traverse method first.