Skip to content

Commit 1d383ea

Browse files
committed
removed bug so that seams get added to original texture
1 parent c2d8c1c commit 1d383ea

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

__init__.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ def register():
6565

6666
__author__ = "yeus <Thomas.Meschede@web.de>"
6767
__status__ = "alpha"
68-
__version__ = "0.9.1"
68+
__version__ = "0.9.2"
6969
__date__ = "2020 Feb 29th"
7070

7171
#TODO: fill this out
7272
bl_info = {
7373
"name": "Syntexmex Blender",
7474
"author": "yeus <Thomas.Meschede@web.de",
75-
"version": (0, 9, 1),
75+
"version": (0, 9, 2),
7676
"blender": (2, 82, 0),
7777
"location": "View3D > Properties > syntexmex",
7878
"description": "Generate example-based seamless textures",
@@ -168,7 +168,8 @@ def run_algorithm(self, context):
168168

169169
ta_width,ta_height=self.target.size
170170
self.ta_map = bpy.data.images.new("ta_map",ta_width,ta_height,
171-
alpha=False,float_buffer=True)
171+
alpha=False,float_buffer=True,
172+
is_data=True)
172173
#BlendDataImages.new(name, width, height, alpha=False, float_buffer=False, stereo3d=False, is_data=False, tiled=False)
173174

174175
examplebuf, targetbuf = up.init_texture_buffers(example_image,
@@ -550,7 +551,8 @@ def execute(self, context):
550551
f"{self.source_material},{self.source_image}")
551552

552553
synthmap = up.blimage2array(bpy.data.images[self.synth_map])[...,:3]
553-
554+
mask = np.all(synthmap[:,:,:2]>=0,axis=2)
555+
554556
#scn = context.scene
555557
obj = context.active_object
556558

@@ -562,10 +564,21 @@ def execute(self, context):
562564
#TODO: make "original" texture permanently saved
563565
imgnodes = [n for n in mat.node_tree.nodes if n.type=='TEX_IMAGE']
564566
images = [up.blimage2array(n.image)[...,:3] for n in imgnodes]
565-
synth_images = [us.normalized_synthmap(synthmap,
567+
synth_images = [us.reconstruct_synthmap(synthmap,
566568
img,
567569
mode='normalized')
568570
for img in images]
571+
572+
#import ipdb; ipdb.set_trace() # BREAKPOINT
573+
if not np.all(mask): #only do this if we need a masked copy
574+
logger.info("copying seams to original textures")
575+
scaled_images = [us.skimage.transform.resize(
576+
img, synthmap.shape[:2])
577+
for img in images]
578+
synth_images = [us.ts.copy_img(img,simg,mask=mask)
579+
for img, simg in zip(scaled_images,synth_images)]
580+
581+
569582

570583
#functionality not implemented right now
571584
#elif self.source_image is not None:
@@ -579,6 +592,7 @@ def execute(self, context):
579592
synthmap.shape[1],synthmap.shape[0],
580593
alpha=False,float_buffer=node.image.is_float,
581594
is_data=is_data)
595+
582596
#add alpha channel and upload into blender
583597
new_img.pixels[:] = np.dstack((simg,np.ones(simg.shape[:2]))).flatten()
584598

0 commit comments

Comments
 (0)