diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index 3b62fcb28..29a089db4 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -315,12 +315,25 @@ void Ogre2LaserRetroMaterialSwitcher::passPreExecute( // to keep vertex deformation consistent; so we use // a cloned material with a different pixel shader // https://github.com/ignitionrobotics/ign-rendering/issues/544 + // + // material may be a nullptr if we called setMaterial directly + // (i.e. it's not using Ogre2Material interface). + // In those cases we fallback to PBS in the current IORM mode. auto material = Ogre::MaterialManager::getSingleton().getByName( subItem->getMaterial()->getName() + "_solid", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); - if (material->getNumSupportedTechniques() > 0u) + if (material) { - subItem->setMaterial(material); + if (material->getLoadingState() == Ogre::Resource::LOADSTATE_UNLOADED) + { + // Manually defined materials like PointCloudPoint_solid need this + material->load(); + } + + if (material->getNumSupportedTechniques() > 0u) + { + subItem->setMaterial(material); + } } else { diff --git a/ogre2/src/Ogre2MaterialSwitcher.cc b/ogre2/src/Ogre2MaterialSwitcher.cc index bcf9bf123..d3e3a35f8 100644 --- a/ogre2/src/Ogre2MaterialSwitcher.cc +++ b/ogre2/src/Ogre2MaterialSwitcher.cc @@ -103,12 +103,25 @@ void Ogre2MaterialSwitcher::cameraPreRenderScene( // to keep vertex deformation consistent; so we use // a cloned material with a different pixel shader // https://github.com/ignitionrobotics/ign-rendering/issues/544 + // + // material may be a nullptr if we called setMaterial directly + // (i.e. it's not using Ogre2Material interface). + // In those cases we fallback to PBS in the current IORM mode. auto material = Ogre::MaterialManager::getSingleton().getByName( subItem->getMaterial()->getName() + "_solid", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); - if (material->getNumSupportedTechniques() > 0u) + if (material) { - subItem->setMaterial(material); + if (material->getLoadingState() == Ogre::Resource::LOADSTATE_UNLOADED) + { + // Manually defined materials like PointCloudPoint_solid need this + material->load(); + } + + if (material->getNumSupportedTechniques() > 0u) + { + subItem->setMaterial(material); + } } else { diff --git a/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc b/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc index c61510634..0a541ae45 100644 --- a/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc +++ b/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc @@ -307,12 +307,26 @@ void Ogre2SegmentationMaterialSwitcher::cameraPreRenderScene( // to keep vertex deformation consistent; so we use // a cloned material with a different pixel shader // https://github.com/ignitionrobotics/ign-rendering/issues/544 + // + // material may be a nullptr if we called setMaterial directly + // (i.e. it's not using Ogre2Material interface). + // In those cases we fallback to PBS in the current IORM mode. auto material = Ogre::MaterialManager::getSingleton().getByName( subItem->getMaterial()->getName() + "_solid", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); - if (material->getNumSupportedTechniques() > 0u) + if (material) { - subItem->setMaterial(material); + if (material->getLoadingState() == + Ogre::Resource::LOADSTATE_UNLOADED) + { + // Manually defined materials like PointCloudPoint_solid need this + material->load(); + } + + if (material->getNumSupportedTechniques() > 0u) + { + subItem->setMaterial(material); + } } else { diff --git a/ogre2/src/Ogre2ThermalCamera.cc b/ogre2/src/Ogre2ThermalCamera.cc index 48ebf6e3d..ba7913699 100644 --- a/ogre2/src/Ogre2ThermalCamera.cc +++ b/ogre2/src/Ogre2ThermalCamera.cc @@ -346,12 +346,27 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene( // to keep vertex deformation consistent; so we use // a cloned material with a different pixel shader // https://github.com/ignitionrobotics/ign-rendering/issues/544 + // + // material may be a nullptr if we called setMaterial directly + // (i.e. it's not using Ogre2Material interface). + // In those cases we fallback to PBS in the current IORM mode. auto material = Ogre::MaterialManager::getSingleton().getByName( subItem->getMaterial()->getName() + "_solid", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); - if (material->getNumSupportedTechniques() > 0u) + if (material) { - subItem->setMaterial(material); + if (material->getLoadingState() == + Ogre::Resource::LOADSTATE_UNLOADED) + { + // Manually defined materials like PointCloudPoint_solid + // need this + material->load(); + } + + if (material->getNumSupportedTechniques() > 0u) + { + subItem->setMaterial(material); + } } else { @@ -494,12 +509,27 @@ void Ogre2ThermalCameraMaterialSwitcher::cameraPreRenderScene( // to keep vertex deformation consistent; so we use // a cloned material with a different pixel shader // https://github.com/ignitionrobotics/ign-rendering/issues/544 + // + // material may be a nullptr if we called setMaterial directly + // (i.e. it's not using Ogre2Material interface). + // In those cases we fallback to PBS in the current IORM mode. auto material = Ogre::MaterialManager::getSingleton().getByName( subItem->getMaterial()->getName() + "_solid", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); - if (material->getNumSupportedTechniques() > 0u) + if (material) { - subItem->setMaterial(material); + if (material->getLoadingState() == + Ogre::Resource::LOADSTATE_UNLOADED) + { + // Manually defined materials like PointCloudPoint_solid + // need this + material->load(); + } + + if (material->getNumSupportedTechniques() > 0u) + { + subItem->setMaterial(material); + } } else { diff --git a/ogre2/src/media/materials/programs/GLSL/point_vs.glsl b/ogre2/src/media/materials/programs/GLSL/point_vs.glsl index bb100cac2..a299834c3 100644 --- a/ogre2/src/media/materials/programs/GLSL/point_vs.glsl +++ b/ogre2/src/media/materials/programs/GLSL/point_vs.glsl @@ -26,6 +26,7 @@ out vec3 ptColor; out gl_PerVertex { vec4 gl_Position; + float gl_PointSize; }; void main() diff --git a/ogre2/src/media/materials/scripts/picker.material b/ogre2/src/media/materials/scripts/picker.material index a849b51b0..44cc1ef81 100644 --- a/ogre2/src/media/materials/scripts/picker.material +++ b/ogre2/src/media/materials/scripts/picker.material @@ -12,16 +12,6 @@ vertex_program plaincolor_vs_GLSL glsl } } -fragment_program plaincolor_fs_GLSL glsl -{ - source plain_color_fs.glsl - - default_params - { - param_named inColor float4 1 1 1 1 - } -} - // Metal shaders vertex_program plaincolor_vs_Metal metal { @@ -36,12 +26,6 @@ vertex_program plaincolor_vs_Metal metal } } -fragment_program plaincolor_fs_Metal metal -{ - source plain_color_fs.metal - shader_reflection_pair_hint plaincolor_vs_Metal -} - // Unified shaders vertex_program plaincolor_vs unified { @@ -49,12 +33,6 @@ vertex_program plaincolor_vs unified delegate plaincolor_vs_Metal } -fragment_program plaincolor_fs unified -{ - delegate plaincolor_fs_GLSL - delegate plaincolor_fs_Metal -} - material ign-rendering/plain_color { // Material has one technique diff --git a/ogre2/src/media/materials/scripts/picker.program b/ogre2/src/media/materials/scripts/picker.program new file mode 100644 index 000000000..e0e033ec2 --- /dev/null +++ b/ogre2/src/media/materials/scripts/picker.program @@ -0,0 +1,24 @@ +// GLSL shaders +fragment_program plaincolor_fs_GLSL glsl +{ + source plain_color_fs.glsl + + default_params + { + param_named inColor float4 1 1 1 1 + } +} + +// Metal shaders +fragment_program plaincolor_fs_Metal metal +{ + source plain_color_fs.metal + shader_reflection_pair_hint plaincolor_vs_Metal +} + +// Unified shaders +fragment_program plaincolor_fs unified +{ + delegate plaincolor_fs_GLSL + delegate plaincolor_fs_Metal +} diff --git a/ogre2/src/media/materials/scripts/point_cloud_point.material b/ogre2/src/media/materials/scripts/point_cloud_point.material index 429968728..0dc1982f1 100644 --- a/ogre2/src/media/materials/scripts/point_cloud_point.material +++ b/ogre2/src/media/materials/scripts/point_cloud_point.material @@ -79,3 +79,21 @@ material PointCloudPoint } } } + +// For sensors +material PointCloudPoint_solid +{ + technique + { + pass + { + point_size_attenuation on + point_sprites on + vertex_program_ref PointCloudVS {} + fragment_program_ref plaincolor_fs + { + param_named_auto inColor custom 1 + } + } + } +}