godotengine / godot

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

Gridmap + BakedLightmap produces huge scene files #41009

Open Wavesonics opened 4 years ago

Wavesonics commented 4 years ago

Godot version: 3.2.2

OS/device including version: Windows 10 x64

Issue description: When you use a BakedLightmap in conjunction with a Gridmap, a huge amount of data is added to the scene in the form of baked_meshes

Such as:

[node name="GroundGridmap" parent="." index="10"]
baked_meshes = [ SubResource( 536 ), SubResource( 537 ), SubResource( 538 ), SubResource( 539 ), SubResource( 540 ), SubResource( 541 ), SubResource( 542 ), SubResource( 543 ), SubResource( 544 ), SubResource( 545 ), SubResource( 546 ), SubResource( 547 ), SubResource( 548 ), SubResource( 549 ), SubResource( 550 ), SubResource( 551 ), SubResource( 552 ), SubResource( 553 ) ]
[sub_resource type="ArrayMesh" id=561]
lightmap_size_hint = Vector2( 328, 328 )
surfaces/0 = {
"aabb": AABB( 62.0751, -0.018673, -268.127, 1.99954, 2.09549, 1.7879 ),
"array_data": PoolByteArray( ... )
"blend_shape_data": [  ],
"format": 97591,
"index_count": 696,
"material": ExtResource( 17 ),
"primitive": 4,
"skeleton_aabb": [  ],
"vertex_count": 242
}

As TSCN this can add hundreds of MB to the file. Even when saved as a binary SCN these files are still dozens of MB for larger gridmaps.

Additionally, if the BakedLightmap node is removed from the scene, these baked_mesh resources don't get removed, so the scene file will never go back down in size.

Steps to reproduce: Add a Gridmap node to a scene, place tons of tiles down. Note that the scene is still quite small. Add a BakedLightmap node to the scene that covers the whole gridmap, and bake the light map. Now note that the scene file size has ballooned to many MB.

Finally delete the BakedLightmap and note that the size does not go back down again.

Minimal reproduction project: Having trouble setting this up as the assets I have to work with keep crashing the 3.2.2 light mapper.

Wavesonics commented 4 years ago

Talking with @reduz there likely isn't a way to do away with the unique UV meshes here.

So the next best option maybe be to provide an option in Gridmap to store the baked meshes in a separate binary file, such like how BakedLightmap allows you to save it's data in a separate file.