-
Notifications
You must be signed in to change notification settings - Fork 365
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
Add triangle wave node #1334
Add triangle wave node #1334
Conversation
This node creates values from 0.0 to "Scale" based on input value.
Adding in procedural2D Herringbone Tilling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cinifreak This sounds like a good proposal for a new node, though I wonder if trianglewave
might be a clearer name than pingpong
, extending naturally to squarewave
and sawtoothwave
in the future.
I don't have a strong opinion on this, but here are two references that I found for the trianglewave
alternative:
https://dev.epicgames.com/community/snippets/o4A/unreal-engine-triangle-wave-material-function
https://docs.unity3d.com/Packages/com.unity.shadergraph@12.1/manual/Triangle-Wave-Node.html
changing name from ping-pong to triangle wave.
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Should this node be in the "procedural2d" category, rather than "math", as it seems to mainly be an image generator as opposed to doing a math-like operation on an input value? |
@dbsmythe Triangle wave is defined as a math node in other softwares. that's why i put it there. It's a mathematical operation after all. |
@jstone-lucasfilm Should i inverse the amplitude value? |
@Cinifreak Ah, I see what you mean now. The My sense is that we should make these two independent inputs that the artist can control, though this requires some modifications to the graph implementation. In the future, this would allow an artist to swap between different wave nodes (e.g. triangle, sawtooth, square), keeping the same Does that sound like a reasonable approach to you as well? |
@Cinifreak Let us know how the suggestions above sound to you, and we're happy to assist with the generalization of this node to support both |
Recreating the nodes with `Frequency` and `Amplitude` as separated inputs.
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
This latest version looks excellent, thanks @Cinifreak! Before merging this change, I wanted to check with you and @crydalch about the best name for "frequency" node inputs in MaterialX. In the Unified Noise nodes that @crydalch recently contributed, he used the name MaterialX/libraries/stdlib/stdlib_defs.mtlx Line 1001 in cdd53d2
Should we follow this same convention for the new |
Yes it would be better to follow @crydalch naming to unify it across all nodes. Just confirm that and i will change it for this PR and consider this for any upcoming nodes PR in the future! |
Sounds good, thanks @Cinifreak, and let's move forward with the convention for frequency inputs that @crydalch has set. |
Changing name and Ui name for `frequency`
- Switch from "frequency" to "period", which simplifies the math and better aligns with reference implementations in DCC packages. - Remove an extra multiply in the graph implementation. - State nodes in processing order for clarity.
@meshula @Cinifreak Maybe we're overthinking this, and the best answer is the simplest? Looking at other wave nodes in material graph editors, it looks like the most popular interface is to provide no controls at all, and to rely upon the artist to add nodes when they need additional scale or bias features. As one example, here is the presentation of wave nodes in NodeToy, where all wave nodes have the same minimal interface as a sine wave: |
Following that approach, what if we were simply to remove both the I like @Cinifreak's choice to generate triangle waves with a period of one and output values in the [0-1] range, which seems consistent with triangle wave nodes in applications in the industry. |
@Cinifreak Could we take this even further and remove the |
But how will the user control the increment value ? |
@Cinifreak In Unity and NodeToy, for example, the artist just adds a |
I think we have misunderstanding here. The scale here is not a multiplier. |
@Cinifreak In your original proposal, the scale input affected both the Does that approach seem reasonable to you? The advantage of splitting this out into separate artist-created nodes is that we don't create extra behavior inside the node that artists may never use, but that they'll still pay for every time they place a |
This changelist simplifies the triangle wave interface to a single scalar input, following the most common approach in DCC tools supporting this node.
@Cinifreak I've made the change described above, and let me know how this looks to you. This seems like the leanest possible implementation of |
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Thank you for that effort. I will give it a test and let you know ASAP. |
@jstone-lucasfilm I like the notion of treating "any" wave as one would treat a sine function, i.e. the input to a triangle wave spans one cycle over [0 .. 1] (as opposed to over 0 to 2*pi), and the output is ranged between 0..1. Given this simple formulation, it would make sense to me to add sawtooth (with a "rising" flag), and square (with a "duty cycle" parameter). Then you'd have the usual set of sin, saw, tri, and square. I can't decide if it's confusing or not that a sin completes a cycle over a circle, and the proposed new generators cycle over zero to one. I think it's probably not confusing, and 0...1 is definitely less confusing than wondering if sine takes radians or degrees. (sawtooth rises, or falls, as noted earlier) |
Completely agree, @meshula, and I think this proposal makes a great template for additional wave nodes in the future. In particular, For |
Rather than add a |
I totally agree with @dbsmythe. I think what we have now is another behaviour that could be helpful if we have all the waves set in one node not just this triangle wave as a single node. |
@Cinifreak I'm not sure I fully understand what you're suggesting in the post above. I like @dbsmythe's proposal to omit Let me know if the current pull request looks good to you, or if there are additional changes that should be made before we merge! |
I tested the final edit. I still seeing that we have to let user control how many periods he needs at least. I pushed another update with just two inputs |
@Cinifreak Couldn't the artist just multiply the input by Although I'm open to adding useful controls, I'm noticing that the As @dbsmythe notes above, we can always design very high-level wave nodes later on, providing a very rich set of controls and options, but that doesn't necessarily mean that our underlying core nodes need to provide them as well. |
I tested to do |
@Cinifreak If you want to get the effect above, then you should just multiply the input by five, effectively making the period 1/5. I'll go back to the earlier implementation for now, and I'll see if I can post a screenshot using the technique described here. Thanks for all of your work on this node, and I think it should be very useful! |
9de2b4d
to
70ec304
Compare
Oh, Okay I understand the technique now. Thank you for you patience. Let's Merge the earlier implementation. Thanks again! |
This reverts commit 9de2b4d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ready to go, thanks @Cinifreak!
This node generates values from zero to one based on the input value.
This node creates values from 0.0 to "Scale" based on input value.
![Screenshot 2023-04-19 175951](https://user-images.githubusercontent.com/31315913/233133393-97694dd2-a768-4172-b211-152b1e9a0773.png)
Example: using ping-pong node with scale=0.18 over "V" component.