-
Notifications
You must be signed in to change notification settings - Fork 358
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 distance math node #1333
Add distance math node #1333
Conversation
Adding distance math node to measure the distance between two point in(X, Y)
|
Hi @Cinifreak, This appears to be a variant on the existing Or is there a requirement to work with colors ? But vec can be converted to color. Just unsure of the intent based on your example images. Thanks. |
@kwokcb Thank you for your feedback, I know there is a magnitude node and it results a vector length (knowing that the reference point is (0, 0) ), but i think we need a distance node too to measure the length between any two points. the other thing is for some reason magnitude node doesn't work with houdini GL, but the distance node work in both cases (Karma & GL). |
Sorry, missed that I'm wondering if magnitude could be extended or repurposed to have a second point with a default value of the origin (for compatibility). Adding @jstone-lucasfilm , @dbsmythe as it would be nice to not add in another node which is very close to an existing one. Otherwise it would be nice to make |
Sure, you have a point, but as a user, I used to use length node for getting the vector length, and use distance node if I have two vectors. It's easier for the user to see them separately, specially if I don't know how distance function works. But I agree with you, one node to do both functions will be great for sure. |
I see your point of I guess another point in favour of separation is that these can map directly to shader intrinsics. The graph approach makes it shading language agnostic but it would be nice to use intrinsics if performance is affected. ( BTW, Sorry if I'm sounding nit-picky on this. There's just a lot of nodes already in the library :). |
my point is to have Magnitude(and naming it length) and distance. or to have one node called distance only. and about you being nit-picky, sure it's good for the library to be organized and matches the user requirements. so, It's great to have your feedback always. |
A dedicated distance node makes sense to me. I don't know that we need to rename magnitude, but I think both make sense for users to have at-hand. |
@crydalch Agreed, I'd support the idea of having both |
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 very promising, @Cinifreak, and I have two suggestions for improvements:
- I'd recommend defining the
distance
node with two vector2 inputs namedin1
andin2
, which will align with other nodes in the math library, and should extend naturally tovector3
andvector4
distance nodes in the future. - In the implementation of the
distance
node, I'd recommend using themagnitude
node to perform most of the work, so that the definition becomes a simple composition ofsubtract
andmagnitude
.
As change request I have changed the inputs from 4 float to 2 vec2 and creating a node graph including Magnitude.
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 proposal is coming along well, and here are a few additional recommendations that I would make:
- Rename the new node from
Distance
todistance
for consistency with other standard nodes in MaterialX. - Rename the two inputs to
in1
andin2
for consistency with other math nodes. - Possibly add
vector3
andvector4
variants of this node as well? I'm open to ideas on this, but it would seem natural for an artist to expectdistance
to work on any two vectors of the same type.
Changing node name from "Distance" to "distance", inputs from "input" to "input". Adding vector3 and vector4 to the node.
Signed-off-by: Jonathan Stone <[email protected]>
Signed-off-by: Jonathan Stone <[email protected]>
Signed-off-by: Jonathan Stone <[email protected]>
Signed-off-by: Jonathan Stone <[email protected]>
Signed-off-by: Jonathan Stone <[email protected]>
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 good to me, thanks @Cinifreak!
Adding distance math node to measure the distance between two points.
Adding distance math node to measure the distance between two point in(X, Y)