Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2019-12-16 14:53:03 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2019-12-16 14:53:03 +0300
commit8d16dc029e6c52b16666b4edfafa66794d64b1a4 (patch)
treea962abff145e09c26fa311ee68246b0fbb463bbe
parentbbc97fc533d03a7242d3172a6780794a28e20e7e (diff)
Fix T72474: UDIM breaks box mapping in Cycles
The ImageTextureNode incorrectly used the tile slot encoding for box- mapped textures as well. Since box-mapping always generates UVs that lie in the 1001 tile, there's no need to support tiles here.
-rw-r--r--intern/cycles/render/nodes.cpp63
1 files changed, 36 insertions, 27 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index cd990393823..5af22e0c2c3 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -293,6 +293,14 @@ ShaderNode *ImageTextureNode::clone() const
void ImageTextureNode::cull_tiles(Scene *scene, ShaderGraph *graph)
{
+ /* Box projection computes its own UVs that always lie in the
+ * 1001 tile, so there's no point in loading any others. */
+ if (projection == NODE_IMAGE_PROJ_BOX) {
+ tiles.clear();
+ tiles.push_back(1001);
+ return;
+ }
+
if (!scene->params.background) {
/* During interactive renders, all tiles are loaded.
* While we could support updating this when UVs change, that could lead
@@ -408,15 +416,6 @@ void ImageTextureNode::compile(SVMCompiler &compiler)
}
if (has_image) {
- /* If there only is one image (a very common case), we encode it as a negative value. */
- int num_nodes;
- if (slots.size() == 1) {
- num_nodes = -slots[0];
- }
- else {
- num_nodes = divide_up(slots.size(), 2);
- }
-
int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
uint flags = 0;
@@ -434,6 +433,15 @@ void ImageTextureNode::compile(SVMCompiler &compiler)
}
if (projection != NODE_IMAGE_PROJ_BOX) {
+ /* If there only is one image (a very common case), we encode it as a negative value. */
+ int num_nodes;
+ if (slots.size() == 1) {
+ num_nodes = -slots[0];
+ }
+ else {
+ num_nodes = divide_up(slots.size(), 2);
+ }
+
compiler.add_node(NODE_TEX_IMAGE,
num_nodes,
compiler.encode_uchar4(vector_offset,
@@ -441,10 +449,28 @@ void ImageTextureNode::compile(SVMCompiler &compiler)
compiler.stack_assign_if_linked(alpha_out),
flags),
projection);
+
+ if (num_nodes > 0) {
+ for (int i = 0; i < num_nodes; i++) {
+ int4 node;
+ node.x = tiles[2 * i];
+ node.y = slots[2 * i];
+ if (2 * i + 1 < slots.size()) {
+ node.z = tiles[2 * i + 1];
+ node.w = slots[2 * i + 1];
+ }
+ else {
+ node.z = -1;
+ node.w = -1;
+ }
+ compiler.add_node(node.x, node.y, node.z, node.w);
+ }
+ }
}
else {
+ assert(slots.size() == 1);
compiler.add_node(NODE_TEX_IMAGE_BOX,
- num_nodes,
+ slots[0],
compiler.encode_uchar4(vector_offset,
compiler.stack_assign_if_linked(color_out),
compiler.stack_assign_if_linked(alpha_out),
@@ -452,23 +478,6 @@ void ImageTextureNode::compile(SVMCompiler &compiler)
__float_as_int(projection_blend));
}
- if (num_nodes > 0) {
- for (int i = 0; i < num_nodes; i++) {
- int4 node;
- node.x = tiles[2 * i];
- node.y = slots[2 * i];
- if (2 * i + 1 < slots.size()) {
- node.z = tiles[2 * i + 1];
- node.w = slots[2 * i + 1];
- }
- else {
- node.z = -1;
- node.w = -1;
- }
- compiler.add_node(node.x, node.y, node.z, node.w);
- }
- }
-
tex_mapping.compile_end(compiler, vector_in, vector_offset);
}
else {