Simulations: Use some shader nodes in simulation node trees
authorJacques Lucke <jacques@blender.org>
Mon, 20 Apr 2020 13:17:36 +0000 (15:17 +0200)
committerJacques Lucke <jacques@blender.org>
Mon, 20 Apr 2020 13:17:36 +0000 (15:17 +0200)
Reviewers: brecht

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

18 files changed:
release/scripts/startup/nodeitems_builtins.py
source/blender/nodes/shader/node_shader_util.c
source/blender/nodes/shader/node_shader_util.h
source/blender/nodes/shader/nodes/node_shader_brightness.c
source/blender/nodes/shader/nodes/node_shader_clamp.c
source/blender/nodes/shader/nodes/node_shader_gamma.c
source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
source/blender/nodes/shader/nodes/node_shader_invert.c
source/blender/nodes/shader/nodes/node_shader_map_range.c
source/blender/nodes/shader/nodes/node_shader_math.c
source/blender/nodes/shader/nodes/node_shader_mixRgb.c
source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
source/blender/nodes/shader/nodes/node_shader_tex_noise.c
source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c
source/blender/nodes/shader/nodes/node_shader_valToRgb.c
source/blender/nodes/shader/nodes/node_shader_vector_math.c

index 722974b52f6575a9f1d2272144222321e7aa4276..fd601035288201a897bcf666426b0b5a788c2eb1 100644 (file)
@@ -501,6 +501,30 @@ simulation_node_categories = [
         NodeItem("SimulationNodeExecuteCondition"),
         NodeItem("SimulationNodeMultiExecute"),
     ]),
