Commit: 6568074b94211007dec99287d3ecae26876431ba
Author: Stefan Werner
Date:   Fri Oct 19 14:49:37 2018 +0200
Branches: cycles_texture_cache
https://developer.blender.org/rB6568074b94211007dec99287d3ecae26876431ba

Cycles: Added option for custom texture cache path.

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

M       intern/cycles/blender/addon/properties.py
M       intern/cycles/blender/addon/ui.py
M       intern/cycles/blender/blender_sync.cpp
M       intern/cycles/render/image.cpp
M       intern/cycles/render/image.h
M       intern/cycles/render/scene.h

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

diff --git a/intern/cycles/blender/addon/properties.py 
b/intern/cycles/blender/addon/properties.py
index 85fa99a172d..3c2c6c8a4a9 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -717,10 +717,23 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
         cls.texture_blur_glossy = FloatProperty(
             name="Glossy Blur",
             default=0.0,
-            description="The amount of texture blur applied to diffuse 
bounces",
+            description="The amount of texture blur applied to glossy bounces",
             min = 0.0, max = 1.0
         )
 
+        cls.use_custom_cache_path = BoolProperty(
+            name="Use Custom Cache Path",
+            default=False,
+            description="Use a custom path for the texture cache, as oppoosed 
to placing cache files next to the original file"
+        )
+
+        cls.custom_cache_path = StringProperty(
+            name="Custom Cache Path",
+            default="",
+            subtype="DIR_PATH",
+            description="Custom path for the texture cache"
+        )
+
         cls.ao_bounces = IntProperty(
             name="AO Bounces",
             default=0,
diff --git a/intern/cycles/blender/addon/ui.py 
b/intern/cycles/blender/addon/ui.py
index b55992a25cc..ba905a35ad9 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -460,8 +460,7 @@ class CYCLES_RENDER_PT_texture_cache(CyclesButtonsPanel, 
Panel):
         rd = scene.render
         layout.active = cscene.use_texture_cache
 
-        col = layout.column()
-        split = col.split()
+        split = layout.split()
         col = split.column()
         col.prop(cscene, "texture_auto_convert")
         col.prop(cscene, "texture_accept_unmipped")
@@ -473,6 +472,11 @@ class CYCLES_RENDER_PT_texture_cache(CyclesButtonsPanel, 
Panel):
         col.prop(cscene, "texture_tile_size")
         col.prop(cscene, "texture_blur_diffuse")
         col.prop(cscene, "texture_blur_glossy")
+        row = layout.row()
+        row.prop(cscene, "use_custom_cache_path")
+        row = layout.row()
+        row.active = cscene.use_custom_cache_path
+        row.prop(cscene, "custom_cache_path")
 
 class CYCLES_RENDER_PT_layer_options(CyclesButtonsPanel, Panel):
     bl_label = "Layer"
diff --git a/intern/cycles/blender/blender_sync.cpp 
b/intern/cycles/blender/blender_sync.cpp
index a5c3de71195..01b71624394 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -699,6 +699,17 @@ SceneParams BlenderSync::get_scene_params(BL::Scene& 
b_scene,
        params.texture.auto_tile = RNA_boolean_get(&cscene, 
"texture_auto_tile");
        params.texture.diffuse_blur = RNA_float_get(&cscene, 
"texture_blur_diffuse");
        params.texture.glossy_blur = RNA_float_get(&cscene, 
"texture_blur_glossy");
+       params.texture.use_custom_cache_path  = RNA_boolean_get(&cscene, 
"use_custom_cache_path");
+       if(params.texture.use_custom_cache_path) {
+               char *path = RNA_string_get_alloc(&cscene, "custom_cache_path", 
NULL, 0);
+               if(path) {
+                       params.texture.custom_cache_path = path;
+                       MEM_freeN(path);
+               }
+       }
+       else {
+               params.texture.custom_cache_path.clear();
+       }
        
        return params;
 }
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index e951d0266ea..fae7a7f19a6 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -765,7 +765,9 @@ void ImageManager::device_load_image(Device *device,
        if(oiio_texture_system && !img->builtin_data) {
                /* Get or generate a mip mapped tile image file.
                 * If we have a mip map, assume it's linear, not sRGB. */
-               bool have_mip = get_tx(img, progress, 
scene->params.texture.auto_convert);
+               const char *cache_path = 
scene->params.texture.use_custom_cache_path ?
+                                        
scene->params.texture.custom_cache_path.c_str() : NULL;
+               bool have_mip = get_tx(img, progress, 
scene->params.texture.auto_convert, cache_path);
 
                /* When using OIIO directly from SVM, store the TextureHandle
                 * in an array for quicker lookup at shading time */
@@ -1145,7 +1147,7 @@ bool ImageManager::make_tx(const string &filename, const 
string &outputfilename,
        return ImageBufAlgo::make_texture(ImageBufAlgo::MakeTxTexture, 
filename, outputfilename, config);
 }
 
-bool ImageManager::get_tx(Image *image, Progress *progress, bool auto_convert)
+bool ImageManager::get_tx(Image *image, Progress *progress, bool auto_convert, 
const char *cache_path)
 {
        if(!path_exists(image->filename)) {
                return false;
@@ -1160,6 +1162,10 @@ bool ImageManager::get_tx(Image *image, Progress 
*progress, bool auto_convert)
        }
        
        string tx_name = image->filename.substr(0, idx) + ".tx";
+       if(cache_path) {
+               string filename = path_filename(tx_name);
+               tx_name = path_join(string(cache_path), filename);
+       }
        if(path_exists(tx_name)) {
                image->filename = tx_name;
                return true;
diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h
index 2cfd25028b0..c76c8a69113 100644
--- a/intern/cycles/render/image.h
+++ b/intern/cycles/render/image.h
@@ -168,7 +168,7 @@ private:
                               ImageDataType type,
                               int slot);
                
-       bool get_tx(Image *image, Progress *progress, bool auto_convert);
+       bool get_tx(Image *image, Progress *progress, bool auto_convert, const 
char *cache_path);
 };
 
 CCL_NAMESPACE_END
diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h
index 27fa4fa3be4..49854641302 100644
--- a/intern/cycles/render/scene.h
+++ b/intern/cycles/render/scene.h
@@ -133,7 +133,7 @@ class TextureCacheParams {
 public:
        TextureCacheParams() : use_cache(false), cache_size(1024), 
tile_size(64), diffuse_blur(1.0f/64.f),
        glossy_blur(0.0f), auto_convert(true), accept_unmipped(true), 
accept_untiled(true),
-       auto_tile(true), auto_mip(true) { }
+       auto_tile(true), auto_mip(true), use_custom_cache_path(false) { }
        
        bool modified(const TextureCacheParams& params)
        {
@@ -146,7 +146,9 @@ public:
                                 && accept_unmipped == params.accept_unmipped
                                 && accept_untiled == params.accept_untiled
                                 && auto_tile == params.auto_tile
-                                && auto_mip == params.auto_mip);
+                                && auto_mip == params.auto_mip
+                                && use_custom_cache_path == 
params.use_custom_cache_path
+                                && custom_cache_path == 
params.custom_cache_path);
        }
 
        bool use_cache;
@@ -159,6 +161,8 @@ public:
        bool accept_untiled;
        bool auto_tile;
        bool auto_mip;
+       bool use_custom_cache_path;
+       string custom_cache_path;
 };
 
 /* Scene Parameters */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to