0
Completed

atan2 without discontinuity

TheMasonX 9 years ago updated 9 years ago 8
Not technically a bug, as it's a part of the atan2 output, but when I try to use polar coordinates, or turn the position into a UV coordinate, I get a nasty pixel wide error along the -x axis due to the discontinuity. I can't seem to find any info on avoiding this, especially in a shader, and I was wondering if you could help. I'm out of places to turn, and I need this to work for my job. Thank you very much in advance.

Answer

+1
Answer
Completed
Found the issue.
This isn't a problem in atan2, this is a problem in how the GPU finds which MIP level to use in the texture. If you connect the MIP input of the Texture 2D node, the artifact goes away :)
+1
Under review
I've wondered this as well recently, I'll look into it
Wow, thanks for the lightning fast feedback! I just want to say that I love Shader Forge by the way, it has made making custom shaders the best part of my day, as I can get amazing results with minimal work, and can focus on the creative bits and fun math rather than trying to setup all the dependencies and figure out why things aren't compiling correctly.
My image didn't show up. The problem, and the code that's generating it.


+1
Answer
Completed
Found the issue.
This isn't a problem in atan2, this is a problem in how the GPU finds which MIP level to use in the texture. If you connect the MIP input of the Texture 2D node, the artifact goes away :)
Awesome! Thank you so much! :)
+1
I did update ArcTan2 now for 1.18 though - you can now select between these:



I saw that, good job! Saves a few nodes of setup and clutter for doing something fairly common. Love all the new nodes and fixes too; my coworker and I have been going over them and what we plan to do with the stencil buffer all morning, it's like Christmas in August :)