Rename TextureTarget to SamplerType.
PiperOrigin-RevId: 911918372 Change-Id: If711d5909499b68316acd10a2de3a2d83436e18d
This commit is contained in:
committed by
Copybara-Service
parent
75f1b81df7
commit
364c716f08
@@ -84,7 +84,7 @@ uintptr_t ImguiBridge::UploadImage(uintptr_t tex_id, const uint8_t* pixels,
|
||||
mjr_defaultTextureConfig(&config);
|
||||
config.width = width;
|
||||
config.height = height;
|
||||
config.target = mjTEXTURE_2D;
|
||||
config.sampler_type = mjTEXTURE_2D;
|
||||
config.format = bpp == 4 ? mjPIXEL_FORMAT_RGBA8 : mjPIXEL_FORMAT_RGB8;
|
||||
config.color_space = mjCOLORSPACE_LINEAR;
|
||||
UniquePtr<mjrTexture> new_texture = ::mujoco::CreateTexture(ctx_, config);
|
||||
@@ -120,7 +120,7 @@ void ImguiBridge::CreateTexture(ImTextureData* data) {
|
||||
mjr_defaultTextureConfig(&config);
|
||||
config.width = data->Width;
|
||||
config.height = data->Height;
|
||||
config.target = mjTEXTURE_2D;
|
||||
config.sampler_type = mjTEXTURE_2D;
|
||||
config.format = mjPIXEL_FORMAT_RGBA8;
|
||||
config.color_space = mjCOLORSPACE_LINEAR;
|
||||
|
||||
|
||||
@@ -545,7 +545,7 @@ void ModelObjects::UploadTexture(const mjModel* model, int id) {
|
||||
mjr_defaultTextureConfig(&config);
|
||||
config.width = model->tex_width[id];
|
||||
config.height = model->tex_height[id];
|
||||
config.target = (mjtTexture)model->tex_type[id];
|
||||
config.sampler_type = (mjtTexture)model->tex_type[id];
|
||||
config.color_space = (mjtColorSpace)model->tex_colorspace[id];
|
||||
switch (model->tex_nchannel[id]) {
|
||||
case 1:
|
||||
|
||||
@@ -58,7 +58,7 @@ static UniquePtr<mjrTexture> CreateFallbackIndirectLightTexture(
|
||||
mjr_defaultTextureConfig(&config);
|
||||
config.width = 1;
|
||||
config.height = 1;
|
||||
config.target = mjTEXTURE_CUBE;
|
||||
config.sampler_type = mjTEXTURE_CUBE;
|
||||
config.format = mjPIXEL_FORMAT_KTX;
|
||||
config.color_space = mjCOLORSPACE_AUTO;
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ static void UpdateGeomMaterial(mjrRenderable* renderable, const mjvGeom& geom,
|
||||
// the programmatic UVs.
|
||||
|
||||
if (textures.color) {
|
||||
if (mjrf_getTextureTarget(textures.color) == mjTEXTURE_2D) {
|
||||
if (mjrf_getSamplerType(textures.color) == mjTEXTURE_2D) {
|
||||
// For 2D textures, `tex_repeat` specifies how many times the texture
|
||||
// image is repeated. The `tex_uniform` flag determines if the repetition
|
||||
// is applied at in object space (false) or in world space (true).
|
||||
|
||||
@@ -61,7 +61,7 @@ void RenderTarget::Prepare(int width, int height) {
|
||||
Texture::InternalFlags color_flags;
|
||||
color_config.width = width;
|
||||
color_config.height = height;
|
||||
color_config.target = mjTEXTURE_2D;
|
||||
color_config.sampler_type = mjTEXTURE_2D;
|
||||
color_config.format = config_.color_format;
|
||||
color_config.color_space = mjCOLORSPACE_LINEAR;
|
||||
color_config.format = mjPIXEL_FORMAT_RGB8;
|
||||
@@ -73,7 +73,7 @@ void RenderTarget::Prepare(int width, int height) {
|
||||
Texture::InternalFlags depth_flags;
|
||||
depth_config.width = width;
|
||||
depth_config.height = height;
|
||||
depth_config.target = mjTEXTURE_2D;
|
||||
depth_config.sampler_type = mjTEXTURE_2D;
|
||||
depth_config.format = config_.depth_format;
|
||||
depth_config.color_space = mjCOLORSPACE_LINEAR;
|
||||
depth_config.format = mjPIXEL_FORMAT_DEPTH32F;
|
||||
|
||||
@@ -386,7 +386,7 @@ ObjectManager::MaterialType Renderable::GetColorMaterialType() const {
|
||||
} else {
|
||||
return ObjectManager::kPhongColor;
|
||||
}
|
||||
} else if (color_texture->GetTarget() == mjTEXTURE_CUBE) {
|
||||
} else if (color_texture->GetSamplerType() == mjTEXTURE_CUBE) {
|
||||
if (material_params_.color[3] < 1.0f) {
|
||||
return ObjectManager::kPhongCubeFade;
|
||||
} else if (material_params_.reflective) {
|
||||
|
||||
@@ -35,7 +35,8 @@ static bool IsCompressed(const mjrTextureConfig& config) {
|
||||
}
|
||||
|
||||
static bool IsCubeMap(const mjrTextureConfig& config) {
|
||||
return config.target == mjTEXTURE_CUBE || config.target == mjTEXTURE_SKYBOX;
|
||||
return config.sampler_type == mjTEXTURE_CUBE ||
|
||||
config.sampler_type == mjTEXTURE_SKYBOX;
|
||||
}
|
||||
|
||||
static int GetFaceHeight(const mjrTextureConfig& config) {
|
||||
|
||||
@@ -52,7 +52,7 @@ class Texture : public mjrTexture {
|
||||
int GetHeight() const { return config_.height; }
|
||||
|
||||
// Returns the target of the texture.
|
||||
mjrTextureTarget GetTarget() const { return config_.target; }
|
||||
mjrSamplerType GetSamplerType() const { return config_.sampler_type; }
|
||||
|
||||
// Returns the underlying filament texture.
|
||||
filament::Texture* GetFilamentTexture() const { return texture_; }
|
||||
|
||||
@@ -221,8 +221,8 @@ int mjrf_getTextureHeight(const mjrTexture* texture) {
|
||||
return mujoco::Texture::downcast(texture)->GetHeight();
|
||||
}
|
||||
|
||||
mjrTextureTarget mjrf_getTextureTarget(const mjrTexture* texture) {
|
||||
return mujoco::Texture::downcast(texture)->GetTarget();
|
||||
mjrSamplerType mjrf_getSamplerType(const mjrTexture* texture) {
|
||||
return mujoco::Texture::downcast(texture)->GetSamplerType();
|
||||
}
|
||||
|
||||
void mjrf_setLightEnabled(mjrLight* light, bool enabled) {
|
||||
|
||||
@@ -119,7 +119,7 @@ typedef enum mjrGraphicsApi_ { // backend graphics API to use
|
||||
typedef std::uint64_t mjrFrameHandle;
|
||||
|
||||
// Bring some legacy mjt types into the mjr namespace.
|
||||
typedef mjtTexture mjrTextureTarget;
|
||||
typedef mjtTexture mjrSamplerType;
|
||||
typedef mjtColorSpace mjrColorSpace;
|
||||
typedef mjtLightType mjrLightType;
|
||||
typedef mjvGLCamera mjrCamera;
|
||||
@@ -191,7 +191,7 @@ struct mjrTextureConfig {
|
||||
int height;
|
||||
|
||||
// The target of the texture (e.g. 2D, cube, etc.)
|
||||
mjrTextureTarget target;
|
||||
mjrSamplerType sampler_type;
|
||||
|
||||
// The format of the pixels in the texture (e.g. RGB8, RGBA8, KTX, etc.)
|
||||
mjrPixelFormat format;
|
||||
@@ -486,8 +486,8 @@ int mjrf_getTextureWidth(const mjrTexture* texture);
|
||||
// Returns the height of the texture.
|
||||
int mjrf_getTextureHeight(const mjrTexture* texture);
|
||||
|
||||
// Returns the target type of the texture.
|
||||
mjrTextureTarget mjrf_getTextureTarget(const mjrTexture* texture);
|
||||
// Returns the sampler type of the texture.
|
||||
mjrSamplerType mjrf_getSamplerType(const mjrTexture* texture);
|
||||
|
||||
// Enables or disables the light.
|
||||
void mjrf_setLightEnabled(mjrLight* light, bool enabled);
|
||||
|
||||
Reference in New Issue
Block a user