+    SimulationNodeCategory("SIM_NOISE", "Noise", items=[
+        NodeItem("ShaderNodeTexNoise"),
+        NodeItem("ShaderNodeTexWhiteNoise"),
+    ]),
+    SimulationNodeCategory("SIM_COLOR", "Color", items=[
+        NodeItem("ShaderNodeMixRGB"),
+        NodeItem("ShaderNodeInvert"),
+        NodeItem("ShaderNodeHueSaturation"),
+        NodeItem("ShaderNodeGamma"),
+        NodeItem("ShaderNodeBrightContrast"),
+    ]),
+    SimulationNodeCategory("SIM_CONVERTER", "Converter", items=[
+        NodeItem("ShaderNodeMapRange"),
+        NodeItem("ShaderNodeClamp"),
+        NodeItem("ShaderNodeMath"),
+        NodeItem("ShaderNodeValToRGB"),
+        NodeItem("ShaderNodeVectorMath"),
+        NodeItem("ShaderNodeSeparateRGB"),
+        NodeItem("ShaderNodeCombineRGB"),
+        NodeItem("ShaderNodeSeparateXYZ"),
+        NodeItem("ShaderNodeCombineXYZ"),
+        NodeItem("ShaderNodeSeparateHSV"),
+        NodeItem("ShaderNodeCombineHSV"),
+    ]),
     SimulationNodeCategory("SIM_GROUP", "Group", items=node_group_items),
     SimulationNodeCategory("SIM_LAYOUT", "Layout", items=[
         NodeItem("NodeFrame"),
index 93d03720058dc6d7c735cb1228588c632d12f000..4464a61c48ccaaf3e18b42d7a9c97bf3b93d0086 100644 (file)
@@ -32,6 +32,11 @@ bool sh_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
   return STREQ(ntree->idname, "ShaderNodeTree");
 }
 
+static bool sh_fn_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
+{
+  return STREQ(ntree->idname, "ShaderNodeTree") || STREQ(ntree->idname, "SimulationNodeTree");
+}
+
 void sh_node_type_base(
     struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
 {
@@ -42,6 +47,12 @@ void sh_node_type_base(
   ntype->update_internal_links = node_update_internal_links_default;
 }
 
+void sh_fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
+{
+  sh_node_type_base(ntype, type, name, nclass, flag);
+  ntype->poll = sh_fn_poll_default;
+}
+
 /* ****** */
 
 void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
index 8d525c8f23cba82d8908895993bcf41e016e963b..8834de0633ed688a3131b60f63ce58f6ababdc13 100644 (file)
@@ -72,6 +72,8 @@
 bool sh_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
 void sh_node_type_base(
     struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
+void sh_fn_node_type_base(
+    struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
 
 /* ********* exec data struct, remains internal *********** */
 
index d8f560277f23e9ac291c3daa512bc64d73937ee0..cc1968cb1b1676cdc06f642db33d3b613ce4a01a 100644 (file)
@@ -46,7 +46,7 @@ void register_node_type_sh_brightcontrast(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
   node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out);
   node_type_init(&ntype, NULL);
   node_type_storage(&ntype, "", NULL, NULL);
index c49cfcea8d33f0f145d53cbda2b94af77fb880a1..808f9686f0ab6c456827bd995bc47ea70bf8c2fa 100644 (file)
@@ -54,7 +54,7 @@ void register_node_type_sh_clamp(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_CLAMP, "Clamp", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_CLAMP, "Clamp", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_clamp_in, sh_node_clamp_out);
   node_type_init(&ntype, node_shader_init_clamp);
   node_type_gpu(&ntype, gpu_shader_clamp);
index b48838e5f56b3010580a81dfefb5caed5a4ae436..747979522d16f8ba25dfc929f3c5fa2eecef5a1e 100644 (file)
@@ -62,7 +62,7 @@ void register_node_type_sh_gamma(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
   node_type_socket_templates(&ntype, sh_node_gamma_in, sh_node_gamma_out);
   node_type_init(&ntype, NULL);
   node_type_storage(&ntype, "", NULL, NULL);
index 7a05fc95eec7e49c2238a4173e98a2c7355e455d..57ef51c65f6430beaa220fd3818568222a62df73 100644 (file)
@@ -89,7 +89,7 @@ void register_node_type_sh_hue_sat(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
   node_type_socket_templates(&ntype, sh_node_hue_sat_in, sh_node_hue_sat_out);
   node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
   node_type_exec(&ntype, NULL, NULL, node_shader_exec_hue_sat);
index 0d6709a19687cc9e7e3c80378af82a95d26380ec..19fa0b0309ddf5d2615087878995b8ed801569cd 100644 (file)
@@ -69,7 +69,7 @@ void register_node_type_sh_invert(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
   node_type_socket_templates(&ntype, sh_node_invert_in, sh_node_invert_out);
   node_type_exec(&ntype, NULL, NULL, node_shader_exec_invert);
   node_type_gpu(&ntype, gpu_shader_invert);
index d59540cb8fa3d716b1b4ecb13812b380fa587dbe..5db7983e752b89aa213742635640826fea52410f 100644 (file)
@@ -81,7 +81,7 @@ void register_node_type_sh_map_range(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_map_range_in, sh_node_map_range_out);
   node_type_init(&ntype, node_shader_init_map_range);
   node_type_update(&ntype, node_shader_update_map_range);
index 08578e0e11e25ca4e83a2f2875084eb142403cc5..8abebbf50811605861f8239956017a9520300198 100644 (file)
@@ -105,7 +105,7 @@ void register_node_type_sh_math(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_math_in, sh_node_math_out);
   node_type_label(&ntype, node_math_label);
   node_type_gpu(&ntype, gpu_shader_math);
index 9c318073304432013cf0ec353cc4e65f5b13ab73..93e88664d1a3f2a6ce8c02dbf262a9d21f21a519 100644 (file)
@@ -107,7 +107,7 @@ void register_node_type_sh_mix_rgb(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0);
   node_type_socket_templates(&ntype, sh_node_mix_rgb_in, sh_node_mix_rgb_out);
   node_type_label(&ntype, node_blend_label);
   node_type_exec(&ntype, NULL, NULL, node_shader_exec_mix_rgb);
index 951755be4f3261026e5a7f5e9a3b883d838c5da5..2c9b77530a2d7558132458a1b7bad55f40bcd831 100644 (file)
@@ -61,7 +61,7 @@ void register_node_type_sh_sephsv(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out);
   node_type_exec(&ntype, NULL, NULL, node_shader_exec_sephsv);
   node_type_gpu(&ntype, gpu_shader_sephsv);
@@ -109,7 +109,7 @@ void register_node_type_sh_combhsv(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out);
   node_type_exec(&ntype, NULL, NULL, node_shader_exec_combhsv);
   node_type_gpu(&ntype, gpu_shader_combhsv);
index f10f80d5c2dd06d676f408402849718329f4842b..d0dc45dceddc6fd011aab8889ea7be41dfe1244d 100644 (file)
@@ -63,7 +63,7 @@ void register_node_type_sh_seprgb(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out);
   node_type_exec(&ntype, NULL, NULL, node_shader_exec_seprgb);
   node_type_gpu(&ntype, gpu_shader_seprgb);
@@ -113,7 +113,7 @@ void register_node_type_sh_combrgb(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out);
   node_type_exec(&ntype, NULL, NULL, node_shader_exec_combrgb);
   node_type_gpu(&ntype, gpu_shader_combrgb);
index 55d5084b13249dc6d58c107d9df35a0cfafaefb9..429b1a3e818f12123566085f3aa72dae5bd4f9fe 100644 (file)
@@ -48,7 +48,7 @@ void register_node_type_sh_sepxyz(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_SEPXYZ, "Separate XYZ", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_SEPXYZ, "Separate XYZ", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_sepxyz_in, sh_node_sepxyz_out);
   node_type_gpu(&ntype, gpu_shader_sepxyz);
 
@@ -80,7 +80,7 @@ void register_node_type_sh_combxyz(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_combxyz_in, sh_node_combxyz_out);
   node_type_gpu(&ntype, gpu_shader_combxyz);
 
index 7b67c2d1f2ef63c89bcf95c6d59a25b3f2c075e8..67268c102c53a611d52dc5b818bb64ba00f007e2 100644 (file)
@@ -91,7 +91,7 @@ void register_node_type_sh_tex_noise(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0);
   node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out);
   node_type_init(&ntype, node_shader_init_tex_noise);
   node_type_storage(
index 1789dc44bf183d4970d2c578585b9932fdd0645d..817ccdc8b6a6c4db319c32561650e00409c0f840 100644 (file)
@@ -72,7 +72,8 @@ void register_node_type_sh_tex_white_noise(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE, 0);
+  sh_fn_node_type_base(
+      &ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE, 0);
   node_type_socket_templates(&ntype, sh_node_tex_white_noise_in, sh_node_tex_white_noise_out);
   node_type_init(&ntype, node_shader_init_tex_white_noise);
   node_type_gpu(&ntype, gpu_shader_tex_white_noise);
index 49f9befdce3032ee809b5cb35f70a4ce8988a538..20f280d00c378e84c967a902ea2aefbc9ea20e39 100644 (file)
@@ -125,7 +125,7 @@ void register_node_type_sh_valtorgb(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0);
   node_type_socket_templates(&ntype, sh_node_valtorgb_in, sh_node_valtorgb_out);
   node_type_init(&ntype, node_shader_init_valtorgb);
   node_type_size_preset(&ntype, NODE_SIZE_LARGE);
index 3a6e273eb20bbd6f80571cf63cb1120211e9a204..b719fe03d9b540df56259ac18ff6f064bf015380 100644 (file)
@@ -134,7 +134,7 @@ void register_node_type_sh_vect_math(void)
 {
   static bNodeType ntype;
 
-  sh_node_type_base(&ntype, SH_NODE_VECTOR_MATH, "Vector Math", NODE_CLASS_OP_VECTOR, 0);
+  sh_fn_node_type_base(&ntype, SH_NODE_VECTOR_MATH, "Vector Math", NODE_CLASS_OP_VECTOR, 0);
   node_type_socket_templates(&ntype, sh_node_vector_math_in, sh_node_vector_math_out);
   node_type_label(&ntype, node_vector_math_label);
   node_type_gpu(&ntype, gpu_shader_vector_math);