Skip to content

Commit

Permalink
Integrated sRGBTextures option directly into vsgXchange::assump optio…
Browse files Browse the repository at this point in the history
…ns support in a standard way.
  • Loading branch information
robertosfield committed Jan 3, 2024
1 parent 1105883 commit ad24499
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/vsgXchange/models.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace vsgXchange
static constexpr const char* discard_empty_nodes = "discard_empty_nodes"; /// bool
static constexpr const char* external_textures = "external_textures"; /// bool
static constexpr const char* external_texture_format = "external_texture_format"; /// TextureFormat enum
static constexpr const char* sRGBTextures = "sRGBTextures"; /// bool

bool readOptions(vsg::Options& options, vsg::CommandLine& arguments) const override;

Expand Down
9 changes: 5 additions & 4 deletions src/assimp/assimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ bool assimp::getFeatures(Features& features) const
features.optionNameTypeMap[assimp::discard_empty_nodes] = vsg::type_name<bool>();
features.optionNameTypeMap[assimp::external_textures] = vsg::type_name<bool>();
features.optionNameTypeMap[assimp::external_texture_format] = vsg::type_name<TextureFormat>();
features.optionNameTypeMap[assimp::sRGBTextures] = vsg::type_name<bool>();

return true;
}
Expand All @@ -157,6 +158,7 @@ bool assimp::readOptions(vsg::Options& options, vsg::CommandLine& arguments) con
result = arguments.readAndAssign<bool>(assimp::discard_empty_nodes, &options) || result;
result = arguments.readAndAssign<bool>(assimp::external_textures, &options) || result;
result = arguments.readAndAssign<TextureFormat>(assimp::external_texture_format, &options) || result;
result = arguments.readAndAssign<bool>(assimp::sRGBTextures, &options) || result;

return result;
}
Expand All @@ -181,6 +183,7 @@ struct SceneConverter
bool discardEmptyNodes = true;
bool externalTextures = false;
TextureFormat externalTextureFormat = TextureFormat::native;
bool sRGBTextures = false;

// TODO flatShadedShaderSet?
vsg::ref_ptr<vsg::ShaderSet> pbrShaderSet;
Expand Down Expand Up @@ -330,8 +333,6 @@ SamplerData SceneConverter::convertTexture(const aiMaterial& material, aiTexture
}
}

bool sRGBTextures = false;
options->getValue("sRGBTextures", sRGBTextures);
if (sRGBTextures && (type == aiTextureType_DIFFUSE || type == aiTextureType_EMISSIVE))
{
switch (samplerImage.data->properties.format)
Expand Down Expand Up @@ -390,7 +391,7 @@ SamplerData SceneConverter::convertTexture(const aiMaterial& material, aiTexture
externalTextureFilename = vsg::removeExtension(externalTextureFilename).concat(".vsgb");
break;
}

// actually write out the texture.. this need only be done once per texture!
if (externalObjects->entries.count(externalTextureFilename) == 0)
{
Expand Down Expand Up @@ -825,7 +826,7 @@ vsg::ref_ptr<vsg::Node> SceneConverter::visit(const aiScene* in_scene, vsg::ref_
discardEmptyNodes = vsg::value<bool>(true, assimp::discard_empty_nodes, options);
externalTextures = vsg::value<bool>(false, assimp::external_textures, options);
externalTextureFormat = vsg::value<TextureFormat>(TextureFormat::native, assimp::external_texture_format, options);

sRGBTextures = vsg::value<bool>(false, assimp::sRGBTextures, options);

std::string name = scene->mName.C_Str();

Expand Down

0 comments on commit ad24499

Please sign in to comment.