Use RGB8 for segmentation colors.
PiperOrigin-RevId: 916061579 Change-Id: I0c1270cb71a9a4476a54b3bf6049981ed30f229f
This commit is contained in:
committed by
Copybara-Service
parent
a03191b9e8
commit
d5872acec8
@@ -226,13 +226,9 @@ static void UpdateGeomMaterial(mjrRenderable* renderable, const mjvGeom& geom,
|
|||||||
const double sample = std::fmod(0.5 + coef1 * index, 1.0);
|
const double sample = std::fmod(0.5 + coef1 * index, 1.0);
|
||||||
segmentation_color = 0x01000000 * sample;
|
segmentation_color = 0x01000000 * sample;
|
||||||
}
|
}
|
||||||
|
material.segmentation_color[0] = (segmentation_color >> 0);
|
||||||
const uint8_t red = (segmentation_color >> 0) & 0xff;
|
material.segmentation_color[1] = (segmentation_color >> 8);
|
||||||
const uint8_t green = (segmentation_color >> 8) & 0xff;
|
material.segmentation_color[2] = (segmentation_color >> 16);
|
||||||
const uint8_t blue = (segmentation_color >> 16) & 0xff;
|
|
||||||
material.segmentation_color[0] = static_cast<float>(red) / 255.0f;
|
|
||||||
material.segmentation_color[1] = static_cast<float>(green) / 255.0f;
|
|
||||||
material.segmentation_color[2] = static_cast<float>(blue) / 255.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UvScale only applies to objects that don't have explicit UV coordinates
|
// UvScale only applies to objects that don't have explicit UV coordinates
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <filament/MaterialInstance.h>
|
#include <filament/MaterialInstance.h>
|
||||||
#include <filament/RenderableManager.h>
|
#include <filament/RenderableManager.h>
|
||||||
#include <filament/TextureSampler.h>
|
#include <filament/TextureSampler.h>
|
||||||
|
#include <math/vec4.h>
|
||||||
#include <mujoco/mujoco.h>
|
#include <mujoco/mujoco.h>
|
||||||
#include "experimental/filament/filament_util.h"
|
#include "experimental/filament/filament_util.h"
|
||||||
#include "experimental/filament/filament/mesh.h"
|
#include "experimental/filament/filament/mesh.h"
|
||||||
@@ -105,8 +106,12 @@ void UpdateMaterialInstance(filament::MaterialInstance* instance,
|
|||||||
ReadFloat4(material.color));
|
ReadFloat4(material.color));
|
||||||
}
|
}
|
||||||
if (fmaterial->hasParameter("SegmentationColor")) {
|
if (fmaterial->hasParameter("SegmentationColor")) {
|
||||||
|
filament::math::float4 color{
|
||||||
|
static_cast<float>(material.segmentation_color[0]) / 255.0f,
|
||||||
|
static_cast<float>(material.segmentation_color[1]) / 255.0f,
|
||||||
|
static_cast<float>(material.segmentation_color[2]) / 255.0f, 1.0f};
|
||||||
instance->setParameter("SegmentationColor", filament::RgbaType::LINEAR,
|
instance->setParameter("SegmentationColor", filament::RgbaType::LINEAR,
|
||||||
ReadFloat4(material.segmentation_color));
|
color);
|
||||||
}
|
}
|
||||||
if (fmaterial->hasParameter("EmissiveFactor")) {
|
if (fmaterial->hasParameter("EmissiveFactor")) {
|
||||||
instance->setParameter("EmissiveFactor", material.emissive);
|
instance->setParameter("EmissiveFactor", material.emissive);
|
||||||
|
|||||||
@@ -97,8 +97,10 @@ void mjr_defaultLightParams(mjrLightParams* params) {
|
|||||||
void mjr_defaultMaterial(mjrMaterial* material) {
|
void mjr_defaultMaterial(mjrMaterial* material) {
|
||||||
memset(material, 0, sizeof(mjrMaterial));
|
memset(material, 0, sizeof(mjrMaterial));
|
||||||
setf(material->color, {1.f, 1.f, 1.f, 1.f});
|
setf(material->color, {1.f, 1.f, 1.f, 1.f});
|
||||||
setf(material->segmentation_color, {1, 1, 1, 1});
|
|
||||||
setf(material->uv_scale, {1, 1, 1});
|
setf(material->uv_scale, {1, 1, 1});
|
||||||
|
material->segmentation_color[0] = 255;
|
||||||
|
material->segmentation_color[1] = 255;
|
||||||
|
material->segmentation_color[2] = 255;
|
||||||
material->emissive = -1.0f;
|
material->emissive = -1.0f;
|
||||||
material->specular = -1.0f;
|
material->specular = -1.0f;
|
||||||
material->glossiness = -1.0f;
|
material->glossiness = -1.0f;
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ struct mjrMaterial {
|
|||||||
float color[4];
|
float color[4];
|
||||||
|
|
||||||
// The color to use for segmentation rendering. Defaults to white.
|
// The color to use for segmentation rendering. Defaults to white.
|
||||||
float segmentation_color[4];
|
mjtByte segmentation_color[3];
|
||||||
|
|
||||||
// Applies an addition scale to the UV coordinates of the object. Defaults to
|
// Applies an addition scale to the UV coordinates of the object. Defaults to
|
||||||
// (1, 1, 1).
|
// (1, 1, 1).
|
||||||
|
|||||||
Reference in New Issue
Block a user