[Bf-blender-cvs] [3d113538561] upstream_cycles_texture_cache: Cycles: Changed Mip Map names to replace, not add to suffix Added oiio_make_tx() call to Cycles' Python API

Stefan Werner noreply at git.blender.org
Wed Jun 27 14:05:06 CEST 2018


Commit: 3d11353856190793b5883c9a035d3b413c68e35f
Author: Stefan Werner
Date:   Tue Aug 1 09:11:50 2017 +0200
Branches: upstream_cycles_texture_cache
https://developer.blender.org/rB3d11353856190793b5883c9a035d3b413c68e35f

Cycles: Changed Mip Map names to replace, not add to suffix
Added oiio_make_tx() call to Cycles' Python API

===================================================================

M	intern/cycles/blender/blender_python.cpp
M	intern/cycles/render/image.cpp
M	intern/cycles/render/image.h
M	intern/cycles/render/shader.cpp

===================================================================

diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 76cc18dd9a1..3ee26f383d9 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -599,6 +599,21 @@ static PyObject *osl_compile_func(PyObject * /*self*/, PyObject *args)
 }
 #endif
 
+static PyObject *oiio_make_tx(PyObject * /*self*/, PyObject *args)
+{
+	const char *inputfile = NULL, *outputfile = NULL;
+	int srgb = 1;
+
+	if(!PyArg_ParseTuple(args, "ssp", &inputfile, &outputfile, &srgb))
+		return NULL;
+	
+	/* return */
+	if(!ImageManager::make_tx(inputfile, outputfile, srgb))
+		Py_RETURN_FALSE;
+
+	Py_RETURN_TRUE;
+}
+
 static PyObject *system_info_func(PyObject * /*self*/, PyObject * /*value*/)
 {
 	string system_info = Device::device_capabilities();
@@ -762,6 +777,7 @@ static PyMethodDef methods[] = {
 	{"osl_update_node", osl_update_node_func, METH_VARARGS, ""},
 	{"osl_compile", osl_compile_func, METH_VARARGS, ""},
 #endif
+	{"oiio_make_tx", oiio_make_tx, METH_VARARGS, ""},
 	{"available_devices", available_devices_func, METH_NOARGS, ""},
 	{"system_info", system_info_func, METH_NOARGS, ""},
 #ifdef WITH_OPENCL
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 70012e491a8..234c7c4e3c1 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -1053,6 +1053,22 @@ void ImageManager::device_free(Device *device)
 	}
 }
 
+bool ImageManager::make_tx(const string &filename, const string &outputfilename, bool srgb)
+{
+	ImageSpec config;
+	config.attribute("maketx:filtername", "lanczos3");
+	config.attribute("maketx:opaque_detect", 1);
+	config.attribute("maketx:highlightcomp", 1);
+	config.attribute("maketx:updatemode", 1);
+	config.attribute("maketx:oiio_options", 1);
+	if(srgb) {
+		config.attribute("maketx:incolorspace", "sRGB");
+		config.attribute("maketx:outcolorspace", "linear");
+	}
+
+	return ImageBufAlgo::make_texture(ImageBufAlgo::MakeTxTexture, filename, outputfilename, config);
+}
+
 bool ImageManager::make_tx(Image *image, Progress *progress)
 {
 	if(!path_exists(image->filename)) {
@@ -1067,7 +1083,7 @@ bool ImageManager::make_tx(Image *image, Progress *progress)
 		}
 	}
 	
-	string tx_name = image->filename + ".tx";
+	string tx_name = image->filename.substr(0, idx) + ".tx";
 	if(path_exists(tx_name)) {
 		image->filename = tx_name;
 		return true;
@@ -1075,18 +1091,7 @@ bool ImageManager::make_tx(Image *image, Progress *progress)
 	
 	progress->set_status("Updating Images", "Converting " + image->filename);
 	
-	ImageSpec config;
-	config.attribute("maketx:filtername", "lanczos3");
-	config.attribute("maketx:opaque_detect", 1);
-	config.attribute("maketx:highlightcomp", 1);
-	config.attribute("maketx:updatemode", 1);
-	config.attribute("maketx:oiio_options", 1);
-	if(image->srgb) {
-		config.attribute("maketx:incolorspace", "sRGB");
-		config.attribute("maketx:outcolorspace", "linear");
-	}
-
-	bool ok = ImageBufAlgo::make_texture(ImageBufAlgo::MakeTxTexture, image->filename, tx_name, config);
+	bool ok = make_tx(image->filename, tx_name, image->srgb);
 	if(ok) {
 		image->filename = tx_name;
 	}
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index fc0c959367b..8bd78ef4783 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -131,6 +131,8 @@ public:
 		int users;
 	};
 
+	static bool make_tx(const string& filename, const string& outputfilename, bool srgb);
+
 private:
 	int tex_num_images[IMAGE_DATA_NUM_TYPES];
 	int max_num_images;
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 5f8739da1cd..71d0061863a 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -721,9 +721,6 @@ void ShaderManager::texture_system_init()
 {
 	ts = TextureSystem::create(true);
 	ts->attribute("gray_to_rgb", 1);
-	/* these seem to do nothing */
-	ts->attribute("latlong_up", "z");
-	//ts->attribute("flip_t", 1);
 	ts->attribute("forcefloat", 1);
 }



More information about the Bf-blender-cvs mailing list