Specular-Glossiness Pbr Material plugin to override METALLICWORKFLOW

I’d like to be able to switch modes from a metallic-roughness material to a specular glossy material on the fly. I’d also like to use a singular ORM texture for both, which currently forces the material into metallic-roughness mode.

In principle, when in specular-glossy mode I would like to get the:

  • Occlusion from the Red channel of the ORM texture (already possible in metallic mode)
  • Specular as an intensity/white value from the Green Channel (roughness in metallic mode)
  • Glossiness as an intensity/white value from the Blue Channel (metalness in metallic mode)

I was thinking of creating a MaterialPlugin in order to achieve this, and was hoping for some guidance from the forum.

It looks to me that the metal workflow is initiated by setting the define METALLICWORKFLOW. This happens if certain values are set within the PBR material.
Would I simply be able to:

  • #undef METALLICWORKFLOW in my plugin to enable the specular-glossy workflow?
  • Use the material plugin to set where it gets the colors for the specular-glossy workflow?

I realise there will be a number of headaches within the above steps, but I was wondering if there are any other major steps that I haven’t considered? Or any advice that you would recommend?


cc @Evgeni_Popov

It may work…

Here’s what is conditioned by METALLICWORKFLOW in the js code:

So, if you undef METALLICWORKFLOW, you will need to set vReflectivityColor to the correct value in the plugin material’s bindForSubMesh method.

I don’t see any other problems so far, but it’s of course untested and unsupported, so do it at your own risk :slight_smile:


Thank you, that was really useful information :+1: