[Bf-blender-cvs] [89f3837d68] master: Displace modifier: Use special version of texture sampling

Sergey Sharybin noreply at git.blender.org
Mon Feb 6 12:37:36 CET 2017


Commit: 89f3837d687c5b685fbea5e7e71242287a735b76
Author: Sergey Sharybin
Date:   Mon Feb 6 12:33:37 2017 +0100
Branches: master
https://developer.blender.org/rB89f3837d687c5b685fbea5e7e71242287a735b76

Displace modifier: Use special version of texture sampling

This version will give less spin locks and now well-tested by render engines.

This should reduce amount of threading overhead when having multiple objects
with displace modifier enabled.

In the future this will also help us threading the modifier.

There are more modifiers which could benefit from this, but let's first
investigate the new behavior with one of them.

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

M	source/blender/modifiers/intern/MOD_displace.c

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

diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 08d118a202..48e5d34288 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -42,6 +42,7 @@
 #include "BKE_cdderivedmesh.h"
 #include "BKE_library.h"
 #include "BKE_library_query.h"
+#include "BKE_image.h"
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_texture.h"
@@ -216,6 +217,7 @@ static void displaceModifier_do(
 	float (*vert_clnors)[3] = NULL;
 	float local_mat[4][4];
 	const bool use_global_direction = dmd->space == MOD_DISP_SPACE_GLOBAL;
+	struct ImagePool *pool = NULL;
 
 	if (!dmd->texture && dmd->direction == MOD_DISP_DIR_RGB_XYZ) return;
 	if (dmd->strength == 0.0f) return;
@@ -259,6 +261,10 @@ static void displaceModifier_do(
 		copy_m4_m4(local_mat, ob->obmat);
 	}
 
+	if (dmd->texture != NULL) {
+		pool = BKE_image_pool_new();
+	}
+
 	for (i = 0; i < numVerts; i++) {
 		TexResult texres;
 		float strength = dmd->strength;
@@ -272,7 +278,7 @@ static void displaceModifier_do(
 
 		if (dmd->texture) {
 			texres.nor = NULL;
-			BKE_texture_get_value(dmd->modifier.scene, dmd->texture, tex_co[i], &texres, false);
+			BKE_texture_get_value_ex(dmd->modifier.scene, dmd->texture, tex_co[i], &texres, pool, false);
 			delta = texres.tin - dmd->midlevel;
 		}
 		else {
@@ -336,6 +342,10 @@ static void displaceModifier_do(
 		}
 	}
 
+	if (pool != NULL) {
+		BKE_image_pool_free(pool);
+	}
+
 	if (tex_co) {
 		MEM_freeN(tex_co);
 	}




More information about the Bf-blender-cvs mailing list