@@ -1157,22 +1157,46 @@ def join_scene(self) -> "TexturesUV":
1157
1157
new_uvs = torch .Tensor (new_uvs )
1158
1158
1159
1159
# If align_corners is True, then an index of x (where x is in
1160
- # the range 0 .. map_.shape[]-1) in one of the input maps
1161
- # was hit by a u of x/(map_.shape[]-1).
1162
- # That x is located at the index loc[] + x in the single_map, and
1163
- # to hit that we need u to equal (loc[] + x) / (total_size[]-1)
1160
+ # the range 0 .. map_.shape[1 ]-1) in one of the input maps
1161
+ # was hit by a u of x/(map_.shape[1 ]-1).
1162
+ # That x is located at the index loc[1 ] + x in the single_map, and
1163
+ # to hit that we need u to equal (loc[1 ] + x) / (total_size[1 ]-1)
1164
1164
# so the old u should be mapped to
1165
- # { u*(map_.shape[]-1) + loc[] } / (total_size[]-1)
1165
+ # { u*(map_.shape[1]-1) + loc[1] } / (total_size[1]-1)
1166
+
1167
+ # Also, an index of y (where y is in
1168
+ # the range 0 .. map_.shape[0]-1) in one of the input maps
1169
+ # was hit by a v of 1 - y/(map_.shape[0]-1).
1170
+ # That y is located at the index loc[0] + y in the single_map, and
1171
+ # to hit that we need v to equal 1 - (loc[0] + y) / (total_size[0]-1)
1172
+ # so the old v should be mapped to
1173
+ # 1 - { (1-v)*(map_.shape[0]-1) + loc[0] } / (total_size[0]-1)
1174
+ # =
1175
+ # { v*(map_.shape[0]-1) + total_size[0] - map.shape[0] - loc[0] }
1176
+ # / (total_size[0]-1)
1166
1177
1167
1178
# If align_corners is False, then an index of x (where x is in
1168
- # the range 1 .. map_.shape[]-2) in one of the input maps
1169
- # was hit by a u of (x+0.5)/(map_.shape[]).
1170
- # That x is located at the index loc[] + 1 + x in the single_map,
1179
+ # the range 1 .. map_.shape[1 ]-2) in one of the input maps
1180
+ # was hit by a u of (x+0.5)/(map_.shape[1 ]).
1181
+ # That x is located at the index loc[1 ] + 1 + x in the single_map,
1171
1182
# (where the 1 is for the border)
1172
- # and to hit that we need u to equal (loc[] + 1 + x + 0.5) / (total_size[])
1183
+ # and to hit that we need u to equal (loc[1 ] + 1 + x + 0.5) / (total_size[1 ])
1173
1184
# so the old u should be mapped to
1174
- # { loc[] + 1 + u*map_.shape[]-0.5 + 0.5 } / (total_size[])
1175
- # = { loc[] + 1 + u*map_.shape[] } / (total_size[])
1185
+ # { loc[1] + 1 + u*map_.shape[1]-0.5 + 0.5 } / (total_size[1])
1186
+ # = { loc[1] + 1 + u*map_.shape[1] } / (total_size[1])
1187
+
1188
+ # Also, an index of y (where y is in
1189
+ # the range 1 .. map_.shape[0]-2) in one of the input maps
1190
+ # was hit by a v of 1 - (y+0.5)/(map_.shape[0]).
1191
+ # That y is located at the index loc[0] + 1 + y in the single_map,
1192
+ # (where the 1 is for the border)
1193
+ # and to hit that we need v to equal 1 - (loc[0] + 1 + y + 0.5) / (total_size[0])
1194
+ # so the old v should be mapped to
1195
+ # 1 - { loc[0] + 1 + (1-v)*map_.shape[0]-0.5 + 0.5 } / (total_size[0])
1196
+ # = { total_size[0] - loc[0] -1 - (1-v)*map_.shape[0] }
1197
+ # / (total_size[0])
1198
+ # = { total_size[0] - loc[0] - map.shape[0] - 1 + v*map_.shape[0] }
1199
+ # / (total_size[0])
1176
1200
1177
1201
# We change the y's in new_uvs for the scaling of height,
1178
1202
# and the x's for the scaling of width.
@@ -1184,7 +1208,9 @@ def join_scene(self) -> "TexturesUV":
1184
1208
denom_y = merging_plan .total_size [1 ] - one_if_align
1185
1209
scale_y = y_shape - one_if_align
1186
1210
new_uvs [:, 1 ] *= scale_x / denom_x
1187
- new_uvs [:, 1 ] += (loc .x + one_if_not_align ) / denom_x
1211
+ new_uvs [:, 1 ] += (
1212
+ merging_plan .total_size [0 ] - x_shape - loc .x - one_if_not_align
1213
+ ) / denom_x
1188
1214
new_uvs [:, 0 ] *= scale_y / denom_y
1189
1215
new_uvs [:, 0 ] += (loc .y + one_if_not_align ) / denom_y
1190
1216
0 commit comments