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:
authorCharlie Jolly <charlie>2021-03-23 12:21:56 +0300
committerCharlie Jolly <mistajolly@gmail.com>2021-03-23 12:59:20 +0300
commitd3758892987d76749fdf1211ed27ff77f39b5b3b (patch)
tree0e0b6b2a614b9829255cae77fb75f93696e7df7b /source/blender/makesrna
parent4c19fcacc0b71271ca2fafc87ef5772a819e7075 (diff)
Nodes: Add Refract and Faceforward functions to Vector Maths nodes
Cycles, Eevee, OSL, Geo, Attribute Based on outdated refract patch D6619 by @cubic_sloth `refract` and `faceforward` are standard functions in GLSL, OSL and Godot shader languages. Adding these functions provides Blender shader artists access to these standard functions. Reviewed By: brecht Differential Revision: https://developer.blender.org/D10622
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 7fa67ad351f..3aba3e51217 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -224,6 +224,18 @@ const EnumPropertyItem rna_enum_node_vec_math_items[] = {
0,
"Reflect",
"Reflect A around the normal B. B doesn't need to be normalized"},
+ {NODE_VECTOR_MATH_REFRACT,
+ "REFRACT",
+ 0,
+ "Refract",
+ "For a given incident vector A, surface normal B and ratio of indices of refraction, Ior, "
+ "refract returns the refraction vector, R"},
+ {NODE_VECTOR_MATH_FACEFORWARD,
+ "FACEFORWARD",
+ 0,
+ "Faceforward",
+ "Orients a vector A to point away from a surface B as defined by its normal C. "
+ "Returns (dot(B, C) < 0) ? A : -A"},
{NODE_VECTOR_MATH_DOT_PRODUCT, "DOT_PRODUCT", 0, "Dot Product", "A dot B"},
{0, "", ICON_NONE, NULL, NULL},
{NODE_VECTOR_MATH_DISTANCE, "DISTANCE", 0, "Distance", "Distance between A and B"},
@@ -1961,7 +1973,7 @@ static const EnumPropertyItem *rna_GeometryNodeAttributeFill_type_itemf(bContext
/**
* This bit of ugly code makes sure the float / attribute option shows up instead of
- * vector / attribute if the node uses an operation that uses a float for input B.
+ * vector / attribute if the node uses an operation that uses a float for input B or C.
*/
static const EnumPropertyItem *rna_GeometryNodeAttributeVectorMath_input_type_b_itemf(
bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
@@ -1994,6 +2006,37 @@ static const EnumPropertyItem *rna_GeometryNodeAttributeVectorMath_input_type_b_
return item_array;
}
+static const EnumPropertyItem *rna_GeometryNodeAttributeVectorMath_input_type_c_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ bNode *node = ptr->data;
+ NodeAttributeVectorMath *node_storage = (NodeAttributeVectorMath *)node->storage;
+
+ EnumPropertyItem *item_array = NULL;
+ int items_len = 0;
+ for (const EnumPropertyItem *item = rna_node_geometry_attribute_input_type_items_any;
+ item->identifier != NULL;
+ item++) {
+ if (item->value == GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE) {
+ RNA_enum_item_add(&item_array, &items_len, item);
+ }
+ else if (item->value == GEO_NODE_ATTRIBUTE_INPUT_FLOAT) {
+ if (node_storage->operation == NODE_VECTOR_MATH_REFRACT) {
+ RNA_enum_item_add(&item_array, &items_len, item);
+ }
+ }
+ else if (item->value == GEO_NODE_ATTRIBUTE_INPUT_VECTOR) {
+ if (node_storage->operation != NODE_VECTOR_MATH_REFRACT) {
+ RNA_enum_item_add(&item_array, &items_len, item);
+ }
+ }
+ }
+ RNA_enum_item_end(&item_array, &items_len);
+
+ *r_free = true;
+ return item_array;
+}
+
static void rna_GeometryNodeAttributeVectorMath_operation_update(Main *bmain,
Scene *scene,
PointerRNA *ptr)
@@ -8901,7 +8944,9 @@ static void def_geo_attribute_vector_math(StructRNA *srna)
prop = RNA_def_property(srna, "input_type_c", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "input_type_c");
- RNA_def_property_enum_items(prop, rna_node_geometry_attribute_input_type_items_vector);
+ RNA_def_property_enum_items(prop, rna_node_geometry_attribute_input_type_items_any);
+ RNA_def_property_enum_funcs(
+ prop, NULL, NULL, "rna_GeometryNodeAttributeVectorMath_input_type_c_itemf");
RNA_def_property_ui_text(prop, "Input Type C", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}