Jump to content

[SOLVED] Problem in assigning manual material to a surface


photo

Recommended Posts

I have migrated all our materials from Unigine 2.3.1 to Unigine 2.6.1 format. But there seems to be an issue when I assign manual material to a surface through node file.

This is how the node file looks like

<?xml version="1.0" encoding="utf-8"?>
<nodes version="2.6">
  	<!--materials>
		<library>Ford_Ranger.mat</library>
	</materials-->
	<node type="NodeDummy" id="797290597" name="Ford_Ranger">
		<transform>0.01 0 0 0 0 0.01 0 0 0 0 0.01 0 0 0 0 1</transform>
		<node type="NodeDummy" id="2146134116" name="Ford_Ranger_LOD1">
			<transform>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</transform>
			<node type="NodeDummy" id="1081169924" name="Ford_Ranger_Wheel_2_LOD1">
				<transform>1 0 0 0 0 1 0 0 0 0 1 0 0 -136.24 37.0209 1</transform>
				<node type="ObjectMeshStatic" id="1564874565" name="Ford_Ranger_Wheel_02">
					<mesh_name>Ford_Ranger/meshes/Ford_Ranger_Wheel_02-lib.mesh</mesh_name>
					<surface name="Ford_Ranger_Clean_MAT" intersection_mask="32" min_parent="4" max_parent="4" max_visible_distance="150" max_fade_distance="5" material="Ford_Ranger_Dirty" property="surface_base"/>
					<transform>1 0 0 0 0 1 0 0 0 0 1 0 0 136.24 -37.0209 1</transform>
				</node>
			</node>
          .
          .
          .
          .

but one loading the world I am getting error:

Object::setMaterialParameter(): no material assigned to the surface

I tried setting it in unigine script and that worked fine which means Material is loaded correctly.

object.setmaterial("Ford_Ranger_Dirty",surface_index); 

 

Please let me know where I am going wrong?

 

Link to comment

Silent please check the test scene attached.

Few more observations related to attached sample

  • Firstly the material is not applied and even if I apply that in manually using editor the parent properties are not set.
  • When I browse "my_material_ball" in editor it does not show the correct parent 
  • If I use GUID in parent_name then also it is not working

(I will try doing this in 2.6.1.1 also)

test_custom_material.zip

Link to comment

Hello, Priyank.

May I ask you what editor are you using? Old or new one (Editor 2)?


I've checked your manual material. Here what you can do:

1. Change xml. Parent_name is incorrect, check this exampe:

<?xml version="1.0" encoding="utf-8"?>
<material version="2.5.0.2" manual="1" name="test_mat" guid="test_mat" parent="439a4939d4ed321f896764d0fd4ed1535a7f73b5" base_material="mesh_base" editable="1">
</material>

In guid you can type name, correct guid will be based on this name.

If you want your material to be a child of base material (like mesh_base) you may skip this. Otherwise in parent specify required parent material guid, you can check it in .mat file.

2. Put your manual material in data folder. This should work.

In Editor 1 you'll see your material as usual, in editor 2 it will be shown as red and only in Materials tab, becaue it has no asset (but still will be working).

Please, let me know if this work for you.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Thanks Morbid,

I have opened the world in Unigine 2.6.1 so hope that is Editor 2

  • How can I choose to open this in Editor 1?
  • why parent_name="material_ball" not working? Isn't parent="<parents_sha_id>" same as parent_name="<material_name>"?
    • parent="<parents_sha_id>"
      • This shows the material in correct hierarchy in materials window
    • parent_name="<material_name>"
      • This shows parent as mesh_base in materials window
  • I have placed the test_scene folder in data directory ball is still shown in red
    • ----test_material.world---
      
      <node type="ObjectMeshStatic" id="319971566" name="material_ball">
          <mesh_name>core/meshes/material_ball.mesh</mesh_name>
          <!-- NOT WORKING:  material is not applied-->
          <surface name="material_ball_mat" material="my_material_ball" property="surface_base"/>
          <!-- This is working but I want to use my custom material in world file
        	<surface name="material_ball_mat" material="716f3df11be2672a4a789a548f4a9ed292ce5473" property="surface_base"/> -->
          <transform>0.99999994 0 0 0.0 0 0.99999994 0 0.0 0 0 0.99999994 0.0 0 0 0 1.0</transform>
      </node>

       

can you please edit and upload the test scene that is working for you.

Edited by Priyank.Jain2
Link to comment

Hello!

How to check or change editor version.

You can switch editor in SDK browser. Click "Other Actions" on a project tab and choose "Configure Project". You can change editor version in workflow drop-down menu. See the attached screenshot.

Manual materials hierarchy:

  1. parent_name="material_ball" doesn't work because this parameter is used for manual materials only.
  2. parent="<guid>" is used when you want to inherit your manual material from material, created in Editor (e.g. material_ball.mat). You need parent_name="<name of your manual material>" when you want to inherit from another manual material.
  3. BUT, I've found a bug. parent_name="<name>" doesn't work for now. I've reported this issue in our tracker.
  4. As a workaround you can inherit from manual material using parent="<guid>".  Guid can be found in guids.db. Type the required name and copy value on the left.

Short summary:

  • If you only want to inherit your manual material from already existing material, like material_ball.mat - use parent="guid".
  • If you want to inherit manual material from another manual material pay attention to 4th paragraph above.

Material name in XML.

Unfortunately you can't use name in xml to assign material to a surface, only GUIDs are acceptable. In case with manual material you can assign it in editor. As a result you'll get a GUID in your .world or .node file.

I've attached a simple scene with manual materials.

Also you can check articles on custom user materials and material file format.

Could you please explain, why you choosed to assign material in XML? Is there a specific need for this?

manual_materials.zip

workflow.PNG

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
  • 5 weeks later...

Hi Morbid,

Quote
  • If you want to inherit manual material from another manual material pay attention to 4th paragraph above.

What I feel is the guids.db will only have <guild> for the materials provided with sdk. How can I get guid for the our own manual material. 

From the document I can see that GUID is created using SHA1 algorithm, Is there any way I can generate guid? (I tried some of the web tools that uses SHA1 but their hash is different.)

Do you expect this bug to be fixed in Unigine 2.7?

Edited by Priyank.Jain2
Link to comment

Hello,

1 hour ago, Priyank.Jain2 said:

What I feel is the guids.db will only have <guild> for the materials provided with sdk

You still can find guid for manual material in guids.db. From left to right you'll see guid, path, name. I understand that using guids.db is not the best solution, but it works.

After we fix manual material inheritance by name this should be much easier.

I've prioritized this ticket but I can't give you 100% guarantee that fix will come in 2.7.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Ok, Got to know that I need to export the material GUID's using 

engine.filesystem.saveGUIDs("<filename>");

and then do the search.

Just one request though. Please add a delimiter between guid and path, I wasted few hours to realize that I am copying my drive initial along with the hash.

Edited by Priyank.Jain2
Link to comment

Hi Priyank,

I haven't realized that all of your materials are manual.

22 hours ago, Priyank.Jain2 said:

Is there any way I can generate guid?

Please check this function, could it be helpful? More on UGUID class could be found here.

void generate(const char * str)

I'd like to mention that guids for manual materials are dependant on name, so in case you rename your manual material guid also will be changed.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
  • 6 months later...
Quote

BUT, I've found a bug. parent_name="<name>" doesn't work for now. I've reported this issue in our tracker.

Any update on this issue? Is this fixed?

 

 

Link to comment
  • silent changed the title to [SOLVED] Problem in assigning manual material to a surface
×
×
  • Create New...