Merge pull request #50150 from Valeryn4/3.x-fix_lightmap_cpu
This commit is contained in:
commit
6cff43e093
2 changed files with 11 additions and 4 deletions
|
@ -59,7 +59,7 @@ void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) {
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case BakedLightmap::BAKE_ERROR_NO_MESHES:
|
case BakedLightmap::BAKE_ERROR_NO_MESHES:
|
||||||
EditorNode::get_singleton()->show_warning(TTR("No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake Light' flag is on."));
|
EditorNode::get_singleton()->show_warning(TTR("No meshes to bake. Make sure they contain an UV2 channel and that the 'Use In Baked Light' and 'Generate Lightmap' flags are on."));
|
||||||
break;
|
break;
|
||||||
case BakedLightmap::BAKE_ERROR_CANT_CREATE_IMAGE:
|
case BakedLightmap::BAKE_ERROR_CANT_CREATE_IMAGE:
|
||||||
EditorNode::get_singleton()->show_warning(TTR("Failed creating lightmap images, make sure path is writable."));
|
EditorNode::get_singleton()->show_warning(TTR("Failed creating lightmap images, make sure path is writable."));
|
||||||
|
|
|
@ -1299,9 +1299,18 @@ LightmapperCPU::BakeError LightmapperCPU::bake(BakeQuality p_quality, bool p_use
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool has_baked_mesh = false;
|
||||||
for (unsigned int i = 0; i < mesh_instances.size(); i++) {
|
for (unsigned int i = 0; i < mesh_instances.size(); i++) {
|
||||||
|
if (mesh_instances[i].generate_lightmap) {
|
||||||
|
has_baked_mesh = true;
|
||||||
|
}
|
||||||
raycaster->add_mesh(mesh_instances[i].data.points, mesh_instances[i].data.normal, mesh_instances[i].data.uv2, i);
|
raycaster->add_mesh(mesh_instances[i].data.points, mesh_instances[i].data.normal, mesh_instances[i].data.uv2, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!has_baked_mesh) {
|
||||||
|
return BAKE_ERROR_NO_MESHES;
|
||||||
|
}
|
||||||
|
|
||||||
raycaster->commit();
|
raycaster->commit();
|
||||||
|
|
||||||
scene_lightmaps.resize(mesh_instances.size());
|
scene_lightmaps.resize(mesh_instances.size());
|
||||||
|
@ -1492,7 +1501,6 @@ LightmapperCPU::BakeError LightmapperCPU::bake(BakeQuality p_quality, bool p_use
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int j = 0;
|
|
||||||
for (unsigned int i = 0; i < mesh_instances.size(); i++) {
|
for (unsigned int i = 0; i < mesh_instances.size(); i++) {
|
||||||
if (!mesh_instances[i].generate_lightmap) {
|
if (!mesh_instances[i].generate_lightmap) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1501,9 +1509,8 @@ LightmapperCPU::BakeError LightmapperCPU::bake(BakeQuality p_quality, bool p_use
|
||||||
if (p_generate_atlas) {
|
if (p_generate_atlas) {
|
||||||
_blit_lightmap(lightmaps_data[i], mesh_instances[i].size, bake_textures[mesh_instances[i].slice], mesh_instances[i].offset.x, mesh_instances[i].offset.y, true);
|
_blit_lightmap(lightmaps_data[i], mesh_instances[i].size, bake_textures[mesh_instances[i].slice], mesh_instances[i].offset.x, mesh_instances[i].offset.y, true);
|
||||||
} else {
|
} else {
|
||||||
_blit_lightmap(lightmaps_data[i], mesh_instances[i].size, bake_textures[j], 0, 0, false);
|
_blit_lightmap(lightmaps_data[i], mesh_instances[i].size, bake_textures[i], 0, 0, false);
|
||||||
}
|
}
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue