[SOLVED] Black materials only with scripting engine 2

Hello, /preface, I’m and engine only user and I would like to at least keep up with the new scripting format, but when I take out any of the scripts in my scene and old code but just the initial world creation, I get only black shiny materials with no ambient light. I know the scripting update was primarily something that would affect the designer users, but are there now issues with engine users?

Could you please post an example, as it is pretty much impossible to debug anything without actual debugging :slight_smile:

I suspect this is the change causing the issue for you:

In other words, when you do:

var m = new pc.StandardMaterial();

…it now returns a physical material, not a phong material. So if you have a non-black specular color plus non-zero shininess, the material will be more black. This is due to ‘conservation of energy’ of physical materials.

A way to check if this is the case is to force your materials back to Phong:

var m = new pc.StandardMaterial();
m.shadingModel = pc.SPECULAR_PHONG;

Read all about physical shading in PlayCanvas here.

Good find will, thank you. Sorry max for no example, it was kind of an error that looked like it might have generally happened since I downloaded the new library right after release.

I was actually using pc.scene.PhongMaterial() to make my material which seemed intuitive enough to make a phong mat, but using wills worked well. Thank you.

But then you don’t have PBR benefits.

I’m slowly learning all the parts, but for now I don’t really need pbr. I need the coding to work with the new system. Thank you though.