Skip to content

Commit

Permalink
Add Lightmap to material (#132)
Browse files Browse the repository at this point in the history
* fix frame number in video encoding

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* encode duplicate frames to ensure continuous pts

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* fix resetting video recording

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* support multiple texcoord set

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* add tex coord set count

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* add lightmap to material

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* fixing load time

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* more fixes

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* fix codecheck

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

Co-authored-by: Louise Poubel <louise@openrobotics.org>
iche033 and chapulina authored Dec 21, 2020
1 parent 5712a55 commit 6b1d056
Showing 3 changed files with 58 additions and 0 deletions.
15 changes: 15 additions & 0 deletions graphics/include/ignition/common/Pbr.hh
Original file line number Diff line number Diff line change
@@ -166,6 +166,21 @@ namespace common
/// \param[in] _map Filename of the emissive map.
public: void SetEmissiveMap(const std::string &_map);

/// \brief Get the light map filename. This will be an empty string
/// if an light map has not been set.
/// \return Filename of the light map, or empty string if a light
/// map has not been specified.
public: std::string LightMap() const;

/// \brief Set the light map filename.
/// \param[in] _map Filename of the light map.
/// \param[in] _uvSet Index of the texture coordinate set
public: void SetLightMap(const std::string &_map, unsigned int _uvSet = 0u);

/// \brief Get the light map texture coordinate set.
/// \return Index of the light map texture coordinate set
public: unsigned int LightMapTexCoordSet() const;

/// \brief Get the metalness value of the material for metal workflow
/// \return metalness value of the material
public: double Metalness() const;
25 changes: 25 additions & 0 deletions graphics/src/Pbr.cc
Original file line number Diff line number Diff line change
@@ -50,6 +50,12 @@ class ignition::common::PbrPrivate
/// \brief Emissive map
public: std::string emissiveMap = "";

/// \brief Light map
public: std::string lightMap;

/// \brief Light map texture coordinate set
public: unsigned int lightMapUvSet = 0u;

/// \brief Roughness value (metal workflow only)
public: double roughness = 0.5;

@@ -293,6 +299,25 @@ void Pbr::SetEmissiveMap(const std::string &_map)
this->dataPtr->emissiveMap = _map;
}

//////////////////////////////////////////////////
std::string Pbr::LightMap() const
{
return this->dataPtr->lightMap;
}

//////////////////////////////////////////////////
void Pbr::SetLightMap(const std::string &_map, unsigned int _uvSet)
{
this->dataPtr->lightMap = _map;
this->dataPtr->lightMapUvSet = _uvSet;
}

//////////////////////////////////////////////////
unsigned int Pbr::LightMapTexCoordSet() const
{
return this->dataPtr->lightMapUvSet;
}

