diff --git a/examples/worlds/lightmap.sdf b/examples/worlds/lightmap.sdf new file mode 100644 index 0000000000..8686531441 --- /dev/null +++ b/examples/worlds/lightmap.sdf @@ -0,0 +1,94 @@ + + + + + + + 0.001 + 1.0 + + + 1.0 1.0 1.0 + 0.8 0.8 0.8 + false + + + + + + + + 3D View + false + docked + + + ogre2 + scene + 1.0 1.0 1.0 + 0.8 0.8 0.8 + -5.5 -2 0.5 0 0.0 0 + + + + + + World control + false + false + 72 + 121 + 1 + + floating + + + + + + + true + true + true + + + + + + + World stats + false + false + 110 + 290 + 1 + + floating + + + + + + + true + true + true + true + + + + + + true + Indoor Lightmap + 0 0 0 0 0 0 + https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Indoor Lightmap + + + + diff --git a/src/Conversions.cc b/src/Conversions.cc index d561eb0c2b..2b71b1d4a4 100644 --- a/src/Conversions.cc +++ b/src/Conversions.cc @@ -316,6 +316,9 @@ msgs::Material ignition::gazebo::convert(const sdf::Material &_in) asFullPath(workflow->EnvironmentMap(), _in.FilePath())); pbrMsg->set_emissive_map(workflow->EmissiveMap().empty() ? "" : asFullPath(workflow->EmissiveMap(), _in.FilePath())); + pbrMsg->set_light_map(workflow->LightMap().empty() ? "" : + asFullPath(workflow->LightMap(), _in.FilePath())); + pbrMsg->set_light_map_texcoord_set(workflow->LightMapTexCoordSet()); } } return out; @@ -363,6 +366,8 @@ sdf::Material ignition::gazebo::convert(const msgs::Material &_in) workflow.SetEnvironmentMap(pbrMsg.environment_map()); workflow.SetAmbientOcclusionMap(pbrMsg.ambient_occlusion_map()); workflow.SetEmissiveMap(pbrMsg.emissive_map()); + workflow.SetLightMap(pbrMsg.light_map(), pbrMsg.light_map_texcoord_set()); + pbr.SetWorkflow(workflow.Type(), workflow); out.SetPbrMaterial(pbr); } diff --git a/src/Conversions_TEST.cc b/src/Conversions_TEST.cc index 6539d5fc73..79ad52a875 100644 --- a/src/Conversions_TEST.cc +++ b/src/Conversions_TEST.cc @@ -222,6 +222,7 @@ TEST(Conversions, Material) workflow.SetEmissiveMap("emissive_map.png"); workflow.SetGlossinessMap("dummy_glossiness_map.png"); workflow.SetSpecularMap("dummy_specular_map.png"); + workflow.SetLightMap("light_map.png", 1u); workflow.SetMetalness(0.3); workflow.SetRoughness(0.9); workflow.SetGlossiness(0.1); @@ -257,6 +258,9 @@ TEST(Conversions, Material) EXPECT_EQ("ambient_occlusion_map.png", pbrMsg.ambient_occlusion_map()); EXPECT_EQ("dummy_glossiness_map.png", pbrMsg.glossiness_map()); EXPECT_EQ("dummy_specular_map.png", pbrMsg.specular_map()); + EXPECT_EQ("light_map.png", pbrMsg.light_map()); + EXPECT_EQ(1u, pbrMsg.light_map_texcoord_set()); + EXPECT_DOUBLE_EQ(0.3, pbrMsg.metalness()); EXPECT_DOUBLE_EQ(0.9, pbrMsg.roughness()); EXPECT_DOUBLE_EQ(0.1, pbrMsg.glossiness()); @@ -284,6 +288,8 @@ TEST(Conversions, Material) EXPECT_EQ("ambient_occlusion_map.png", newWorkflow->AmbientOcclusionMap()); EXPECT_EQ("dummy_glossiness_map.png", newWorkflow->GlossinessMap()); EXPECT_EQ("dummy_specular_map.png", newWorkflow->SpecularMap()); + EXPECT_EQ("light_map.png", newWorkflow->LightMap()); + EXPECT_EQ(1u, newWorkflow->LightMapTexCoordSet()); EXPECT_DOUBLE_EQ(0.3, newWorkflow->Metalness()); EXPECT_DOUBLE_EQ(0.9, newWorkflow->Roughness()); EXPECT_DOUBLE_EQ(0.1, newWorkflow->Glossiness()); diff --git a/src/rendering/SceneManager.cc b/src/rendering/SceneManager.cc index 6aa73f780f..e8f0c1a0f8 100644 --- a/src/rendering/SceneManager.cc +++ b/src/rendering/SceneManager.cc @@ -538,6 +538,23 @@ rendering::MaterialPtr SceneManager::LoadMaterial( else ignerr << "Unable to find file [" << emissiveMap << "]\n"; } + + // light map + std::string lightMap = workflow->LightMap(); + if (!lightMap.empty()) + { + std::string fullPath = common::findFile( + asFullPath(lightMap, _material.FilePath())); + if (!fullPath.empty()) + { + unsigned int uvSet = workflow->LightMapTexCoordSet(); + material->SetLightMap(fullPath, uvSet); + } + else + { + ignerr << "Unable to find file [" << lightMap << "]\n"; + } + } } return material; }