[Bf-blender-cvs] [77cd8182f86] master: Cycles: Remove Vector input on Sky texture when using the included sun

Lukas Stockner noreply at git.blender.org
Mon Jul 13 03:15:37 CEST 2020


Commit: 77cd8182f865022320d0e48b31b599bad033dab5
Author: Lukas Stockner
Date:   Mon Jul 13 01:40:47 2020 +0200
Branches: master
https://developer.blender.org/rB77cd8182f865022320d0e48b31b599bad033dab5

Cycles: Remove Vector input on Sky texture when using the included sun

When using the sun, we need to sun sampling logic to avoid excessive
sampling map resolution, but that logic assumes that the Vector input
comes from the view direction.
That is the case in the vast majority of cases anyways, so the easiest
solution is to just remove the input for that case.

Differential Revision: https://developer.blender.org/D8091

===================================================================

M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/shader/nodes/node_shader_tex_sky.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 2440b16aeb8..0658b2f048a 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -4421,7 +4421,7 @@ static void def_sh_tex_sky(StructRNA *srna)
   RNA_def_property_enum_sdna(prop, NULL, "sky_model");
   RNA_def_property_enum_items(prop, prop_sky_type);
   RNA_def_property_ui_text(prop, "Sky Type", "Which sky model should be used");
-  RNA_def_property_update(prop, 0, "rna_Node_update");
+  RNA_def_property_update(prop, 0, "rna_ShaderNode_socket_update");
 
   prop = RNA_def_property(srna, "sun_direction", PROP_FLOAT, PROP_DIRECTION);
   RNA_def_property_ui_text(prop, "Sun Direction", "Direction from where the sun is shining");
@@ -4445,7 +4445,7 @@ static void def_sh_tex_sky(StructRNA *srna)
   RNA_def_property_ui_text(prop, "Sun Disc", "Include the sun itself in the output");
   RNA_def_property_boolean_sdna(prop, NULL, "sun_disc", 1);
   RNA_def_property_boolean_default(prop, true);
-  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+  RNA_def_property_update(prop, 0, "rna_ShaderNode_socket_update");
 
   prop = RNA_def_property(srna, "sun_size", PROP_FLOAT, PROP_ANGLE);
   RNA_def_property_ui_text(prop, "Sun Size", "Size of sun disc (angular diameter)");
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
index 70f3f80eb4b..7e15daaf666 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
@@ -214,6 +214,14 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat,
   }
 }
 
+static void node_shader_update_sky(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  bNodeSocket *sockVector = nodeFindSocket(node, SOCK_IN, "Vector");
+
+  NodeTexSky *tex = (NodeTexSky *)node->storage;
+  nodeSetSocketAvailability(sockVector, !(tex->sky_model == 2 && tex->sun_disc == 1));
+}
+
 /* node type definition */
 void register_node_type_sh_tex_sky(void)
 {
@@ -225,6 +233,8 @@ void register_node_type_sh_tex_sky(void)
   node_type_init(&ntype, node_shader_init_tex_sky);
   node_type_storage(&ntype, "NodeTexSky", node_free_standard_storage, node_copy_standard_storage);
   node_type_gpu(&ntype, node_shader_gpu_tex_sky);
+  /* remove Vector input for Nishita */
+  node_type_update(&ntype, node_shader_update_sky);
 
   nodeRegisterType(&ntype);
 }



More information about the Bf-blender-cvs mailing list