//////////////////////////////////////////////////
PbrType Pbr::Type() const
{
18 changes: 18 additions & 0 deletions graphics/src/Pbr_TEST.cc
Original file line number Diff line number Diff line change
@@ -32,6 +32,8 @@ TEST(Pbr, BasicAPI)
EXPECT_EQ(std::string(), pbr.RoughnessMap());
EXPECT_EQ(std::string(), pbr.MetalnessMap());
EXPECT_EQ(std::string(), pbr.EmissiveMap());
EXPECT_EQ(std::string(), pbr.LightMap());
EXPECT_EQ(0u, pbr.LightMapTexCoordSet());
EXPECT_DOUBLE_EQ(0.5, pbr.Roughness());
EXPECT_DOUBLE_EQ(0.0, pbr.Metalness());
EXPECT_EQ(std::string(), pbr.SpecularMap());
@@ -60,6 +62,10 @@ TEST(Pbr, BasicAPI)
pbr.SetEmissiveMap("metal_emissive_map.png");
EXPECT_EQ("metal_emissive_map.png", pbr.EmissiveMap());

pbr.SetLightMap("metal_light_map.png", 1u);
EXPECT_EQ("metal_light_map.png", pbr.LightMap());
EXPECT_EQ(1u, pbr.LightMapTexCoordSet());

pbr.SetRoughnessMap("roughness_map.png");
EXPECT_EQ("roughness_map.png", pbr.RoughnessMap());

@@ -89,6 +95,7 @@ TEST(Pbr, MoveCopy)
pbr.SetEnvironmentMap("specular_env_map.png");
pbr.SetAmbientOcclusionMap("specular_ambient_occlusion_map.png");
pbr.SetEmissiveMap("specular_emissive_map.png");
pbr.SetLightMap("specular_light_map.png", 2u);
pbr.SetGlossinessMap("glossiness_map.png");
pbr.SetSpecularMap("specular_map.png");
pbr.SetGlossiness(0.1);
@@ -102,6 +109,8 @@ TEST(Pbr, MoveCopy)
EXPECT_EQ("specular_ambient_occlusion_map.png",
pbr2.AmbientOcclusionMap());
EXPECT_EQ("specular_emissive_map.png", pbr2.EmissiveMap());
EXPECT_EQ("specular_light_map.png", pbr2.LightMap());
EXPECT_EQ(2u, pbr2.LightMapTexCoordSet());
EXPECT_EQ("specular_map.png", pbr2.SpecularMap());
EXPECT_EQ("glossiness_map.png", pbr2.GlossinessMap());
EXPECT_DOUBLE_EQ(0.1, pbr2.Glossiness());
@@ -122,6 +131,7 @@ TEST(Pbr, MoveCopy)
pbr.SetEnvironmentMap("metal_env_map.png");
pbr.SetAmbientOcclusionMap("metal_ambient_occlusion_map.png");
pbr.SetEmissiveMap("metal_emissive_map.png");
pbr.SetLightMap("metal_light_map.png", 3u);
pbr.SetRoughnessMap("roughness_map.png");
pbr.SetMetalnessMap("metalness_map.png");
pbr.SetRoughness(0.8);
@@ -136,6 +146,8 @@ TEST(Pbr, MoveCopy)
EXPECT_EQ("metal_ambient_occlusion_map.png",
pbr2.AmbientOcclusionMap());
EXPECT_EQ("metal_emissive_map.png", pbr2.EmissiveMap());
EXPECT_EQ("metal_light_map.png", pbr2.LightMap());
EXPECT_EQ(3u, pbr2.LightMapTexCoordSet());
EXPECT_EQ("roughness_map.png", pbr2.RoughnessMap());
EXPECT_EQ("metalness_map.png", pbr2.MetalnessMap());
EXPECT_DOUBLE_EQ(0.8, pbr2.Roughness());
@@ -156,6 +168,7 @@ TEST(Pbr, MoveCopy)
pbr.SetEnvironmentMap("metal_env_map.png");
pbr.SetAmbientOcclusionMap("metal_ambient_occlusion_map.png");
pbr.SetEmissiveMap("metal_emissive_map.png");
pbr.SetLightMap("metal_light_map.png", 1u);
pbr.SetRoughnessMap("roughness_map.png");
pbr.SetMetalnessMap("metalness_map.png");
pbr.SetRoughness(0.8);
@@ -171,6 +184,8 @@ TEST(Pbr, MoveCopy)
EXPECT_EQ("metal_ambient_occlusion_map.png",
pbr2.AmbientOcclusionMap());
EXPECT_EQ("metal_emissive_map.png", pbr2.EmissiveMap());
EXPECT_EQ("metal_light_map.png", pbr2.LightMap());
EXPECT_EQ(1u, pbr2.LightMapTexCoordSet());
EXPECT_EQ("roughness_map.png", pbr2.RoughnessMap());
EXPECT_EQ("metalness_map.png", pbr2.MetalnessMap());
EXPECT_DOUBLE_EQ(0.8, pbr2.Roughness());
@@ -191,6 +206,7 @@ TEST(Pbr, MoveCopy)
pbr.SetEnvironmentMap("metal_env_map.png");
pbr.SetAmbientOcclusionMap("metal_ambient_occlusion_map.png");
pbr.SetEmissiveMap("metal_emissive_map.png");
pbr.SetLightMap("metal_light_map.png", 2u);
pbr.SetRoughnessMap("roughness_map.png");
pbr.SetMetalnessMap("metalness_map.png");
pbr.SetRoughness(0.18);
@@ -205,6 +221,8 @@ TEST(Pbr, MoveCopy)
EXPECT_EQ("metal_ambient_occlusion_map.png",
pbr2.AmbientOcclusionMap());
EXPECT_EQ("metal_emissive_map.png", pbr2.EmissiveMap());
EXPECT_EQ("metal_light_map.png", pbr2.LightMap());
EXPECT_EQ(2u, pbr2.LightMapTexCoordSet());
EXPECT_EQ("roughness_map.png", pbr2.RoughnessMap());
EXPECT_EQ("metalness_map.png", pbr2.MetalnessMap());
EXPECT_DOUBLE_EQ(0.18, pbr2.Roughness());

0 comments on commit 6b1d056

Please sign in to comment.