[Bf-blender-cvs] [6450e35a2f6] upstream_cycles_texture_cache: Cycles: added diffuse_blur and glossy_blur parameters to texture cache

Stefan Werner noreply at git.blender.org
Wed Jun 27 14:04:57 CEST 2018


Commit: 6450e35a2f6d5a6cf99c2721c9b657ab4f366309
Author: Stefan Werner
Date:   Fri Jul 14 14:57:19 2017 +0200
Branches: upstream_cycles_texture_cache
https://developer.blender.org/rB6450e35a2f6d5a6cf99c2721c9b657ab4f366309

Cycles: added diffuse_blur and glossy_blur parameters to texture cache

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_sync.cpp
M	intern/cycles/kernel/kernel_oiio_globals.h
M	intern/cycles/kernel/svm/svm_image.h
M	intern/cycles/render/image.cpp
M	intern/cycles/render/scene.h
M	intern/cycles/render/shader.cpp

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 0297123a748..5c92b9dc9ca 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -699,6 +699,20 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
             description="The size of tiles that Cycles uses for auto tiling"
         )
 
+        cls.texture_blur_diffuse = FloatProperty(
+            name="Diffuse Blur",
+            default=0.0156,
+            description="The amount of texture blur applied to diffuse bounces",
+            min = 0.0, max = 1.0
+        )
+
+        cls.texture_blur_glossy = FloatProperty(
+            name="Glossy Blur",
+            default=0.0,
+            description="The amount of texture blur applied to diffuse bounces",
+            min = 0.0, max = 1.0
+        )
+
         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 df44d8aac45..0cea7181384 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -429,6 +429,8 @@ class CYCLES_RENDER_PT_performance(CyclesButtonsPanel, Panel):
         sub.prop(cscene, "texture_auto_mip")
         sub.prop(cscene, "texture_auto_tile")
         sub.prop(cscene, "texture_tile_size")
+        sub.prop(cscene, "texture_blur_diffuse")
+        sub.prop(cscene, "texture_blur_glossy")
 
         col = split.column()
 
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index e47b64b99f2..eb70b702a0c 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -664,14 +664,16 @@ SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene,
 
 	params.bvh_layout = DebugFlags().cpu.bvh_layout;
 
-	params.texture_cache_size = RNA_int_get(&cscene, "texture_cache_size");
-	params.texture_auto_convert = RNA_boolean_get(&cscene, "texture_auto_convert");
-	params.texture_accept_unmipped = RNA_boolean_get(&cscene, "texture_accept_unmipped");
-	params.texture_accept_untiled = RNA_boolean_get(&cscene, "texture_accept_untiled");
-	params.texture_tile_size = RNA_int_get(&cscene, "texture_tile_size");
-	params.texture_auto_mip = RNA_int_get(&cscene, "texture_auto_mip");
-	params.texture_auto_tile = RNA_int_get(&cscene, "texture_auto_tile");
-
+	params.texture.cache_size = RNA_int_get(&cscene, "texture_cache_size");
+	params.texture.auto_convert = RNA_boolean_get(&cscene, "texture_auto_convert");
+	params.texture.accept_unmipped = RNA_boolean_get(&cscene, "texture_accept_unmipped");
+	params.texture.accept_untiled = RNA_boolean_get(&cscene, "texture_accept_untiled");
+	params.texture.tile_size = RNA_int_get(&cscene, "texture_tile_size");
+	params.texture.auto_mip = RNA_boolean_get(&cscene, "texture_auto_mip");
+	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");
+	
 	return params;
 }
 
diff --git a/intern/cycles/kernel/kernel_oiio_globals.h b/intern/cycles/kernel/kernel_oiio_globals.h
index d8e81d98659..54644c94160 100644
--- a/intern/cycles/kernel/kernel_oiio_globals.h
+++ b/intern/cycles/kernel/kernel_oiio_globals.h
@@ -35,6 +35,8 @@ struct OIIOGlobals
 	OIIO::TextureSystem *tex_sys;
 	thread_mutex tex_paths_mutex;
 	vector<OIIOTexture> textures;
