Page 1 of 1

Barycentric coordinates in Custom Expression Node

PostPosted: Mon Oct 15, 2018 2:59 pm
by francois85
Hello,

Im wondering if someone can help me with the Custom Expression Node. Im not sure why it is not working. Basically Im trying to use it to blend 3 textures together inside a given triangle.

Im my example I broke it down the the smallest components possible.I pass the 3 points of my triangle (a,b,c) and p (vertex position node). I calculate the barycentric coordinates(u, v, w). Then I check if p is inside my triangle by making sure the sum of u+v+w is <=1 (image has typo of * but I use +). If true I return the desired blend weigh (u,v,w) to a Weighted Blend node and a texture index to my texture array.

Im not seeing any affect, I would expect my triangle to have a different color than the surrounding triangles and have a gradient blend.

Please help I not sure if the Nodes are used correctly

Re: Barycentric coordinates in Custom Expression Node

PostPosted: Tue Oct 16, 2018 7:19 am
by francois85
Ive narrowed it down to the Custom Expression Node. Either its a bug or I have it setup wrong. In the setup below I try and return a float3 to the summed blend node weight and it renders black but when I connect the same values through a vector it works. Im I doing something wrong in the expression?

Re: Barycentric coordinates in Custom Expression Node

PostPosted: Tue Oct 16, 2018 1:41 pm
by Amplify_Borba
Hey there!

From what I can tell by the screenshots you've shared, you'll need to specify the type of the values you're assigning to the variables.

Please consider the example shared below:

Image

In this example, I'm declaring a variable within the function's scope, "myVector", which will be returned through the Out port, and a I'm initializing the custom Out0 output as a different value.

Please let me know if this helps, thanks!

Re: Barycentric coordinates in Custom Expression Node

PostPosted: Sat Oct 20, 2018 5:06 am
by francois85
Very helpful as alway thanks for the reply. I got confuse when the out mode created an input plug but your help got me back on track

Awesome tool love the power it give

Re: Barycentric coordinates in Custom Expression Node

PostPosted: Mon Oct 22, 2018 10:48 am
by Amplify_Borba
No problem, happy to know you're having a good time with ASE!

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, every bit helps and your feedback is extremely valuable to us!

Feel free to get back in touch if you have further issues or questions, thanks!