[Bf-blender-cvs] [287adc8eba0] cycles_texture_cache: Cycles: Mip map creation now respects texture extension settings

Stefan Werner noreply at git.blender.org
Fri Jan 11 13:44:35 CET 2019


Commit: 287adc8eba094c604350ae4d29acf0d381abb42a
Author: Stefan Werner
Date:   Fri Jan 11 13:43:38 2019 +0100
Branches: cycles_texture_cache
https://developer.blender.org/rB287adc8eba094c604350ae4d29acf0d381abb42a

Cycles: Mip map creation now respects texture extension settings

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

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

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

diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index cc45122464c..7af43634db2 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -607,12 +607,13 @@ static PyObject *oiio_make_tx(PyObject * /*self*/, PyObject *args)
 {
 	const char *inputfile = NULL, *outputfile = NULL;
 	int srgb = 1;
+	int extension = EXTENSION_CLIP;
 
-	if(!PyArg_ParseTuple(args, "ssp", &inputfile, &outputfile, &srgb))
+	if(!PyArg_ParseTuple(args, "sspi", &inputfile, &outputfile, &srgb, &extension))
 		return NULL;
 	
 	/* return */
-	if(!ImageManager::make_tx(inputfile, outputfile, srgb))
+	if(!ImageManager::make_tx(inputfile, outputfile, srgb, (ExtensionType)extension))
 		Py_RETURN_FALSE;
 
 	Py_RETURN_TRUE;
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 0cd3f5c2713..27d312e6dac 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -1155,15 +1155,30 @@ void ImageManager::device_free(Device *device)
 	}
 }
 
-bool ImageManager::make_tx(const string &filename, const string &outputfilename, bool srgb)
+bool ImageManager::make_tx(const string &filename, const string &outputfilename, bool srgb, ExtensionType extension)
 {
 	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);
 	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(srgb) {
 		config.attribute("maketx:incolorspace", "sRGB");
@@ -1200,7 +1215,7 @@ bool ImageManager::get_tx(Image *image, Progress *progress, bool auto_convert, c
 	if(auto_convert) {
 		progress->set_status("Updating Images", "Converting " + image->filename);
 	
-		bool ok = make_tx(image->filename, tx_name, image->srgb);
+		bool ok = make_tx(image->filename, tx_name, image->srgb, image->extension);
 		if(ok) {
 			image->filename = tx_name;
 		return true;
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index aa294264807..230372ad175 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -139,7 +139,7 @@ public:
 		int users;
 	};
 
-	static bool make_tx(const string& filename, const string& outputfilename, bool srgb);
+	static bool make_tx(const string& filename, const string& outputfilename, bool srgb, ExtensionType extension);
 
 private:
 	int tex_num_images[IMAGE_DATA_NUM_TYPES];



More information about the Bf-blender-cvs mailing list