+	float diffuse_blur;
+	float glossy_blur;
 };
 
 CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index ab9b4c413d3..ef491ceed17 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -17,7 +17,7 @@
 #ifdef __OIIO__
 #  include "kernel/kernel_oiio_globals.h"
 #  define NEAREST_LOOKUP_PATHS (PATH_RAY_DIFFUSE | PATH_RAY_SHADOW | PATH_RAY_DIFFUSE_ANCESTOR | PATH_RAY_VOLUME_SCATTER | PATH_RAY_GLOSSY)
-#  define BLUR_LOOKUP_PATHS (PATH_RAY_DIFFUSE | PATH_RAY_DIFFUSE_ANCESTOR)
+#  define DIFFUSE_BLUR_PATHS (PATH_RAY_DIFFUSE | PATH_RAY_DIFFUSE_ANCESTOR)
 #endif
 
 CCL_NAMESPACE_BEGIN
@@ -34,14 +34,23 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
 		if(path_flag & NEAREST_LOOKUP_PATHS) {
 			options.interpmode = OIIO::TextureOpt::InterpClosest;
 			options.mipmode = OIIO::TextureOpt::MipModeOneLevel;
-			if(path_flag & BLUR_LOOKUP_PATHS) {
-				options.sblur = options.tblur = 1.f/64.f;
-			}
 		}
 		else {
 			options.interpmode = kg->oiio->textures[id].interpolation;
 			options.mipmode = OIIO::TextureOpt::MipModeAniso;
 		}
