Is it possible to create a Basic Material in the Editor?

I can’t use Standard materials because of the default shader. Or, maybe, I just don’t know how to disable shading and make an unlit material in the Editor. But I’ve found this: BasicMaterial | PlayCanvas API Reference
I think it is a perfect “template” to create unlit materials, but is it possible to use it in the Editor? Or I need to create all materials in code (at runtime)?

Hi @Dan_Organ,

No you can’t use that in editor, you will have to do that using a custom script.

For unlit materials you can do the following on the standard physical material:

  1. Disable Use Lighting on the Other tab of the material:

image

  1. Use the Emissive channel to add color to your material:

image

2 Likes

Thanks, Leonidas. I’ve created an unlit material by setting Emissive and Opacity texture maps. Opacity is for alpha-test only, it is the same texture as Emissive. Diffuse is null.
BTW, I need unlit materials to achieve maximum possible performance on mobile devices. Do you think it is alright to use the Standard material in such a way? Or it is better to create Basic Material in my scripts?

I think yes, the PlayCanvas engine will make sure that the material compiles the minimum shader required.

Tum off any other feature you may not need, like Use Skybox, Use Tonemapping etc and performance is going to be great.

For those who want to create a simple unlit material with a script:

UrlLoader.prototype.loadMaterial = function(_name) {
    var self = this;
    this.app.assets.loadFromUrl(this.textures_path + _name + '.png', 'texture', function(err, asset) {
        var new_texture = asset.resource;
        var new_mat = new pc.BasicMaterial();
        new_mat.color.set(1, 1, 1);
        new_mat.colorMap = new_texture;
        new_mat.alphaTest = 0.1;
        new_mat.update();
        self.entity.model.meshInstances[0].material = new_mat;
    });
};

Attach this script to your entity with a model component. You must specify a path to your opacity textures (I am using textures_path and _name).

2 Likes