This code is not meant to be used “as is” in other tools (even in ShaderMaterial). See:
ShaderMaterial