+		
+		
+		if(path_flag & DIFFUSE_BLUR_PATHS) {
+			options.sblur = options.tblur = kg->oiio->diffuse_blur;
+		}
+		else if(path_flag & PATH_RAY_GLOSSY) {
+			options.sblur = options.tblur = kg->oiio->glossy_blur;
+		}
+		else {
+			options.sblur = options.tblur = 0.0f;
+		}
+		
 		bool success = kg->oiio->tex_sys->texture(kg->oiio->textures[id].handle, (OIIO::TextureSystem::Perthread*)kg->oiio_tdata, options, x, y, ds.dx, ds.dy, dt.dx, dt.dy, 4, (float*)&r);
 		if(!success) {
 			(void) kg->oiio->tex_sys->geterror();
@@ -282,13 +291,21 @@ ccl_device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, int
 		if(path_flag & NEAREST_LOOKUP_PATHS) {
 			options.interpmode = OIIO::TextureOpt::InterpClosest;
 			options.mipmode = OIIO::TextureOpt::MipModeOneLevel;
-			if(path_flag & BLUR_LOOKUP_PATHS)
-			   options.sblur = options.tblur = 1.f/64.f;
 		}
 		else {
 			options.interpmode = kg->oiio->textures[id].interpolation;
 			options.mipmode = OIIO::TextureOpt::MipModeTrilinear;
 		}
+		
+		if(path_flag & DIFFUSE_BLUR_PATHS) {
+			options.sblur = options.tblur = kg->oiio->diffuse_blur;
+		} else if(path_flag & PATH_RAY_GLOSSY) {
+			options.sblur = options.tblur = kg->oiio->glossy_blur;
+		}
+		else {
+			options.sblur = options.tblur = 0.0f;
+		}
+		
 		bool success = kg->oiio->tex_sys->environment (kg->oiio->textures[id].handle, (OIIO::TextureSystem::Perthread*)kg->oiio_tdata, options,
 													   Imath::V3f(co.x, -co.y, co.z), Imath::V3f(dRdx.x, -dRdx.y, dRdx.z),
 													   Imath::V3f(dRdy.x, -dRdy.y, dRdy.z), use_alpha ? 4 : 3, (float*)&f);
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 8b6ded28210..70012e491a8 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -738,7 +738,7 @@ void ImageManager::device_load_image(Device *device,
 
 	if(oiio_texture_system && !img->builtin_data) {
 		/* Generate a mip mapped tile image file */
-		if(scene->params.texture_auto_convert) {
+		if(scene->params.texture.auto_convert) {
 			make_tx(img, progress);
 		}
 		/* When using OIIO directly from SVM, store the TextureHandle
diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h
index bedd5dc9752..cdb462918eb 100644
--- a/intern/cycles/render/scene.h
+++ b/intern/cycles/render/scene.h
@@ -127,6 +127,37 @@ public:
 	DeviceScene(Device *device);
 };
 
+/* Texture Cache Params */
+class TextureCacheParams {
+public:
+	TextureCacheParams() : 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) { }
+	
+	bool modified(const TextureCacheParams& params)
+	{
+		return !(cache_size == params.cache_size
+				 && tile_size == params.tile_size
+				 && diffuse_blur == params.diffuse_blur
+				 && glossy_blur == params.glossy_blur
+				 && auto_convert == params.auto_convert
+				 && accept_unmipped == params.accept_unmipped
+				 && accept_untiled == params.accept_untiled
+				 && auto_tile == params.auto_tile
+				 && auto_mip == params.auto_mip);
+	}
+	
+	int cache_size;
+	int tile_size;
+	float diffuse_blur;
+	float glossy_blur;
+	bool auto_convert;
+	bool accept_unmipped;
+	bool accept_untiled;
+	bool auto_tile;
+	bool auto_mip;
+};
+
 /* Scene Parameters */
 
 class SceneParams {
@@ -168,13 +199,7 @@ public:
 
 	bool persistent_data;
 	int texture_limit;
-	int texture_cache_size;
-	bool texture_auto_convert;
-	bool texture_accept_unmipped;
-	bool texture_accept_untiled;
-	bool texture_auto_tile;
-	bool texture_auto_mip;
-	int texture_tile_size;
+	TextureCacheParams texture;
 
 	SceneParams()
 	{
@@ -186,13 +211,6 @@ public:
 		num_bvh_time_steps = 0;
 		persistent_data = false;
 		texture_limit = 0;
-		texture_cache_size = 1024;
-		texture_auto_convert = true;
-		texture_accept_unmipped = true;
-		texture_accept_untiled = true;
-		texture_auto_tile = true;
-		texture_auto_mip = true;
-		texture_tile_size = 64;
 	}
 
 	bool modified(const SceneParams& params)
@@ -204,13 +222,7 @@ public:
 		&& num_bvh_time_steps == params.num_bvh_time_steps
 		&& persistent_data == params.persistent_data
 		&& texture_limit == params.texture_limit)
-		&& texture_cache_size == params.texture_cache_size
-		&& texture_auto_convert == params.texture_auto_convert
-		&& texture_accept_unmipped == params.texture_accept_unmipped
-		&& texture_accept_untiled == params.texture_accept_untiled
-		&& texture_auto_tile == params.texture_auto_tile
-		&& texture_auto_mip == params.texture_auto_mip
-		&& texture_tile_size == params.texture_tile_size; }
+		&& !texture.modified(params.texture); }
 };
 
 /* Scene */
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index c3576f12052..5f8739da1cd 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -483,21 +483,23 @@ void ShaderManager::device_update_common(Device *device,
 	if(scene->shaders.size() == 0)
 		return;
 	
-	if(device->info.type == DEVICE_CPU && (scene->params.shadingsystem == SHADINGSYSTEM_OSL || scene->params.texture_cache_size > 0)) {
+	if(device->info.type == DEVICE_CPU && (scene->params.shadingsystem == SHADINGSYSTEM_OSL || scene->params.texture.cache_size > 0)) {
 		/* set texture system */
 		scene->image_manager->set_oiio_texture_system((void*)ts);
 		OIIOGlobals *oiio_globals = (OIIOGlobals*)device->oiio_memory();
 		if(oiio_globals) {
 			/* update attributes from scene parms */
-			ts->attribute("autotile", scene->p

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list