Change in how materials are handled? Or in archive export

Hello. I decided to add another asset to my game today, so I uploaded it to the playcanvas website as a .fbx, then downloaded it as a model archive, the normal way.

Upon including it in my project, it wouldn’t load. Playcanvas spouted ‘data.parameters not defined’, and the callback from “app.assets.loadFromUrl()” simply never ran.
To check to see if it was my version of playcanvas being out-of-date, I grabbed the latest build from github.
Now it didn’t even spout an error, loading simply stopped with no errors, and the callback never runs.

Upon inspecting the material file, I noticed that the path to the image the file uses has not been refered to anywhere. Closer inspection reveals a couple surprising things:

  1. The exported zip file has 6 files representing the material, all with the same name, but some are different to each other. They are really small.

  2. These .json files are different to what they used to be:
    Old material files start off:

    {“parameters”: [
    {“data”: false, “name”: “ambientTint”, “type”: “boolean”},
    {“data”: [0, 0, 0], “name”: “ambient”, “type”: “vec3”},

These just jump straight into it:

{"opacity": 1, "fresnelModel": 2, "name": "ParticleGlow", "conserveEnergy": true, ....

The asset works fine in the playcanvas online editor, and in game there, so it isn’t the asset that’s wrong. So at the moment I suspect it’s the export model archive utility, or that you’ve changed the material handling and haven’t pushed the changes through to github.

The material format has indeed changed, but model loading should be fine. It seems to work with some of the models I’ve tried. It’s not possible to not push changes to Github as the PlayCanvas Editor uses the latest version of the engine (which is on Github).

Can you maybe PM me a zip of your model export so I can test locally?

Here’s the model that I got using the ‘export model archive’ button:

Note that there are six files in the one folder, wach with the same name.
I’ll try grabbing the engine again, maybe I did something funny.

On the other hand, I assumed it was the new file that was breaking things, because the old ones still loaded, and the new one looked different, and if I commented out the lines getting it, my game resumed working.
Is there still support for the old material format? Or do I need to re-convert my old models?

Ah there was a bug in our resource loader. I pushed a fix in the engine master branch. Let me know if that fixes your issue - seems fine here after the fix :slight_smile:

So the playcanvas engine now loads the object. I can’t see it because the exported material is wrong.

In the editor it looks like:


I have circled the diffuse texture map in red.

But when it exports, there is not even a diffuseMap entry in the json file, or anywhere else as far as I can see. There is nothing linking to the Particles.jpg texture sheet.
As a result, or perhaps for some other reason, when I try to load the model, I can’t see it.
No model I export has a reference to any image textures, so it looks like the export is broken.

Can you give me read access to your project? My username is vaios. If you have ‘private source assets’ enabled I will need write access

Done.

So inside the project there are two model assets:
One is called ‘SixShip.’ When it exports it creates a material file including ‘diffuseMap=’/path/image’.

The other asset is called ‘Laser.’ When it exports it’s material file does not include a diffuseMap entry to it’s material, though the material does use a diffuse texture map.

Thanks,

I fixed another bug in the exporter. Could you check if it’s OK now?

Yup, working fine now.

Let there be lasers… Oddly persistent, show-through-cockpit-lasers, but … lasers, LASERS. It’s up to me now.

1 Like

One more material problem…

I’ve put a new laser bolt in the project, and this one uses only a single plane per ‘sprite,’ relying on the ‘Cull Mode’ to ensure both sides are drawn. This is exported (The entry “cull” appears in the json), but is not changing much.
I tried manually setting the values in the material file, and the changing the value has very little affect. There are two settings:

  1. The value 2: Show Nothing
  2. Any other value: Normal Back-face culling.

Yeah, I know, I should just add in the extra planes

Model:

I think this looks OK to me - The available culling modes are:

 - pc.CULLFACE_NONE
 - pc.CULLFACE_BACK 
 - pc.CULLFACE_FRONT
 - pc.CULLFACE_FRONTANDBACK

You currently have pc.CULLFACE_NONE which does not cull anything. If you try the other values you will see a difference.

Hmm, so I’d expect pc.CULLFACE_NONE to make both sides of a face to appear identicle? Makes sense to me.
So with the laser model above, I stuck it in the default spinny-load-model-example. You can see that the faces do not appear the same from all angles. No idea why. May be a problem with the model.
Demonstration

You’ve got light in that scene, and faces are illuminated based on their normals.
For such basic material, you could use pc.BasicMaterial which ignores the lighting.

Alternatively, use the pc.PhongMaterial but set diffuse and specular to black and set the texture as emissive. Then lighting won’t affect the geometry.

You are correct.I completely forgot that the color of an object is dependant on the amount of light hitting it!
My apologies.