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 <lukasstockner97>2019-12-04 21:57:28 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-12-10 22:44:46 +0300
commite760972221e68d3c81f2ee3687cc71836dde8ae9 (patch)
treeb1a2efbb17c05a429e4509d336a1eb14c73cfb8c /intern/cycles/kernel/svm
parent35b5888b157d05d378df3acc899d28856a9eb9a4 (diff)
Cycles: support for custom shader AOVs
Custom render passes are added in the Shader AOVs panel in the view layer settings, with a name and data type. In shader nodes, an AOV Output node is then used to output either a value or color to the pass. Arbitrary names can be used for these passes, as long as they don't conflict with built-in passes that are enabled. The AOV Output node can be used in both material and world shader nodes. Implemented by Lukas, with tweaks by Brecht. Differential Revision: https://developer.blender.org/D4837
Diffstat (limited to 'intern/cycles/kernel/svm')
-rw-r--r--intern/cycles/kernel/svm/svm.h13
-rw-r--r--intern/cycles/kernel/svm/svm_aov.h49
-rw-r--r--intern/cycles/kernel/svm/svm_types.h3
3 files changed, 65 insertions, 0 deletions
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h
index 18f086d6726..c4d7164a4d8 100644
--- a/intern/cycles/kernel/svm/svm.h
+++ b/intern/cycles/kernel/svm/svm.h
@@ -164,6 +164,7 @@ CCL_NAMESPACE_END
#include "kernel/svm/svm_math_util.h"
#include "kernel/svm/svm_mapping_util.h"
+#include "kernel/svm/svm_aov.h"
#include "kernel/svm/svm_attribute.h"
#include "kernel/svm/svm_gradient.h"
#include "kernel/svm/svm_blackbody.h"
@@ -218,6 +219,7 @@ CCL_NAMESPACE_BEGIN
ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg,
ShaderData *sd,
ccl_addr_space PathState *state,
+ ccl_global float *buffer,
ShaderType type,
int path_flag)
{
@@ -467,6 +469,17 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg,
case NODE_IES:
svm_node_ies(kg, sd, stack, node, &offset);
break;
+ case NODE_AOV_START:
+ if (!svm_node_aov_check(state, buffer)) {
+ return;
+ }
+ break;
+ case NODE_AOV_COLOR:
+ svm_node_aov_color(kg, sd, stack, node, buffer);
+ break;
+ case NODE_AOV_VALUE:
+ svm_node_aov_value(kg, sd, stack, node, buffer);
+ break;
# endif /* __EXTRA_NODES__ */
#endif /* NODES_GROUP(NODE_GROUP_LEVEL_2) */
diff --git a/intern/cycles/kernel/svm/svm_aov.h b/intern/cycles/kernel/svm/svm_aov.h
new file mode 100644
index 00000000000..899e466d099
--- /dev/null
+++ b/intern/cycles/kernel/svm/svm_aov.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011-2013 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+CCL_NAMESPACE_BEGIN
+
+ccl_device_inline bool svm_node_aov_check(ccl_addr_space PathState *state,
+ ccl_global float *buffer)
+{
+ int path_flag = state->flag;
+
+ bool is_primary = (path_flag & PATH_RAY_CAMERA) && (!(path_flag & PATH_RAY_SINGLE_PASS_DONE));
+
+ return ((buffer != NULL) && is_primary);
+}
+
+ccl_device void svm_node_aov_color(
+ KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ccl_global float *buffer)
+{
+ float3 val = stack_load_float3(stack, node.y);
+
+ if (buffer) {
+ kernel_write_pass_float4(buffer + kernel_data.film.pass_aov_color + 4 * node.z,
+ make_float4(val.x, val.y, val.z, 1.0f));
+ }
+}
+
+ccl_device void svm_node_aov_value(
+ KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ccl_global float *buffer)
+{
+ float val = stack_load_float(stack, node.y);
+
+ if (buffer) {
+ kernel_write_pass_float(buffer + kernel_data.film.pass_aov_value + node.z, val);
+ }
+}
+CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index 040e7c6a0f8..8dbb147e76a 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -150,6 +150,9 @@ typedef enum ShaderNodeType {
NODE_VERTEX_COLOR,
NODE_VERTEX_COLOR_BUMP_DX,
NODE_VERTEX_COLOR_BUMP_DY,
+ NODE_AOV_START,
+ NODE_AOV_VALUE,
+ NODE_AOV_COLOR,
} ShaderNodeType;
typedef enum NodeAttributeType {