Hi I’m working on a material, and I am trying to avoid custom node (because it might be slower). However at some point I want to calculate an angle, but I noticed there is no atan2 node or any other tangent node in the material editor. There are sin and cos nodes though. Why is this not there, or is it under a different name?
Hello BramV,
In order to further understand this issue I need a little more information.
1.) What are you trying to accomplish with this material?
2.) Why are you needing to calculate an angle and for what purpose?
3.) Can you link a screenshot of your material?
After I have this information I believe I can answer this question better.
I’m making a material that has a circular wave (ripple) on it, by manipulating the normals and some texturing deformation. The angle that I use in the calculation is the angle between the current pixel (in uv coordinates) and the center of the wave (in uv coordinates).
I’ve made it in a custom node which worked fine, but I thought it might be faster to only use internal nodes. I did already find a way around calculating the angle, it’s not 100% neccesary for what I wanted, however atan2 is a intrinsic HLSL function, and I see no reason why UE wouln’t have a node for each intrinisic HLSL function.
I find your question therefor kind of odd (but I seen this question often: why do you need it, what are you making? who cares what it;s for if it’s basic functionality that UE is lacking?). It’s like you are trying always to find alternatives for what users want, instead of just implementing basic functionality and letting the users do what the want to do…
Instead of wondering what I’m trying to accomplish it would seem more logical to wonder; yeah why would we implement cos and sin, but leave out tan??? makes no sense to me…
Those decisions are based off of hour calculations to how our systems calculate information. Sometimes we have to use alternative methods because it interferes with UE4’s basic functions. For this instance, however, I believe since you have already found a work around this is a feature request.
I can enter one for you. I cannot guarantee that it will be implemented nor guarantee that it will be a feature inside the current engine.
Would you like me to do this?
Yes I think it would improve the overall usefullnes of the engine if all basic HLSL functions are implemented as nodes. Thanks.
Alright, there is a ticket in for a Tangent material node like there is for sine and cosine.
The ticket number is UE-21943.
We might expose “tan” at some point but you can make a Custom node and expose it material function (with the checkbox to make it appear in the list). That is likely what we would do anyway. Sin and Cos have been made before material functions - this is why they are different.
Mr. Marting Mittring, I have one note on why it should be a priority: You can not use custom nodes for Tessellation Shaders, or not easily at least. Therefore with the simple HLSL custom code solution, would prove entirely invalid in that case.
Hi.
In math, Tang is the division of Sin over Cosine (Sin/Cosine). Actually there is a node called divide. I believe by dividing Sin by Cosine (linking Sin to pin ‘A’ and Cosine to pin ‘B’, you should have your Tang function in result. Here take a look at my graph for instance.
An important thing that you should note, is that both Sin and Cosine nodes have to link to a same node, otherwise you won’t have the correct result. Actually this is all a theory I’m not pretty sure that in materials this is going to work. But in math it does. ;D
Regards.