nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.23k stars 232 forks source link

WISHLIST: SV Custom SET and GET Attribute for Geometry Nodes instancing #3960

Closed enzyme69 closed 2 years ago

enzyme69 commented 3 years ago

Snapshot:

Screen Shot 2021-03-08 at 12 40 30 am

As shown by Bradley Animation with Animation Nodes here: https://www.youtube.com/watch?v=EmMyxSRGhRc

I am wondering if SV can support the creation of Custom Attribute (Points) and fill it values so that Geometry Nodes can understand the value and using it for instancing.

vicdoval commented 3 years ago

If it can be done in python then it can be done in sverchok

enzyme69 commented 3 years ago

Yes, I am trying to dig more into it. Bradley Animation is using AN version with some extra nodes from Kuldeep Singh to set custom attribute.

enzyme69 commented 3 years ago

In the past, we have already Attribute "Col". But in recent Blender there is also "Geometry" etc which I hardly used. But probably related to Geometry Nodes instancing.

Screen Shot 2021-03-08 at 1 08 48 am

https://docs.blender.org/manual/en/latest/render/shader_nodes/input/attribute.html

enzyme69 commented 3 years ago

Currently reading this: https://docs.blender.org/manual/en/dev/modeling/geometry_nodes/attributes_reference.html

Durman commented 3 years ago

This is looks like original code of the node.

code ```py if object is None: return object if object.type != "MESH": self.raiseErrorMessage("Object should be Mesh type.") if attName == "": self.raiseErrorMessage("Attribute name can't be empty.") attribute = object.data.attributes.get(attName) if attribute is None: attribute = object.data.attributes.new(attName, self.dataType, self.domain) elif attribute.data_type != self.dataType or attribute.domain != self.domain: object.data.attributes.remove(attribute) attribute = object.data.attributes.new(attName, self.dataType, self.domain) if self.domain == "POINT": amount = len(object.data.vertices) elif self.domain == "EDGE": amount = len(object.data.edges) elif self.domain == "CORNER": amount = len(object.data.loops) else: amount = len(object.data.polygons) if self.dataType == "FLOAT": _data = FloatList.fromValues(VirtualDoubleList.create(data, 0).materialize(amount)) elif self.dataType == "INT": _data = VirtualLongList.create(data, 0).materialize(amount) elif self.dataType == "FLOAT2": _data = VirtualVector2DList.create(data, Vector((0, 0))).materialize(amount) elif self.dataType == "FLOAT_VECTOR": _data = VirtualVector3DList.create(data, Vector((0, 0, 0))).materialize(amount) elif self.dataType in ["FLOAT_COLOR", "BYTE_COLOR"]: _data = VirtualColorList.create(data, Color((0, 0, 0, 0))).materialize(amount) else: _data = VirtualBooleanList.create(data, False).materialize(amount) if self.dataType in ["FLOAT", "INT", "BOOLEAN"]: attribute.data.foreach_set("value", _data.asMemoryView()) elif self.dataType in ["FLOAT2", "FLOAT_VECTOR"]: attribute.data.foreach_set("vector", _data.asMemoryView()) else: attribute.data.foreach_set("color", _data.asMemoryView()) attribute.data.update() return object ```
enzyme69 commented 3 years ago

So far, the most interesting bits of Geometry Nodes is the ability to separate Vertex Color data like "SvCol" XYZ, then inject it back into Geometry Nodes mesh.

Durman commented 3 years ago

2021-03-13_12-16-52

Durman commented 3 years ago

2021-03-13_13-35-14

summereasy commented 3 years ago

Hey @Durman, I noticed an interesting tool in your screenshot. And quite useful. Is that a build-in tool or some utility you made yourself? screenshot

Durman commented 3 years ago

Do you mean spreadsheet editor? This is not what can be done with Python so it is build-in functionality. Now it's in 2.93 Blender version. It shows some attributes of selected mesh. Later more functionality will be added like filtering, editing values and etc. So it's on early development stage.

summereasy commented 3 years ago

Now it's in 2.93 Blender version. It shows some attributes of selected mesh. Later more functionality will be added like filtering, editing values and etc. So it's on early development stage.

Oh! I see! It is great to know it's coming and thanks!

Durman commented 3 years ago

@enzyme69 or someone else, do you have any ideas in mind about usecases for the set mesh attribute node?

enzyme69 commented 3 years ago

It's probably for Geometry Nodes and instancing and things like Attribute Transfer node. If SV nodes can provide data like for example for index instance.

Set Mesh Atrribute ... maybe:

I think Kuldeep shows some Animation Nodes set and get custom attribute.

AndGuz commented 2 years ago

This idea would be pretty useful for use it with geonodes fields.

Durman commented 2 years ago

You can create attributes with Sverchok and GN can utilize them.

2021-12-23_13-55-47