Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 9 -> main #1077

Merged
merged 20 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f8f631a
Update badges to point to gz-rendering9 branch (#1044)
iche033 Aug 25, 2024
77ef27d
Prepare for gz-rendering9.0.0~pre1 release (#1045)
iche033 Aug 28, 2024
22e05d5
Prepare for gz-rendering9.0.0~pre2 release (#1046)
iche033 Aug 29, 2024
6136735
Fix readme issues (#1051)
avanmalleghem Sep 2, 2024
3ba2f1e
Add Github Action for Windows and fix build (#1049)
azeey Sep 3, 2024
6ec0c52
Fix using lightmap and emissive map together (#1047)
iche033 Sep 5, 2024
12b6a15
Use gz-rendering9 in links and lux_core_engine example (#1053)
caguero Sep 6, 2024
3ee62e1
fix prerequisites (#1054)
avanmalleghem Sep 9, 2024
03060ba
Fix install tutorial (#1055)
avanmalleghem Sep 13, 2024
9c9934f
examples/heightmap: Fixed Windows build (#1062)
peci1 Sep 16, 2024
ca37cf0
18_simple_demo_tutorial: Add Windows instructions (#1061)
peci1 Sep 16, 2024
6cf203d
Update homebrew install instruction (#1064)
iche033 Sep 16, 2024
21993f0
examples/depth_camera: Fixed windows usage (#1060)
peci1 Sep 16, 2024
8e42985
Revert "Fix using lightmap and emissive map together (#1047)"
iche033 Sep 17, 2024
8835b39
Add macOS instructions for render_order tutorial (#1069)
athenaz2 Sep 18, 2024
c0e7c30
Merge pull request #1067 from gazebosim/revert_lightmap
iche033 Sep 18, 2024
7ef4528
Update code for loading normal and albedo maps from image data (#1068)
iche033 Sep 23, 2024
cd1d3f8
Prepare for 9.0.0 (#1070)
iche033 Sep 26, 2024
a9af984
Fix installation with GZ_ENABLE_RELOCATABLE_INSTALL=ON (#1071)
traversaro Sep 30, 2024
efb4bf5
update readme
iche033 Oct 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Windows
on:
pull_request:

jobs:
build:
name: Window CI
env:
PACKAGE: gz-rendering9
runs-on: windows-latest
steps:
- name: setup-pixi
uses: prefix-dev/[email protected]
with:
run-install: false

- name: Install build tools
run: |
pixi init
pixi add vcstool colcon-common-extensions pkgconfig
- name: Setup pixi env variables
shell: bash
run: |
eval "$(pixi shell-hook)"
echo CMAKE_PREFIX_PATH=$CONDA_PREFIX/Library >> $GITHUB_ENV
- name: Install base dependencies
run: |
# List adapted from https:/gazebo-tooling/release-tools/blob/f89ac8cafc646260598eb8eb6d94be8093bdc9f7/jenkins-scripts/lib/windows_env_vars.bat#L22
pixi add assimp dlfcn-win32 eigen ffmpeg freeimage gdal gflags ogre ogre-next spdlog tinyxml2
- name: Clone source dependencies
run: |
mkdir src
cd src
pixi run vcs import --input https://raw.githubusercontent.com/gazebo-tooling/gazebodistro/master/${env:PACKAGE}.yaml

- uses: actions/checkout@v4
with:
path: src/gz-rendering

- name: Build Dependencies
run: |
pixi run colcon build --merge-install --cmake-args -G"Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF --event-handlers console_direct+ --packages-up-to ${env:PACKAGE}

- name: Build Package
run: pixi run colcon build --merge-install --cmake-args -G"Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DSKIP_ogre=ON --event-handlers console_direct+ --packages-select ${env:PACKAGE}

- name: Test
run: pixi run colcon test --merge-install --event-handlers console_direct+ --packages-select ${env:PACKAGE}
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ set(GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR
set(GZ_RENDERING_ENGINE_INSTALL_DIR
${CMAKE_INSTALL_PREFIX}/${GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR})

#--------------------------------------
# Find DL if doing relocatable installation
if (GZ_ENABLE_RELOCATABLE_INSTALL)
gz_find_package(DL REQUIRED)
endif()

#--------------------------------------
# Find dependencies that we ignore for Visual Studio
Expand Down
31 changes: 30 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,36 @@

### Gazebo Rendering 9.X

### Gazebo Rendering 9.0.0 (2024-09-XX)
### Gazebo Rendering 9.0.0 (2024-09-25)

1. **Baseline:** this includes all changes from 8.2.0 and earlier.

1. Update code for loading normal and albedo maps from image data
* [Pull request #1068](https:/gazebosim/gz-rendering/pull/1068)

1. examples/depth_camera: Fixed windows usage
* [Pull request #1060](https:/gazebosim/gz-rendering/pull/1060)

1. examples/heightmap: Fixed Windows build
* [Pull request #1062](https:/gazebosim/gz-rendering/pull/1062)

1. Add Github Action for Windows and fix build
* [Pull request #1049](https:/gazebosim/gz-rendering/pull/1049)

1. Miscellaneous documentation fixes
* [Pull request #1051](https:/gazebosim/gz-rendering/pull/1051)
* [Pull request #1053](https:/gazebosim/gz-rendering/pull/1053)
* [Pull request #1054](https:/gazebosim/gz-rendering/pull/1054)
* [Pull request #1055](https:/gazebosim/gz-rendering/pull/1055)
* [Pull request #1061](https:/gazebosim/gz-rendering/pull/1061)
* [Pull request #1064](https:/gazebosim/gz-rendering/pull/1064)
* [Pull request #1069](https:/gazebosim/gz-rendering/pull/1069)

1. Update badges to point to gz-rendering9 branch
* [Pull request #1044](https:/gazebosim/gz-rendering/pull/1044)

1. Ionic Changelog
* [Pull request #1042](https:/gazebosim/gz-rendering/pull/1042)

1. Remove gl preference in cmake
* [Pull request #1041](https:/gazebosim/gz-rendering/pull/1041)
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

Build | Status
-- | --
Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/branch/main/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/branch/main)
Ubuntu Noble | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-noble-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-noble-amd64)
Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-main-homebrew-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-main-homebrew-amd64)
Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-main-win)](https://build.osrfoundation.org/job/gz_rendering-main-win)
Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-rendering/tree/gz-rendering9/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-rendering/tree/gz-rendering9)
Ubuntu Noble | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-gz-rendering9-noble-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-gz-rendering9-noble-amd64)
Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-ci-gz-rendering9-homebrew-amd64)](https://build.osrfoundation.org/job/gz_rendering-ci-gz-rendering9-homebrew-amd64)
Windows | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_rendering-9-win)](https://build.osrfoundation.org/job/gz_rendering-9-win)

Gazebo Rendering is a C++ library designed to provide an abstraction
for different rendering engines. It offers unified APIs for creating
Expand All @@ -31,9 +31,9 @@ of libraries designed to rapidly develop robot applications.

[Folder Structure](#folder-structure)

[Code of Conduct](#code-of-conduct)
[Contributing](#contributing)

[Contributing](#code-of-contributing)
[Code of Conduct](#code-of-conduct)

[Versioning](#versioning)

Expand Down Expand Up @@ -80,8 +80,8 @@ Rendering engine plugin implementation code is stored in their own folders

# Contributing

Please see
[CONTRIBUTING.md](https://gazebosim.org/docs/all/contributing).
Please see the
[contribution guide](https://gazebosim.org/docs/all/contributing).

# Code of Conduct

Expand Down
4 changes: 3 additions & 1 deletion examples/depth_camera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ if (NOT APPLE)
link_directories(${GLEW_LIBRARY_DIRS})
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif()

configure_file (example_config.hh.in ${PROJECT_BINARY_DIR}/example_config.hh)

Expand Down
5 changes: 5 additions & 0 deletions examples/depth_camera/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@
using namespace gz;
using namespace rendering;

#if not defined(_WIN32)
const std::string RESOURCE_PATH =
common::joinPaths(std::string(PROJECT_BINARY_PATH), "media");
#else
const std::string RESOURCE_PATH =
common::joinPaths(std::string(PROJECT_BINARY_PATH), "..", "media");
#endif

void buildScene(ScenePtr _scene)
{
Expand Down
4 changes: 3 additions & 1 deletion examples/heightmap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ if (NOT APPLE)
link_directories(${GLEW_LIBRARY_DIRS})
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif()

configure_file (example_config.hh.in ${PROJECT_BINARY_DIR}/example_config.hh)

Expand Down
7 changes: 7 additions & 0 deletions examples/heightmap/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glut.h>
#else
#include <GL/glut.h>
#endif

#include <iostream>
Expand All @@ -39,8 +41,13 @@
using namespace gz;
using namespace rendering;

#if not defined(_WIN32)
const std::string RESOURCE_PATH =
common::joinPaths(std::string(PROJECT_BINARY_PATH), "media");
#else
const std::string RESOURCE_PATH =
common::joinPaths(std::string(PROJECT_BINARY_PATH), "..", "media");
#endif

//////////////////////////////////////////////////
void createImageHeightmaps(const ScenePtr _scene, VisualPtr _root)
Expand Down
2 changes: 1 addition & 1 deletion examples/lux_core_engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
set(GZ_PLUGIN_VER 2)
set(GZ_COMMON_VER 5)

find_package(gz-rendering7 REQUIRED)
find_package(gz-rendering9 REQUIRED)
find_package(gz-plugin3 REQUIRED COMPONENTS all)

if (NOT DEFINED ENV{LUXCORE_SDK_PATH})
Expand Down
135 changes: 131 additions & 4 deletions ogre2/src/Ogre2Material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
*/

#include <cstddef>

// Note this include is placed in the src file because
// otherwise ogre produces compile errors
#ifdef _MSC_VER
Expand All @@ -31,6 +33,8 @@
#include <OgreMaterialManager.h>
#include <OgrePixelFormatGpuUtils.h>
#include <OgreTechnique.h>
#include <OgreTextureBox.h>
#include <OgreTextureFilters.h>
#include <OgreTextureGpuManager.h>
#include <Vao/OgreVaoManager.h>
#ifdef _MSC_VER
Expand Down Expand Up @@ -130,6 +134,23 @@ class gz::rendering::Ogre2MaterialPrivate
return "invalid";
}
}

/// \brief Prepare for normal mapping by converting to two-component
/// normalized signed 8-bit format
/// \param[in] _texture Normal map texture
/// \param[in/out] _image Normal map image data
public: void PrepareForNormalMapping(Ogre::TextureGpu *_texture,
Ogre::Image2 &_image);

/// \brief Allocate mimaps for the texture. This should be done when the
/// texture's residency status is still OnStorage.
/// \param[in] _texture Input texture to allocate mimaps
public: void AllocateMipmaps(Ogre::TextureGpu *_texture);

/// \brief Generate mimaps for the texture. This should be done when the
/// texture's residency status is Resident.
/// \param[in] _texture Input texture to generate mimpas
public: void GenerateMipmaps(Ogre::TextureGpu *_texture);
};

using namespace gz;
Expand Down Expand Up @@ -1220,6 +1241,8 @@ void Ogre2Material::SetTextureMapDataImpl(const std::string& _name,
root->getRenderSystem()->getTextureGpuManager();

// create the gpu texture
Ogre::uint32 filters = Ogre::TextureFilter::TypeGenerateDefaultMipmaps;
filters |= this->ogreDatablock->suggestFiltersForType(_type);
Ogre::uint32 textureFlags = 0;
textureFlags |= Ogre::TextureFlags::AutomaticBatching;
Ogre::TextureGpu *texture = textureMgr->createOrRetrieveTexture(
Expand All @@ -1228,7 +1251,7 @@ void Ogre2Material::SetTextureMapDataImpl(const std::string& _name,
textureFlags | Ogre::TextureFlags::ManualTexture,
Ogre::TextureTypes::Type2D,
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
0u);
filters);

// Has to be loaded
if (texture->getWidth() == 0)
Expand All @@ -1241,13 +1264,31 @@ void Ogre2Material::SetTextureMapDataImpl(const std::string& _name,
texture->setTextureType(Ogre::TextureTypes::Type2D);
texture->setNumMipmaps(1u);
texture->setResolution(_img->Width(), _img->Height());
texture->scheduleTransitionTo(Ogre::GpuResidency::Resident);
texture->waitForData();

// upload raw color image data to gpu texture
Ogre::Image2 img;
img.loadDynamicImage(&data[0], false, texture);

// Replicates the steps that ogre does when it loads a texture map from
// file. For normal maps, it is first converted to a two component signed
// 8 bit format. Albedo and normal maps will have mipmaps generated.
// \todo(iche033) See if there is a way to reuse these functions
// from ogre-next without copying the code here.

// Normal maps - convert to two component signed 8 bit format:
// Ogre::PFG_RG8_SNORM format
if (_type == Ogre::PBSM_NORMAL)
this->dataPtr->PrepareForNormalMapping(texture, img);

if (_type == Ogre::PBSM_DIFFUSE || _type == Ogre::PBSM_NORMAL)
this->dataPtr->AllocateMipmaps(texture);

// Upload raw color image data to gpu texture
texture->scheduleTransitionTo(Ogre::GpuResidency::Resident);
texture->waitForData();
img.uploadTo(texture, 0, 0);

if (_type == Ogre::PBSM_DIFFUSE || _type == Ogre::PBSM_NORMAL)
this->dataPtr->GenerateMipmaps(texture);
}

// Now assign it to the material
Expand Down Expand Up @@ -1563,3 +1604,89 @@ ShaderParamsPtr Ogre2Material::FragmentShaderParams()
{
return this->dataPtr->fragmentShaderParams;
}

//////////////////////////////////////////////////
void Ogre2MaterialPrivate::PrepareForNormalMapping(Ogre::TextureGpu *_texture,
Ogre::Image2 &_image)
{
// code adpated from PrepareForNormalMapping::_executeStreaming function in
// OgreMain/src/OgreTextureFilters.cpp (v2-3)
const Ogre::uint8 numMipmaps = _image.getNumMipmaps();
const Ogre::PixelFormatGpu dstFormat = Ogre::PFG_RG8_SNORM;
const Ogre::uint32 rowAlignment = 4u;
const size_t dstSizeBytes = Ogre::PixelFormatGpuUtils::calculateSizeBytes(
_image.getWidth(),
_image.getHeight(),
_image.getDepth(),
_image.getNumSlices(),
dstFormat, numMipmaps,
rowAlignment );
void *imgData = OGRE_MALLOC_SIMD( dstSizeBytes, Ogre::MEMCATEGORY_RESOURCE);
for (Ogre::uint8 mip = 0; mip < numMipmaps; ++mip)
{
Ogre::TextureBox srcBox = _image.getData( mip );
const Ogre::uint32 width = srcBox.width;
const Ogre::uint32 height = srcBox.height;

Ogre::TextureBox dstBox = srcBox;
dstBox.bytesPerPixel =
Ogre::PixelFormatGpuUtils::getBytesPerPixel(dstFormat);
dstBox.bytesPerRow =
Ogre::PixelFormatGpuUtils::getSizeBytes(
width, 1u, 1u, 1u, dstFormat, 4u);
dstBox.bytesPerImage =
Ogre::PixelFormatGpuUtils::getSizeBytes(width, height, 1u, 1u,
dstFormat, 4u);
dstBox.data = Ogre::PixelFormatGpuUtils::advancePointerToMip(
imgData, width, height, srcBox.depth, srcBox.numSlices, mip, dstFormat);

Ogre::PixelFormatGpuUtils::convertForNormalMapping(
srcBox, _image.getPixelFormat(),
dstBox, dstFormat);
}
_image.loadDynamicImage(imgData, _image.getWidth(), _image.getHeight(),
_image.getDepthOrSlices(), _image.getTextureType(), dstFormat, false,
numMipmaps);
_texture->setPixelFormat(dstFormat);
}

//////////////////////////////////////////////////
void Ogre2MaterialPrivate::AllocateMipmaps(Ogre::TextureGpu *_texture)
{
// code adpated from GenerateHwMipmaps::_executeStreaming function in
// OgreMain/src/OgreTextureFilters.cpp (v2-3)
Ogre::uint8 maxMipmaps = Ogre::PixelFormatGpuUtils::getMaxMipmapCount(
_texture->getWidth(),
_texture->getHeight(),
_texture->getDepth() );
_texture->setNumMipmaps(maxMipmaps);
}

//////////////////////////////////////////////////
void Ogre2MaterialPrivate::GenerateMipmaps(Ogre::TextureGpu *_texture)
{
// code adpated from GenerateHwMipmaps::_executeSerial function in
// OgreMain/src/OgreTextureFilters.cpp (v2-3)
Ogre::TextureGpuManager *textureManager = _texture->getTextureManager();
Ogre::TextureGpu *tempTexture = textureManager->createTexture(
"___tempMipmapTexture",
Ogre::GpuPageOutStrategy::Discard,
Ogre::TextureFlags::RenderToTexture |
Ogre::TextureFlags::AllowAutomipmaps |
Ogre::TextureFlags::DiscardableContent,
_texture->getTextureType());
tempTexture->copyParametersFrom(_texture);
tempTexture->unsafeScheduleTransitionTo(Ogre::GpuResidency::Resident);
Ogre::TextureBox box = _texture->getEmptyBox(0);
_texture->copyTo(tempTexture, box, 0, box, 0);
tempTexture->_autogenerateMipmaps();

Ogre::uint8 mipmaps = _texture->getNumMipmaps();
for (size_t i = 1u; i < mipmaps; ++i)
{
box = _texture->getEmptyBox( i );
tempTexture->copyTo(_texture, box, i, box, i);
}
textureManager->destroyTexture(tempTexture);
tempTexture = 0;
}
Loading
Loading