Cyanilux / ShaderGraphVariables

Adds 'Register Variable' and 'Get Variable' nodes to Shader Graph, allowing you to link sections of a graph without connection wires. <3
MIT License
264 stars 24 forks source link

Feature Request: Explicit Types #10

Closed maldorse closed 1 month ago

maldorse commented 8 months ago

Great package! Very helpful.

It would be great to be able to choose type explicitely. Float, Vector2, Vector3 etc. This could be housed in the graph inspector panel, under the node settings tab. When you select a Register Variable node, you'd see and set its type there.

Thank you!

Tehenauin commented 1 month ago

This would be really helpful. In my case I need a float and having it converted to a vector4 doesnt help.

Cyanilux commented 1 month ago

It does currently support both Vector4 and Float, but as most math nodes use a "DynamicVector" port type it seems to default to Vector4, unless the value is passed through a Float node before connecting to the Register Variable.

Ideally it should check the type of the DynamicVector. I'll try looking into it to fix that issue. (Honestly thought Shader Graph would implement their own portals which is why I haven't bothered)

As for supporting Vector2/3 that would mean adding two more ports to the subgraphs (which gets hidden, but is still a bit of a messy solution). But we'll see.

Tehenauin commented 1 month ago

couldn't you alternatively make one node for every different type?

Cyanilux commented 1 month ago

Technically yes, but would be a lot of rewriting. I think having it automatically switch between the vector types would be more convenient anyway.

I found that the code already contains the type checking for dynamic ports, but commented it out as it introduced another bug. Though in hindsight I don't think it's that much of an issue. I'm working on adding Vector2/3 types too now.

Cyanilux commented 1 month ago

Okay, main branch has been updated - should now switch between Float and Vector types correctly when connecting Dynamic ports, including Vector2/3. Hopefully it doesn't break anything