[Bf-blender-cvs] [195c664716a] cycles_texture_cache: Merge branch 'master' into cycles_texture_cache
Stefan Werner
noreply at git.blender.org
Mon Jun 15 12:33:11 CEST 2020
Commit: 195c664716a171106166d64e317b6e9ee80f8f40
Author: Stefan Werner
Date: Mon Jun 8 22:38:19 2020 +0200
Branches: cycles_texture_cache
https://developer.blender.org/rB195c664716a171106166d64e317b6e9ee80f8f40
Merge branch 'master' into cycles_texture_cache
===================================================================
===================================================================
diff --cc intern/cycles/render/image_oiio.cpp
index 6422371c516,c4f95c6b4bc..84ac68fb01c
--- a/intern/cycles/render/image_oiio.cpp
+++ b/intern/cycles/render/image_oiio.cpp
@@@ -236,86 -233,4 +236,86 @@@ bool OIIOImageLoader::equals(const Imag
return filepath == other_loader.filepath;
}
+
+bool OIIOImageLoader::make_tx(const string &filename,
+ const string &outputfilename,
+ const ustring &colorspace,
+ ExtensionType extension)
+{
+ ImageSpec config;
+ config.attribute("maketx:filtername", "lanczos3");
+ config.attribute("maketx:opaque_detect", 1);
+ config.attribute("maketx:highlightcomp", 1);
+ config.attribute("maketx:oiio_options", 1);
+ config.attribute("maketx:updatemode", 1);
+
+ switch (extension) {
+ case EXTENSION_CLIP:
+ config.attribute("maketx:wrap", "black");
+ break;
+ case EXTENSION_REPEAT:
+ config.attribute("maketx:wrap", "periodic");
+ break;
+ case EXTENSION_EXTEND:
+ config.attribute("maketx:wrap", "clamp");
+ break;
+ default:
+ assert(0);
+ break;
+ }
+
+ /* Convert textures to linear color space before mip mapping. */
+ if (colorspace != u_colorspace_raw) {
+ if (colorspace == u_colorspace_srgb || colorspace.empty()) {
+ config.attribute("maketx:incolorspace", "sRGB");
+ }
+ else {
+ config.attribute("maketx:incolorspace", colorspace.c_str());
+ }
+ config.attribute("maketx:outcolorspace", "linear");
+ }
+
+ return ImageBufAlgo::make_texture(ImageBufAlgo::MakeTxTexture, filename, outputfilename, config);
+}
+
+bool OIIOImageLoader::get_tx(const ustring &colorspace,
+ const ExtensionType &extension,
+ Progress *progress,
+ bool auto_convert,
+ const char *cache_path)
+{
+ if (!path_exists(osl_filepath().c_str())) {
+ return false;
+ }
+
+ string::size_type idx = osl_filepath().rfind('.');
+ if (idx != string::npos) {
+ string extension = osl_filepath().substr(idx + 1).c_str();
+ if (extension == "tx") {
+ return true;
+ }
+ }
+
+ string tx_name = string(osl_filepath().substr(0, idx).c_str()) + ".tx";
+ if (cache_path) {
+ string filename = path_filename(tx_name);
+ tx_name = path_join(string(cache_path), filename);
+ }
+ if (path_exists(tx_name)) {
+ filepath = tx_name;
+ return true;
+ }
+
+ if (auto_convert && progress) {
- progress->set_status("Updating Images", "Converting " + osl_filepath());
++ progress->set_status("Updating Images", string("Converting ") + osl_filepath().c_str());
+
+ bool ok = make_tx(osl_filepath().c_str(), tx_name, colorspace, extension);
+ if (ok) {
+ filepath = tx_name;
+ return true;
+ }
+ }
+ return false;
+}
+
CCL_NAMESPACE_END
More information about the Bf-blender-cvs
mailing list