[SOLVED] Model simply renders black using `StandardMaterial`

When I set a material to a volumetric model (a new format I’m porting over), it just goes black.

The same happens for the MS Hcap demo, for testing: Volumetric Video Microsoft MRCS - PLAYCANVAS

function findHoloVideoPlayer() {
    const entity = pc.app.root.findOne(_ => _.c?.script?.["holoVideoPlayer"]);
    if (!entity) {
        console.warn("no entity with holoVideoPlayer script found");
        return;
    }
    return entity.c.script.holoVideoPlayer;
}
/**
 * @param {pc.Color} color 
 * @returns {pc.StandardMaterial}
 */
function createMaterial(color) {
  const material = new pc.StandardMaterial();
  material.diffuse = color;
  material.update();
  return material;
}
const white  = createMaterial(new pc.Color(1, 1, 1));
const red    = createMaterial(new pc.Color(1, 0, 0));
const green  = createMaterial(new pc.Color(0, 1, 0));
const blue   = createMaterial(new pc.Color(0, 0, 1));
const yellow = createMaterial(new pc.Color(1, 1, 0));
const player = findHoloVideoPlayer();
const holoVideoEntity = player.entity.findByName("HoloVideoEntity");
holoVideoEntity.c.render.meshInstances[0].material = red;

Result:

Does anyone know what’s going on here?

Do you have any light or prefiltered cubemap in the scene? Or ambient color? Those are the sources of light.
Alternatively, instead of diffuse, assign your color to emissive on the material.

I can add a directional light like this:

var light = new pc.Entity();
light.addComponent("light", {
    type: "directional",
    color: new pc.Color(1, 1, 1),
    range: 1000,
    intensity: 1
});
light.setEulerAngles(-45, 0, 45);
light.light.intensity = 0.5;
pc.app.root.addChild(light);

pc.app.scene.ambientLight is [1, 1, 1, 1], that should also be okay?

The model is still black after adding the directional light :confused:

Another example, which works, loading a JPG into a texture:

function materialFromImage(url) {
  var decalMaterial = new pc.BasicMaterial('decal');
  var uvTestTexture = new pc.Texture(pc.app.graphicsDevice);
  decalMaterial.colorMap = uvTestTexture;
  decalMaterial.update();
  var uvTest = document.createElement("img");
  uvTest.crossOrigin = "anonymous";
  uvTest.src = url;
  //uvTest
  uvTest.onload = () => {
    uvTestTexture.setSource(uvTest);
  }
  return decalMaterial;
}
function findHoloVideoPlayer() {
    const entity = pc.app.root.findOne(_ => _.c?.script?.["holoVideoPlayer"]);
    if (!entity) {
        console.warn("no entity with holoVideoPlayer script found");
        return;
    }
    return entity.c.script.holoVideoPlayer;
}
const player = findHoloVideoPlayer();
const holoVideoEntity = player.entity.findByName("HoloVideoEntity");
const decalMaterial = materialFromImage("https://s3-eu-west-1.amazonaws.com/apps.playcanvas.com/3dfa1892/thumbs/180.jpg");
holoVideoEntity.c.render.meshInstances[0].material = decalMaterial;

Result:

But a simple colored material doesn’t work :thinking:

how about setting emissive color on the material?
Does your model have normals?

Thank youuu! It was the normals :see_no_evil: