Jump to content

Loading materials for node in 2.6


photo

Recommended Posts

In 2.5 materials loads automaticaly after using this statement:

NodeReference::create(path)

Could you provide me how to load materials in 2.6 ?

Same instructions can't find materials' guids.

Log outputs:

Object::setMaterial(): can't find guid "..." material for "mesh..." obejct

Now I solve the problem by using Materials::get()->loadMeterial(path) function with manual pointing to materials' files. Is it more simpliest and/or correct way to load materials?

Edited by shtams
Link to comment

Hi shtams!

Materials for NodeReferences are loaded automatically when you call this:

NodeReference::create(path)

the same way they did in 2.5. So, normally you shouldn't use the Materials manager to load materials and assign them manually one by one.

But in your case the problem seems to be in wrong material GUIDs stored in the *.node file, that you use to create a NodeReference or some sort of GUID mismatch (can't tell you exactly, as you didn't specify the details of your project's migration).

The point is that materials system has changed in 2.6 (see the devlog) and the hierarchy is now based on GUIDs. Make sure you carefully read the content migration guide.

Maybe something went wrong while you were upgrading your project from 2.5 to 2.6.

Try checking if GUIDs of materials assigned to surfaces in the contents of your *.node file are the same as the GUIDs stored in the corresponding *.mat files, that you're loading via Materials::get()->loadMaterial(path) ...

Fixing the mismatches should solve your problem!

Hope this helps!

Thanks!

Link to comment

If I put materials in main data_path, works great. But materials wont load from additional data pathes? Why not?

Console command filesystem_list shows that materials loaded to cache at first time.

Link to comment

More info here!

I use "filesystem_reload" at runtime.

Case 1:

  1. put .mat in data2
  2. create .ulink file in data1 with text: "c:\data2"
  3. filesystem_list shows c:\data2 in cache
  4. start arguments is "-data_path ../data1"
  5. findMaterialByGUID returns not null

Case 2:

  1. put .mat in data2
  2. create .ulink file in data1 (empty)
  3. start argumets is "-data_path ../data1"
  4. modify .ulink with absolute path to data2
  5. run console "filesystem_reload"
  6. filesystem_list shows c:\data2 in cache
  7. findMaterialByGUID returns nullptr
Link to comment

I see, now it's much clearer!

The point is, that the Engine loads all materials from all data folders at startup. At runtime filesystem_reload does add new external folders, but it does not update the list of materials in the Materials manager. So, the only way in your case is indeed to load them manually via Materials::get()->loadMaterial(path)

Thanks!

  • Like 1
Link to comment
×
×
  • Create New...