Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 4 additions & 5 deletions dso/map/Image/ImageMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ ImageMap::update()
}
if (needsUpdate ||
hasChanged(attrTexture) ||
hasChanged(attrGamma) ||
hasChanged(attrSourceColorSpace) ||
hasChanged(attrWrapAround) ||
hasChanged(attrUseDefaultColor) ||
hasChanged(attrDefaultColor)) {
std::string errorStr;
if (!mUdimTexture->update(this,
sLogEventRegistry,
get(attrTexture),
static_cast<ispc::TEXTURE_GammaMode>(get(attrGamma)),
get(attrSourceColorSpace),
wrapS,
wrapT,
get(attrUseDefaultColor),
Expand All @@ -161,13 +161,13 @@ ImageMap::update()
}
if (needsUpdate ||
hasChanged(attrTexture) ||
hasChanged(attrGamma) ||
hasChanged(attrSourceColorSpace) ||
hasChanged(attrWrapAround) ||
hasChanged(attrUseDefaultColor) ||
hasChanged(attrDefaultColor)) {
std::string errorStr;
if (!mTexture->update(get(attrTexture),
static_cast<ispc::TEXTURE_GammaMode>(get(attrGamma)),
get(attrSourceColorSpace),
wrapS,
wrapT,
get(attrUseDefaultColor),
Expand Down Expand Up @@ -415,4 +415,3 @@ ImageMap::applyColorCorrection(Color& result) const
}

//---------------------------------------------------------------------------

17 changes: 6 additions & 11 deletions dso/map/Image/ImageMap.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,12 @@
"group": "Blur",
"comment": "Amount to offset derivatives which controls mipmap selection. This can be used to provide a cheap, albiet low quality, blur. Note: Setting this value to -1.0 effectively disables mip mapping and the highest resolution will be used."
},
"attrGamma": {
"name": "gamma",
"type": "Int",
"default": "2",
"flags": "FLAGS_ENUMERABLE",
"enum": {
"off": "0",
"on": "1",
"auto": "2"
},
"comment": "If this is set to 'on' or 'auto' and the 'texture' file is 8-bit, then a power of 2.2 will be applied to the RGB channels of the image."
"attrSourceColorSpace": {
"name": "source_color_space",
"label": "source color space",
"type": "String",
"default": "\"auto\"",
"comment": "OCIO source color space for the texture. Use 'auto' to apply the active OCIO file rules. Explicit values are resolved as color-space names, roles, or aliases from the active OCIO config."
},
"attrOffset": {
"name": "offset",
Expand Down
36 changes: 33 additions & 3 deletions dso/map/UsdUVTexture/UsdUVTexture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ static ispc::StaticUsdUVTextureData sStaticUsdUVTextureData;

//----------------------------------------------------------------------------

namespace {

constexpr int sSourceColorSpaceRaw = 0;
constexpr int sSourceColorSpaceSrgb = 1;

std::string
sourceColorSpaceFromUsdEnum(const int sourceColorSpace, const std::string& overrideValue)
{
if (!overrideValue.empty()) {
return overrideValue;
}

switch (sourceColorSpace) {
case sSourceColorSpaceRaw:
return "raw";
case sSourceColorSpaceSrgb:
return "sRGB";
default:
return "auto";
}
}

} // namespace

RDL2_DSO_CLASS_BEGIN(UsdUVTexture, scene_rdl2::rdl2::Map)

public:
Expand Down Expand Up @@ -73,6 +97,9 @@ UsdUVTexture::update()
const std::string filename = get(attrFile);
const std::size_t udimPos = filename.find("<UDIM>");
const bool areWeAUdim = udimPos != std::string::npos;
const std::string sourceColorSpace =
sourceColorSpaceFromUsdEnum(get(attrSourceColorSpace),
get(attrSourceColorSpaceOverride));

const scene_rdl2::rdl2::SceneVariables &sv = getSceneClass().getSceneContext()->getSceneVariables();
mIspc.mFatalColor = asIspc(sv.get(scene_rdl2::rdl2::SceneVariables::sFatalColor));
Expand Down Expand Up @@ -103,14 +130,16 @@ UsdUVTexture::update()

if (needsUpdate ||
hasChanged(attrFile) ||
hasChanged(attrSourceColorSpace) ||
hasChanged(attrSourceColorSpaceOverride) ||
hasChanged(attrWrapS) ||
hasChanged(attrWrapT) ||
hasChanged(attrFallback)) {

if (!mUdimTexture->update(this,
sLogEventRegistry,
filename,
static_cast<ispc::TEXTURE_GammaMode>(get(attrSourceColorSpace)),
sourceColorSpace,
wrapS,
wrapT,
true, // use default/fallback color
Expand All @@ -135,12 +164,14 @@ UsdUVTexture::update()
}
if (needsUpdate ||
hasChanged(attrFile) ||
hasChanged(attrSourceColorSpace) ||
hasChanged(attrSourceColorSpaceOverride) ||
hasChanged(attrWrapS) ||
hasChanged(attrWrapT) ||
hasChanged(attrFallback)) {

if (!mTexture->update(filename,
static_cast<ispc::TEXTURE_GammaMode>(get(attrSourceColorSpace)),
sourceColorSpace,
wrapS,
wrapT,
true, // use default/fallback color
Expand Down Expand Up @@ -242,4 +273,3 @@ UsdUVTexture::sample(const scene_rdl2::rdl2::Map *self,
rgb = rgb * me->get(attrScale) + me->get(attrBias);
*sample = rgb;
}

9 changes: 8 additions & 1 deletion dso/map/UsdUVTexture/UsdUVTexture.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@
"sRGB": "1",
"auto": "3"
},
"comment": "Flag indicating the color space in which the source texture is encoded. If set to auto, gamma correction will be applied if the images is not single channel."
"comment": "USD sourceColorSpace policy. raw is treated as USD data, sRGB is resolved through the active OCIO config, and auto uses OCIO file rules."
},
"attrSourceColorSpaceOverride": {
"name": "source_color_space",
"label": "source color space override",
"type": "String",
"default": "\"\"",
"comment": "Optional OCIO source color-space override. Empty preserves the USD sourceColorSpace enum. Use 'auto' to apply active OCIO file rules, or author a color-space name, role, or alias from the active OCIO config. Data color spaces bypass conversion because OCIO marks them as data."
}
}
}
Loading