godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.93k stars 21.06k forks source link

GridMap items' mesh material data lost after export #23104

Open saranvdev opened 5 years ago

saranvdev commented 5 years ago

Godot version: v3.1.alpha.calinou.4c1a5d9

OS/device including version: Arch Linux

Issue description: Exporting MeshLib doesn't work for item's material data.

I get this error when trying to export MeshLib: Resource was not pre cached for the resource section, bug?

and this one, however I don't remember when exactly: drivers/gles3/rasterizer_storage_gles3.cpp:1013 - Condition ' !texture->active ' is true. returned: Ref<Image>()

Perhaps tiles in a gridmap store SpatialMaterial data in a wrong place? Manually editing materials works fine. This is why I think so:

  1. I tried manually changing material data via MeshLib item properties in an inspector.
  2. It changed successfully, color was visible.
  3. After removing current MeshLib, exporting the new one and assigning it to a new GridMap node, item materials are lost as before, EXCEPT the ones that I modified using previous GridMap/MeshLib item properties: imgur-2018_10_18-09 27 45 These are just the same as previously.

Steps to reproduce:

  1. Create a MeshLib scene,
  2. Add MeshInstances with material data,
  3. Export,
  4. Assign MeshLib to a GridMap node,
  5. SpatialMaterials are lost

Edit: Materials edited via GridMap item properties disappear after the editor's restart.

neonsoup commented 5 years ago

This happens because mesh you edit is actually imported from file and not attached to the scene, so if you change its material it will not actually be saved. If you open the mesh resource in inspector by right clicking it on the screenshot you provided and chosing apropriate menu item, you will actually see the warning about that above the property list, which does not appear for nested resources. Would be good to see some kind of warning there, like an exclamation mark or red outline or both.

neonsoup commented 5 years ago

Ways to fix that are making the mesh resource local to scene or saving it in separate file along with material.

akien-mga commented 5 years ago

The workflow might have been improved in the master branch with #25522, could you test again?

Shadowblitz16 commented 3 years ago

This is still a issue in 3.2.3.

abgenullt commented 3 years ago

I'm just running into the same thing. I think the problem is, that the names of the grid map tiles are taken from the node name of the mesh instance. So, if you ceate an inherited scene for a tile variation, you can't change this name. This could cause a naming conflict for the mesh lib converter.

One solution could be, to create a special "GridMapTile" node type, the mesh lib converter can scan for and pick the names from. So, you can choose them yourself.

Another approach would be to let the user use multiple mesh libs in one grid map, like you would do in a 2d map. So, you can create multiple mesh libs for each variation.

tavurth commented 1 year ago

Ran into this issue now while attempting to export a GridMap that can be sent over the wire.

Godot v4.0.3.stable.official [5222a99f5]

I noticed that many areas of Resource saving are broken when it comes to GridMap, instead I will probably have to write my own custom Resource which bundles the textures 🤔

My main issue at the moment is that Texture2D is not included in the export.

As can be seen from this exported .tscn file the resource is set as local_to_scene and yet the texture is still imported from the Godot cache.

[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_lsyke"]
resource_local_to_scene = true
load_path = "res://.godot/imported/walls24.png-baee28b6d28cf1eb2ffaf0c01d63a387.ctex"
metadata/tag = "science"
metadata/type = 1

EDIT

This issue appears to be that Texture2D is not exportable to a .tres or .res file. Instead I will have to export the Image. I will open a new issue about this.