Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
enzyme69 opened this issue Mar 7, 2021 · 15 comments · Fixed by #4596
Closed

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

enzyme69 opened this issue Mar 7, 2021 · 15 comments · Fixed by #4596
Labels
Proposal 💡 Would be nice to have

Comments

@enzyme69
Copy link
Collaborator

enzyme69 commented Mar 7, 2021

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
Copy link
Collaborator

vicdoval commented Mar 7, 2021

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

@enzyme69
Copy link
Collaborator Author

enzyme69 commented Mar 7, 2021

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
Copy link
Collaborator Author

enzyme69 commented Mar 7, 2021

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
Copy link
Collaborator Author

enzyme69 commented Mar 7, 2021

@Durman Durman added the Proposal 💡 Would be nice to have label Mar 11, 2021
@Durman
Copy link
Collaborator

Durman commented Mar 11, 2021

This is looks like original code of the node.

code
        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
Copy link
Collaborator Author

enzyme69 commented Mar 12, 2021

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 Durman self-assigned this Mar 13, 2021
@Durman
Copy link
Collaborator

Durman commented Mar 13, 2021

2021-03-13_12-16-52

@Durman
Copy link
Collaborator

Durman commented Mar 13, 2021

2021-03-13_13-35-14

@Durman Durman mentioned this issue Mar 13, 2021
5 tasks
@summereasy
Copy link

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
Copy link
Collaborator

Durman commented Mar 14, 2021

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
Copy link

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
Copy link
Collaborator

Durman commented May 16, 2021

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

@enzyme69
Copy link
Collaborator Author

enzyme69 commented May 16, 2021

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:

  • transferring normal matrix
  • injecting color into points (cloud?)
  • getting and setting radius from grease pencil (stylus pressure stroke) into curves?
  • custom attribute

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

@nortikin nortikin reopened this May 17, 2021
@Durman Durman removed their assignment Jun 10, 2021
@AndGuz
Copy link

AndGuz commented Dec 23, 2021

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

@Durman
Copy link
Collaborator

Durman commented Dec 23, 2021

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

2021-12-23_13-55-47

@Durman Durman mentioned this issue Jul 27, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal 💡 Would be nice to have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants