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:
authorPeter Kim <pk15950@gmail.com>2022-09-08 07:00:12 +0300
committerPeter Kim <pk15950@gmail.com>2022-09-08 07:00:12 +0300
commit00dcfdf916c69672210b006e62d966f1bc2fbeb7 (patch)
tree0cbb1b91fe26c750197126085b74224a795a103c /intern/cycles/scene/shader_nodes.cpp
parenta39532670f6b668da7be5810fb1f844b82feeba3 (diff)
parentd5934974219135102f364f57c45a8b1465e2b8d9 (diff)
Merge branch 'master' into xr-devxr-dev
Diffstat (limited to 'intern/cycles/scene/shader_nodes.cpp')
-rw-r--r--intern/cycles/scene/shader_nodes.cpp262
1 files changed, 251 insertions, 11 deletions
diff --git a/intern/cycles/scene/shader_nodes.cpp b/intern/cycles/scene/shader_nodes.cpp
index 3b58556f601..a9cd453947b 100644
--- a/intern/cycles/scene/shader_nodes.cpp
+++ b/intern/cycles/scene/shader_nodes.cpp
@@ -2391,7 +2391,7 @@ void GlossyBsdfNode::simplify_settings(Scene *scene)
* NOTE: Keep the epsilon in sync with kernel!
*/
if (!roughness_input->link && roughness <= 1e-4f) {
- VLOG(3) << "Using sharp glossy BSDF.";
+ VLOG_DEBUG << "Using sharp glossy BSDF.";
distribution = CLOSURE_BSDF_REFLECTION_ID;
}
}
@@ -2400,7 +2400,7 @@ void GlossyBsdfNode::simplify_settings(Scene *scene)
* benefit from closure blur to remove unwanted noise.
*/
if (roughness_input->link == NULL && distribution == CLOSURE_BSDF_REFLECTION_ID) {
- VLOG(3) << "Using GGX glossy with filter glossy.";
+ VLOG_DEBUG << "Using GGX glossy with filter glossy.";
distribution = CLOSURE_BSDF_MICROFACET_GGX_ID;
roughness = 0.0f;
}
@@ -2484,7 +2484,7 @@ void GlassBsdfNode::simplify_settings(Scene *scene)
* NOTE: Keep the epsilon in sync with kernel!
*/
if (!roughness_input->link && roughness <= 1e-4f) {
- VLOG(3) << "Using sharp glass BSDF.";
+ VLOG_DEBUG << "Using sharp glass BSDF.";
distribution = CLOSURE_BSDF_SHARP_GLASS_ID;
}
}
@@ -2493,7 +2493,7 @@ void GlassBsdfNode::simplify_settings(Scene *scene)
* benefit from closure blur to remove unwanted noise.
*/
if (roughness_input->link == NULL && distribution == CLOSURE_BSDF_SHARP_GLASS_ID) {
- VLOG(3) << "Using GGX glass with filter glossy.";
+ VLOG_DEBUG << "Using GGX glass with filter glossy.";
distribution = CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID;
roughness = 0.0f;
}
@@ -2577,7 +2577,7 @@ void RefractionBsdfNode::simplify_settings(Scene *scene)
* NOTE: Keep the epsilon in sync with kernel!
*/
if (!roughness_input->link && roughness <= 1e-4f) {
- VLOG(3) << "Using sharp refraction BSDF.";
+ VLOG_DEBUG << "Using sharp refraction BSDF.";
distribution = CLOSURE_BSDF_REFRACTION_ID;
}
}
@@ -2586,7 +2586,7 @@ void RefractionBsdfNode::simplify_settings(Scene *scene)
* benefit from closure blur to remove unwanted noise.
*/
if (roughness_input->link == NULL && distribution == CLOSURE_BSDF_REFRACTION_ID) {
- VLOG(3) << "Using GGX refraction with filter glossy.";
+ VLOG_DEBUG << "Using GGX refraction with filter glossy.";
distribution = CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
roughness = 0.0f;
}
@@ -4950,7 +4950,7 @@ NODE_DEFINE(MixNode)
type_enum.insert("hue", NODE_MIX_HUE);
type_enum.insert("saturation", NODE_MIX_SAT);
type_enum.insert("value", NODE_MIX_VAL);
- type_enum.insert("color", NODE_MIX_COLOR);
+ type_enum.insert("color", NODE_MIX_COL);
type_enum.insert("soft_light", NODE_MIX_SOFT);
type_enum.insert("linear_light", NODE_MIX_LINEAR);
SOCKET_ENUM(mix_type, "Type", type_enum, NODE_MIX_BLEND);
@@ -4999,13 +4999,253 @@ void MixNode::compile(OSLCompiler &compiler)
void MixNode::constant_fold(const ConstantFolder &folder)
{
if (folder.all_inputs_constant()) {
- folder.make_constant_clamp(svm_mix(mix_type, fac, color1, color2), use_clamp);
+ folder.make_constant_clamp(svm_mix_clamped_factor(mix_type, fac, color1, color2), use_clamp);
}
else {
folder.fold_mix(mix_type, use_clamp);
}
}
+/* Mix Color */
+
+NODE_DEFINE(MixColorNode)
+{
+ NodeType *type = NodeType::add("mix_color", create, NodeType::SHADER);
+
+ static NodeEnum type_enum;
+ type_enum.insert("mix", NODE_MIX_BLEND);
+ type_enum.insert("add", NODE_MIX_ADD);
+ type_enum.insert("multiply", NODE_MIX_MUL);
+ type_enum.insert("screen", NODE_MIX_SCREEN);
+ type_enum.insert("overlay", NODE_MIX_OVERLAY);
+ type_enum.insert("subtract", NODE_MIX_SUB);
+ type_enum.insert("divide", NODE_MIX_DIV);
+ type_enum.insert("difference", NODE_MIX_DIFF);
+ type_enum.insert("darken", NODE_MIX_DARK);
+ type_enum.insert("lighten", NODE_MIX_LIGHT);
+ type_enum.insert("dodge", NODE_MIX_DODGE);
+ type_enum.insert("burn", NODE_MIX_BURN);
+ type_enum.insert("hue", NODE_MIX_HUE);
+ type_enum.insert("saturation", NODE_MIX_SAT);
+ type_enum.insert("value", NODE_MIX_VAL);
+ type_enum.insert("color", NODE_MIX_COL);
+ type_enum.insert("soft_light", NODE_MIX_SOFT);
+ type_enum.insert("linear_light", NODE_MIX_LINEAR);
+ SOCKET_ENUM(blend_type, "Type", type_enum, NODE_MIX_BLEND);
+
+ SOCKET_IN_FLOAT(fac, "Factor", 0.5f);
+ SOCKET_IN_COLOR(a, "A", zero_float3());
+ SOCKET_IN_COLOR(b, "B", zero_float3());
+ SOCKET_BOOLEAN(use_clamp_result, "Use Clamp Result", false);
+ SOCKET_BOOLEAN(use_clamp, "Use Clamp", true);
+
+ SOCKET_OUT_COLOR(result, "Result");
+
+ return type;
+}
+
+MixColorNode::MixColorNode() : ShaderNode(get_node_type())
+{
+}
+
+void MixColorNode::compile(SVMCompiler &compiler)
+{
+ ShaderInput *fac_in = input("Factor");
+ ShaderInput *a_in = input("A");
+ ShaderInput *b_in = input("B");
+ ShaderOutput *result_out = output("Result");
+
+ int fac_in_stack_offset = compiler.stack_assign(fac_in);
+ int a_in_stack_offset = compiler.stack_assign(a_in);
+ int b_in_stack_offset = compiler.stack_assign(b_in);
+
+ compiler.add_node(
+ NODE_MIX_COLOR,
+ compiler.encode_uchar4(use_clamp, blend_type, use_clamp_result),
+ compiler.encode_uchar4(fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
+ compiler.stack_assign(result_out));
+}
+
+void MixColorNode::compile(OSLCompiler &compiler)
+{
+ compiler.parameter(this, "blend_type");
+ compiler.parameter(this, "use_clamp");
+ compiler.parameter(this, "use_clamp_result");
+ compiler.add(this, "node_mix_color");
+}
+
+void MixColorNode::constant_fold(const ConstantFolder &folder)
+{
+ if (folder.all_inputs_constant()) {
+ if (use_clamp) {
+ fac = clamp(fac, 0.0f, 1.0f);
+ }
+ folder.make_constant_clamp(svm_mix(blend_type, fac, a, b), use_clamp_result);
+ }
+ else {
+ folder.fold_mix_color(blend_type, use_clamp, use_clamp_result);
+ }
+}
+
+/* Mix Float */
+
+NODE_DEFINE(MixFloatNode)
+{
+ NodeType *type = NodeType::add("mix_float", create, NodeType::SHADER);
+
+ SOCKET_IN_FLOAT(fac, "Factor", 0.5f);
+ SOCKET_IN_FLOAT(a, "A", 0.0f);
+ SOCKET_IN_FLOAT(b, "B", 0.0f);
+ SOCKET_BOOLEAN(use_clamp, "Use Clamp", true);
+ SOCKET_OUT_FLOAT(result, "Result");
+
+ return type;
+}
+
+MixFloatNode::MixFloatNode() : ShaderNode(get_node_type())
+{
+}
+
+void MixFloatNode::compile(SVMCompiler &compiler)
+{
+ ShaderInput *fac_in = input("Factor");
+ ShaderInput *a_in = input("A");
+ ShaderInput *b_in = input("B");
+ ShaderOutput *result_out = output("Result");
+
+ int fac_in_stack_offset = compiler.stack_assign(fac_in);
+ int a_in_stack_offset = compiler.stack_assign(a_in);
+ int b_in_stack_offset = compiler.stack_assign(b_in);
+
+ compiler.add_node(
+ NODE_MIX_FLOAT,
+ use_clamp,
+ compiler.encode_uchar4(fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
+ compiler.stack_assign(result_out));
+}
+
+void MixFloatNode::compile(OSLCompiler &compiler)
+{
+ compiler.parameter(this, "use_clamp");
+ compiler.add(this, "node_mix_float");
+}
+
+void MixFloatNode::constant_fold(const ConstantFolder &folder)
+{
+ if (folder.all_inputs_constant()) {
+ if (use_clamp) {
+ fac = clamp(fac, 0.0f, 1.0f);
+ }
+ folder.make_constant(a * (1 - fac) + b * fac);
+ }
+}
+
+/* Mix Vector */
+
+NODE_DEFINE(MixVectorNode)
+{
+ NodeType *type = NodeType::add("mix_vector", create, NodeType::SHADER);
+
+ SOCKET_IN_FLOAT(fac, "Factor", 0.5f);
+ SOCKET_IN_VECTOR(a, "A", zero_float3());
+ SOCKET_IN_VECTOR(b, "B", zero_float3());
+ SOCKET_BOOLEAN(use_clamp, "Use Clamp", true);
+
+ SOCKET_OUT_VECTOR(result, "Result");
+
+ return type;
+}
+
+MixVectorNode::MixVectorNode() : ShaderNode(get_node_type())
+{
+}
+
+void MixVectorNode::compile(SVMCompiler &compiler)
+{
+ ShaderInput *fac_in = input("Factor");
+ ShaderInput *a_in = input("A");
+ ShaderInput *b_in = input("B");
+ ShaderOutput *result_out = output("Result");
+
+ int fac_in_stack_offset = compiler.stack_assign(fac_in);
+ int a_in_stack_offset = compiler.stack_assign(a_in);
+ int b_in_stack_offset = compiler.stack_assign(b_in);
+
+ compiler.add_node(
+ NODE_MIX_VECTOR,
+ compiler.encode_uchar4(use_clamp, fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
+ compiler.stack_assign(result_out));
+}
+
+void MixVectorNode::compile(OSLCompiler &compiler)
+{
+ compiler.parameter(this, "use_clamp");
+ compiler.add(this, "node_mix_vector");
+}
+
+void MixVectorNode::constant_fold(const ConstantFolder &folder)
+{
+ if (folder.all_inputs_constant()) {
+ if (use_clamp) {
+ fac = clamp(fac, 0.0f, 1.0f);
+ }
+ folder.make_constant(a * (one_float3() - fac) + b * fac);
+ }
+}
+
+/* Mix Vector Non Uniform */
+
+NODE_DEFINE(MixVectorNonUniformNode)
+{
+ NodeType *type = NodeType::add("mix_vector_non_uniform", create, NodeType::SHADER);
+
+ SOCKET_IN_VECTOR(fac, "Factor", make_float3(0.5f, 0.5f, 0.5f));
+ SOCKET_IN_VECTOR(a, "A", zero_float3());
+ SOCKET_IN_VECTOR(b, "B", zero_float3());
+ SOCKET_BOOLEAN(use_clamp, "Use Clamp", true);
+
+ SOCKET_OUT_VECTOR(result, "Result");
+
+ return type;
+}
+
+MixVectorNonUniformNode::MixVectorNonUniformNode() : ShaderNode(get_node_type())
+{
+}
+
+void MixVectorNonUniformNode::compile(SVMCompiler &compiler)
+{
+ ShaderInput *fac_in = input("Factor");
+ ShaderInput *a_in = input("A");
+ ShaderInput *b_in = input("B");
+ ShaderOutput *result_out = output("Result");
+
+ int fac_in_stack_offset = compiler.stack_assign(fac_in);
+ int a_in_stack_offset = compiler.stack_assign(a_in);
+ int b_in_stack_offset = compiler.stack_assign(b_in);
+
+ compiler.add_node(
+ NODE_MIX_VECTOR_NON_UNIFORM,
+ compiler.encode_uchar4(use_clamp, fac_in_stack_offset, a_in_stack_offset, b_in_stack_offset),
+ compiler.stack_assign(result_out));
+}
+
+void MixVectorNonUniformNode::compile(OSLCompiler &compiler)
+{
+ compiler.parameter(this, "use_clamp");
+ compiler.add(this, "node_mix_vector_non_uniform");
+}
+
+void MixVectorNonUniformNode::constant_fold(const ConstantFolder &folder)
+{
+ if (folder.all_inputs_constant()) {
+ if (use_clamp) {
+ fac = saturate(fac);
+ }
+ folder.make_constant(a * (one_float3() - fac) + b * fac);
+ }
+}
+
/* Combine Color */
NODE_DEFINE(CombineColorNode)
@@ -6671,7 +6911,7 @@ void CurvesNode::compile(SVMCompiler &compiler,
ShaderInput *fac_in = input("Fac");
- compiler.add_node(type,
+ compiler.add_node(ShaderNodeType(type),
compiler.encode_uchar4(compiler.stack_assign(fac_in),
compiler.stack_assign(value_in),
compiler.stack_assign(value_out),
@@ -6736,7 +6976,7 @@ void RGBCurvesNode::constant_fold(const ConstantFolder &folder)
void RGBCurvesNode::compile(SVMCompiler &compiler)
{
- CurvesNode::compile(compiler, NODE_RGB_CURVES, input("Color"), output("Color"));
+ CurvesNode::compile(compiler, NODE_CURVES, input("Color"), output("Color"));
}
void RGBCurvesNode::compile(OSLCompiler &compiler)
@@ -6774,7 +7014,7 @@ void VectorCurvesNode::constant_fold(const ConstantFolder &folder)
void VectorCurvesNode::compile(SVMCompiler &compiler)
{
- CurvesNode::compile(compiler, NODE_VECTOR_CURVES, input("Vector"), output("Vector"));
+ CurvesNode::compile(compiler, NODE_CURVES, input("Vector"), output("Vector"));
}
void VectorCurvesNode::compile(OSLCompiler &compiler)