Skip to content

Commit

Permalink
Merge branch 'gz-rendering9' into glb_normal_map
Browse files Browse the repository at this point in the history
  • Loading branch information
iche033 committed Sep 19, 2024
2 parents b470095 + c0e7c30 commit 78adf63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ogre2/src/Ogre2Material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -774,17 +774,22 @@ void Ogre2Material::SetLightMap(const std::string &_name,
this->dataPtr->lightMapData = _img;
this->lightMapUvSet = _uvSet;

// Apply lightmap by using the detail map slot to store the lightmap texture
// and blending it with the diffuse map.
Ogre::PbsTextureTypes type = Ogre::PBSM_DETAIL0;
this->ogreDatablock->setDetailMapBlendMode(0, Ogre::PBSM_BLEND_OVERLAY);
// in gz-rendering5 + ogre 2.1, we reserved detail map 0 for light map
// and set a blend mode (PBSM_BLEND_OVERLAY AND PBSM_BLEND_MULTIPLY2X
// produces better results) to blend with base albedo map. However, this
// creates unwanted red highlights with ogre 2.2. So switching to use the
// emissive map slot and calling setUseEmissiveAsLightmap(true)
// Ogre::PbsTextureTypes type = Ogre::PBSM_DETAIL0;
// this->ogreDatablock->setDetailMapBlendMode(0, Ogre::PBSM_BLEND_OVERLAY);
Ogre::PbsTextureTypes type = Ogre::PBSM_EMISSIVE;

// lightmap usually uses a different tex coord set
if (_img == nullptr)
this->SetTextureMapImpl(this->lightMapName, type);
else
this->SetTextureMapDataImpl(this->lightMapName, _img, type);
this->ogreDatablock->setTextureUvSource(type, this->lightMapUvSet);
this->ogreDatablock->setUseEmissiveAsLightmap(true);
}

//////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions tutorials/21_render_order.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@ make
Execute the example:

```{.sh}
# Linux (defaults to using ogre1)
./simple_demo
# macOS (ogre1 is not supported on macOS, but ogre2 is)
./simple_demo ogre2
```

0 comments on commit 78adf63

Please sign in to comment.