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

Allow non-interpolation of colors in Cartoon and Ribbon Mesh #393

Closed
BradyAJohnston opened this issue Jan 3, 2024 · 9 comments · Fixed by #394
Closed

Allow non-interpolation of colors in Cartoon and Ribbon Mesh #393

BradyAJohnston opened this issue Jan 3, 2024 · 9 comments · Fixed by #394
Labels
enhancement New feature or request

Comments

@BradyAJohnston
Copy link
Owner

Currently colors are interpolated on the generated cartoon and ribbon meshes, as the colors are sourced from the alpha carbons.

image

It is possible however to just do immediate transitions from one to the to the next, and expose this as an option to the user.

image

@rbdavid
Copy link
Contributor

rbdavid commented Jan 12, 2024

@BradyAJohnston What/where is the option to turn off the color interpolation?

Edit: I've updated to 4.0.8. Maybe I'm just using the wrong node elements though.

@rbdavid
Copy link
Contributor

rbdavid commented Jan 12, 2024

Disregard, the save file that I have based all of my work on is using the old version of the Mn Utils Style Cartoon node so I wasn't seeing the Interpolate Color checkbox. Even when I pull out a fresh node, the checkbox isn't present. But I open a fresh blender project and use the Mn Utils Style Cartoon node, the new parameters are there. So my MN is on 4.0.8 but the old save file doesn't recognize the updated version of the nodes.

When an update pushes changes to a node, how do I cascade that update to the affected nodes that were used in saved blender files? Or do I need to recreate the whole project to utilize the new node types/parameters?

@BradyAJohnston
Copy link
Owner Author

@rbdavid currently when selecting the nodes from the menu, MN checks if the node already exists in the file, then if not appends it to the current working file. Once MN is updated the node might change but the names won't, which is the problem that you are running in to.

To import the new node, you can either rename the old node, then the import will not detect the existence of the node and append the new one, or you can manually append the new node as well.

Renaming the Old Node

CleanShot.2024-01-13.at.09.51.04.mp4

You can manually append node groups (which will import & .001 to the node group) by going File -> Append and finding the MN_data_file.blend that is inside of the assets folder in the add-on directory. If you choose NodeTree you will find all of the Geometry Nodes nodes in that file, and you can choose the new cartoon node, which will be appended to the file and you should be able to find it through the node groups.

If you have suggestions on how you think MN should handle this better, I'm open to suggestions also!

@rbdavid
Copy link
Contributor

rbdavid commented Jan 13, 2024

Oh this is a tough one. Having an update auto-populate nodes with the new parameters would create potential issues with recreating past figures. Certainly something to be avoided. The process you described (client-side renaming of old nodes so that an import of a new MN version loads the updated nodes) is very rough though. Who knows how outdated a user's MN version could get and how many renamings they'd need to do. Very difficult to update MN and continue a working project.

But the past versions of Molecular Nodes are available to download still, so versioning in regards to MN can be controlled that way. Instead of Edit -> Preferences -> Add-ons -> Import: molecularnodes could you rename the add-on to include versioning? That way, the MN directory in the user's blender add-on directory tree would differentiate multiple installs of MN. For example, when Blender unzips the MN zip file, it creates a molecularnodes-4.0.8 directory. Then the user can have multiple versions installed, enable/import the specific MN version, and install the correct dependencies for whatever version they want to use. (edit: alternatively I just control my add-ons in this way). If you can add a metadata field to save files/figures/animations to denote what Blender add-ons and versions were used to create those files, that would be icing on the cake.

But I'm a novice with Blender and have no idea how the Blender community handles this type of thing.

@rbdavid
Copy link
Contributor

rbdavid commented Jan 13, 2024

Also, as a side thought, shouldn't the Interpolate Color checkbox be part of the Color Set node? Or, you'll need to implement the same checkbox with Ribbon and Surface representation styles. (These changes are very low priority for me but its a consideration for other potential users.)

Once again, I am uncertain the internals of all of these nodes so I could be confusing the tasks being done by the specific nodes.

@BradyAJohnston
Copy link
Owner Author

The 'Set Color' node sets the colors based on a per-atom basis. When the styles are created, they pull the color information form the relevant atoms (usually alpha-carbons). Only once it starts to get the color information and apply it to the style mesh, then interpolation will occur / not occur.

The option was also added to the ribbon node (might need to load the new one as well), and the option for interpolating colors on the surface style was already there, but they are under the 'Color' tab with an option for 'Blur'. I should change this though to be more consistent with naming throughout the nodes.

In terms of versioning, versioning the add-on itself to have multiple installs I don't think would work, and I don't think it would be the best approach. I could potentially have some version number for the nodes themselves, to check for when there is a newer node that has been updated. I don't have access to a lot of metadata options for the nodes but I could potentially create some custom properties for them, so that when the version in your file and the MN_data_file.blend differ, both options show up to be added from the menu. Will have a look into it.

@rbdavid
Copy link
Contributor

rbdavid commented Jan 13, 2024

Yeah, but having multiple versions of the same named nodes in the drop down menu creates ambiguity, right? And might start to bloat the node lists. Maybe both are inevitable when a project starts to span multiple MN versions. Idk, its a tough problem that's best to be avoided when possible.

@rbdavid
Copy link
Contributor

rbdavid commented Jan 13, 2024

Just tried to create a user-defined path to add-ons (https://docs.blender.org/manual/en/latest/editors/preferences/addons.html -> user-defined add-on path tip). Loaded up three different versions of MN in the user-created addons subdir. When I try to check the import box for any of these different versions, I get this error message: Screenshot (41)

I haven't dug deep into where the molecular_nodes_4 module is in the whole MN file directory so I can't debug this error at the moment.

I have changed the bl_info['name'] dictionary value in the outer most __init__.py script to be a versioned name. Within Blender, I now see four different installs of MN (one in the default blender directory tree and the three in the user-defined add-ons directory). This avoids a warning/error in the add-ons menu saying that multiple versions of molecularnodes are present and need to be sorted. So if I can figure out the module load error above, then I could technically import different versions of the add-on.

Now, that still doesn't change the fact that the node details are saved within a specific project's .blend file... If the parameters/configurations/connections of nodes used explicitly in the graph are saved within that .blend NodeTree subdirectory then switching between add-on versions won't change a thing, right?

I'd have to rename the old node(s), save and exit blender, and then load the blender file to get the updated nodes to be imported correctly. Then, I still have to drag the updated node(s) onto the graph, make connections, and update parameters. Is there a way to alter the .blend file and specifically the node graph outside of the GUI? Assuming the node naming issue is solved by version numbering node types, can I write a script to automate the change of nodes within the graph from the outdated node to the updated one? Where default values of the new node are used if parameters are added between versions.

Anyways, my questions keep spilling far afield from molecular nodes features. I really appreciate your add-on and hope I can get blender to work the way I want it to. There's something to VMD's human readable vis-state files that make it very easy to script around. I've just gotta figure out how to do those things with blender files.

@BradyAJohnston
Copy link
Owner Author

I don't think this approach is going to work. For buttons in Blender to work, you have to register operators with a string bl_idrna. Each add-on is going to register the same named operators on top of each other, so you are going to get name space collisions all over the place.

This is quite out-of-scope of just using the add-on itself, so I can't really help you with multiple installations, because I would highly recommend against such a strategy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants