-
Notifications
You must be signed in to change notification settings - Fork 75
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
Rework Node UX #348
Rework Node UX #348
Conversation
Here is my idea for that: either constantly unregistering/registering the categories or creating a global pool of all node items accumulated from Malt itself and plugins and replacing the |
When replacing the draw function you lose the search functionality, right? Seems like the items parameter can be a callback that receives the current context, so that can be a good option. |
You can only search the node items of a node cateogory that returns True when polling. Specifically |
This is checked but for me this has no effect. The hash functions for example are still all separate and have no dropdown menu. |
It works, check Node Utils > Float, for example. Those multiple hashes is because this new UI is not tracking function overloads yet (the old did). |
Ah yeah I just noticed that some actually do already have dropdowns. |
I found an issue with the subcategories. When the enum updates you need to recompile the graph for the change to take effect (an issue that pops up a lot in MaltSE). I cant commit the change though because I need to request access for GitKraken to push to the repo (request now pending). |
Not sure if we can do this, as mentioned before, the search function lists all node items in categories that can be polled. So I think the only way to make subcategory items be their own search items you would need to create and display a 'Misc' node category that contains all the subcategory items as their own items. |
I've added support for enum properties. /*
META
@color: subtype=ENUM(Red,Green,Blue); default=1;
*/
vec3 test_enum(int color)
{
switch (color)
{
case 0: return vec3(1,0,0);
case 1: return vec3(0,1,0);
case 2: return vec3(0,0,1);
}
return vec3(0);
} There are probably some things left to fix and tweak, but I think all the major features needed for the new API are already there. |
for the min/max parameters. The 'bpy.types.UILayout.prop' function has a 'slider' keyword argument that we can use to display the parameters with both min and max as sliders. But I dont see any way to retrieve the malt subtype of a function input to reliably set that up. Where does the subtype go when its read by the parser? That part of malt is still pretty much a blackbox to me. |
All meta properties are inside a "meta" dictionary in their function/parameter. If you add import pprint
pprint.pprint(functions) to the preload_menus function in MaltNodeTree.py you can see the whole info. This is how a single function looks like:
|
The GLSL parameters are converter to MaltParameters inside MaltNode.setup_sockets: Malt/BlenderMalt/MaltNodes/MaltNode.py Line 132 in ceb2fda
And then sent to the setup function of MaltPropertyGroup: Malt/BlenderMalt/MaltProperties.py Line 114 in ceb2fda
In the case of the subtype, it always gets stored as part of the MaltPropertyGroup rna dictionary: Malt/BlenderMalt/MaltProperties.py Line 267 in ceb2fda
So the info was already there. It just had to be retrieved from the draw function: Malt/BlenderMalt/MaltProperties.py Line 579 in ceb2fda
/*
META
@factor: subtype=Slider; default=0.5; min=0.0; max=1.0;
*/
vec3 test_slider(float factor, vec3 a, vec3 b)
{
return mix(a,b, factor);
} |
I've added a new Input file in Node Utils that implements new nodes more in line with the Cycles/EEVEE/ShadingEssentials style. |
seems like we ended up working on the same thing now 😅 |
bias should be kept as possible
Ah sorry I was going to rename it. It's a correction factor that brings the output range to 0-1. Before they were a bit lower. It's not that noticeable for the 4D noise but 2D and 1D didn't have very good value ranges so I added this. I know blender uses its own set of magic numbers to correct for this. |
maybe a name like 'range correction factor' would be better?
Yeah I would like to avoid it as well if possible. Custom python nodes maybe belong exclusively into plugins to separate them a bit.
Thought about that too. Might be a good solution. Similar to this we could separate the node itself into a Tiled and Infinite version but this would add too many node category items again. I think the voronoi node should have a randomness parameter. Do you think we should add one? I have not done that already because I know we are going to have to dance around the backwards compatibility issue since we dont want to keep a valid overload function that would work for old files |
I have refactored the noise functions into "c style templates", so we don't have so much duplicated code.
That's what the
Sure! As long as we make sure to keep a cell_noise and a cell_noise_ex function with the old signatures, there shouldn't be any compact issues. |
I am aware that this brings the value WITHIN the 0-1 range but it's actually only using a range that's more like 0.2-0.8. The magic multiplier was added to make sure that the entire 0-1 range is being used for the resulting values. Maybe there is a better way to improve this though. But I am not sure if you can do it analytically (instead of trying different values until you find one that works reasonably well which is what I tried) |
The important point is that if you want to remap the range you should use
The analytical way is to assume that the dot product can actually be 1 or -1 even if it's rare. |
from my crude tests I was able to confirm that with the adjustment, the mean is still 0.5. The variance increases for sure but the mean is still 0.5. |
looks interesting. I have never seen something like this for shader programming. Do you know how I can make VSCode not freak out? It is current not very happy with this arrangement 😅 |
alright I looked up what the noise node in blender does and it has the same 'issue' that low values are almost never lower than 0.2. Since I never noticed that the support of the blender noise node is not actually 0-1 range but 0.2-0.8 instead I think it would not be too much of an issue to do the same for our noise. I think we could leave it how it is now (even though I am having trouble understanding this c-style layout now) |
I use the same settings that Malt sets when Setup VS Code is enabled. This is what my .vscode/settings.json looks like: {
"files.associations": {
"*.glsl": "cpp"
},
"C_Cpp.default.includePath": [
"./Malt/Shaders",
"./Malt/Pipelines/NPR_Pipeline/Shaders"
],
"C_Cpp.default.forcedInclude": [
"./Malt/Shaders/Intellisense/intellisense.glsl",
"./Malt/Pipelines/NPR_Pipeline/Shaders/NPR_Intellisense.glsl"
],
"C_Cpp.autoAddFileAssociations": true,
"C_Cpp.default.cppStandard": "c++03",
"C_Cpp.default.compilerPath": "",
"C_Cpp.default.browse.limitSymbolsToIncludedHeaders": true,
"C_Cpp.errorSquiggles": "Disabled",
"python.analysis.extraPaths": [
"./Malt/.Dependencies-310"
],
}
It's essentially the same as a macro. Instead of doing something like this: #define SUM(array, result)\
{\
for(int i = 0; i < array.length(); i++)\
{\
result += array[i];\
}\
}\
int a[10] = int[10](/** init **//);
int sum;
SUM(a, sum); You put the macro content in a separate file: for(int i = 0; i < array.length(); i++)
{
result += array[i];
} and then: int array[10] = int[10](/** init **//);
int result;
#include "SUM.inl" The generated code is the same, but you get better compiler errors (with actual file and line number) and avoid the pain of adding the BTW, you were right that the correct way to remap the value is |
since I remember you wanting to add a smoothstep node, I went ahead and came up with a generalized easing function that behaves similarly to edit: not sure if the thing about the derivatives is even true |
throwing in smooth min and max for good measures. I think those two functions have been long overdue for implementation xD |
looks intuitive I think. Layering the shading models like that is a good idea.
oops completely read past this. I have added some more changes so if you want to approve them then I think we could merge this into development. |
I feel about the easing functions kind of like I felt with blend functions. For example, I think it would be more useful if easing modes were part of the map range node, smooth min/max may be better if integrated directly into min/max nodes, all types should support them (not just floats), the Common/Math functions should probably be implemented as macros... So I think it would be best if we leave them out for now, so we can merge this asap. |
So smooth min and smooth max would be applied element-wise in the case of vector inputs?
the reasoning behind this is that since easing functions require a fixed range of 0-1, this would make them more useful as part of the map range node?
Sure, its just additional shader features after all and not critical to the node UX but maybe we should still look at them very soon. |
Merged! 🥳🥳🥳
Yep, that's how the min/max functions work too.
Yes, don't you think so? |
This branch aims to improve the Nodes user experience with the help of @Kolupsy.
The goal is to make them work closer to the built-in Blender nodes and the MaltShadingEssentials plugin, while maintaining the convenience of declaring nodes from pure GLSL functions.
In the cases where auto-generation from GLSL is not enough, BlenderMalt specific nodes will be implemented.
Feedback is welcome.
Tasks:
Known Issues:
Custom libraries for specific node trees are not yet supported.(Node Tree Local Libraries are deprecated)