diff --git a/OIIO/WriteOIIO.cpp b/OIIO/WriteOIIO.cpp index 801a9a4..91b588b 100644 --- a/OIIO/WriteOIIO.cpp +++ b/OIIO/WriteOIIO.cpp @@ -229,6 +229,25 @@ enum EParamTileSize { eParamTileSize512 }; +#define kParamOutputTextureformat "textureformat" +#define kParamOutputTextureformatLabel "Texture Format" +#define kParamOutputTextureformatHint "" + +#define kParamOutputTextureformatOptionNone "None", "", "0" +#define kParamOutputTextureformatOptionPlain "Plain Texture", "MIP-mapped OpenEXR files", "Plain Texture" +#define kParamOutputTextureformatOptionLatLong "LatLong Environment", "Latlong Environment OpenEXR environment maps.", "LatLong Environment" +#define kParamOutputTextureformatOptionCubeFace "CubeFace Environment", "CubeFace Environment OpenEXR environment maps.", "CubeFace Environment" +#define kParamOutputTextureformatOptionShadow "Shadow", "Force one level for shadow maps", "Shadow" + +enum EParamTextureformat { + eParamTextureformatNone = 0, + eParamTextureformatPlain, + eParamTextureformatLatLong, + eParamTextureformatCubeFace, + eParamTextureformatShadow +} + + #define kParamProcessAllLayers "processAllLayers" #define kParamProcessAllLayersLabel "All Layers" #define kParamProcessAllLayersHint "When checked, all layers will be written to the file" @@ -372,6 +391,7 @@ class WriteOIIOPlugin IntParam* _zipCompressionLevel; ChoiceParam* _orientation; ChoiceParam* _compression; + ChoiceParam* _textureformat; ChoiceParam* _tileSize; ChoiceParam* _outputLayers; ChoiceParam* _parts; @@ -389,6 +409,7 @@ WriteOIIOPlugin::WriteOIIOPlugin(OfxImageEffectHandle handle, , _zipCompressionLevel(NULL) , _orientation(NULL) , _compression(NULL) + , _textureformat(NULL) , _tileSize(NULL) , _outputLayers(NULL) , _parts(NULL) @@ -403,6 +424,7 @@ WriteOIIOPlugin::WriteOIIOPlugin(OfxImageEffectHandle handle, _zipCompressionLevel = fetchIntParam(kParamOutputZIPCompressionLevel); _orientation = fetchChoiceParam(kParamOutputOrientation); _compression = fetchChoiceParam(kParamOutputCompression); + _textureformat = fetchChoiceParam(kParamOutputTextureformat); _tileSize = fetchChoiceParam(kParamTileSize); if (gIsMultiplanarV2) { _outputLayers = fetchChoiceParam(kParamOutputChannels); @@ -843,6 +865,9 @@ WriteOIIOPlugin::refreshParamsVisibility(const string& filename) if (_views) { _views->setIsSecretAndDisabled(!isEXR); } + if (_textureformat) { + _textureformat->setIsSecretAndDisabled(!isEXR); + } if (_parts) { _parts->setIsSecretAndDisabled(!output->supports("multiimage")); } @@ -855,6 +880,9 @@ WriteOIIOPlugin::refreshParamsVisibility(const string& filename) if (_views) { _views->setIsSecretAndDisabled(true); } + if (_textureformat) { + _textureformat->setIsSecretAndDisabled(true); + } if (_parts) { _parts->setIsSecretAndDisabled(true); } @@ -1013,6 +1041,9 @@ WriteOIIOPlugin::beginEncodeParts(void* user_data, int compression_i; _compression->getValue(compression_i); string compression; + int textureformat_i; + _textureformat->getValue(textureformat_i); + string textureformat; switch ((EParamCompression)compression_i) { case eParamCompressionAuto: { @@ -1069,6 +1100,21 @@ WriteOIIOPlugin::beginEncodeParts(void* user_data, break; } + switch ((EParamTextureformat)textureformat_i) { + case eParamTextureformatPlain: + textureformat = "Plain Texture"; + break; + case eParamTextureformatCubeFace: + textureformat = "CubeFace Environment"; + break; + case eParamTextureformatLatLong: + textureformat = "LatLong Environment"; + break; + case eParamTextureformatShadow: + textureformat = "Shadow"; + break; + } + spec.attribute("oiio:BitsPerSample", bitsPerSample); // oiio:UnassociatedAlpha should be set if the data buffer is unassociated/unpremultiplied. // However, WriteOIIO::getExpectedInputPremultiplication() stated that input to the encode() @@ -1150,6 +1196,7 @@ WriteOIIOPlugin::beginEncodeParts(void* user_data, #endif } spec.attribute("Orientation", orientation + 1); + spec.attribute("textureformat", textureformat); if (!compression.empty()) { // some formats have a good value for the default compression spec.attribute("compression", compression); } @@ -1732,6 +1779,25 @@ WriteOIIOPluginFactory::describeInContext(ImageEffectDescriptor& desc, page->addChild(*param); } } + { + ChoiceParamDescriptor* param = desc.defineChoiceParam(kParamOutputTextureformat); + param->setLabel(kParamOutputTextureformatLabel); + param->setHint(kParamOutputTextureformatHint); + assert(param->getNOptions() == eParamTextureformatNone); + param->appendOption(kParamOutputTextureformatOptionNone); + assert(param->getNOptions() == eParamTextureformatPlain); + param->appendOption(kParamOutputTextureformatOptionPlain); + assert(param->getNOptions() == eParamTextureformatLatLong); + param->appendOption(kParamOutputTextureformatOptionLatLong); + assert(param->getNOptions() == eParamTextureformatCubeFace); + param->appendOption(kParamOutputTextureformatOptionCubeFace); + assert(param->getNOptions() == eParamTextureformatShadow); + param->appendOption(kParamOutputTextureformatOptionShadow); + param->setDefault(eParamTextureformatNone); + if (page) { + page->addChild(*param); + } + } if (gIsMultiplanarV2) {