make input uvs centered and scaled to -1 to 1įixed4 col = tex2D(_MainTex, uv) * _Color As a small addition, I divided the angle by 2pi to make it go from -0.5 to 0.5, instead of -pi to pi, which is usually a more annoying number to work with. I put it in a function in a include file for reuse, but you can of course put the function in your shader file, or even do the calculations inline. So we use the the atan2 to calculate the angle and calculate the length of the position for the distance and store it in a float2 (I used that because its convenient, you can also build your own struct for that if you prefer that). While in cartesian 2d space the 2 variables we use are the “right-ness” as well as the “up-ness”(or “down-ness” depending on context), in polar coordinates the 2 variables are the angle around the center and the distance from that center. While you manipulate polar coordinates, remember that not all rules from geometry in cartesian coordinates apply, but I encourage you to play with all ideas you have and see what happens.Ĭonverting cartesian to polar coordinates □︎ Now I want to introduce you to polar coordinates, how to convert to and from them and show you how to use them. That pushing things to the right, pushes them to the right, up is up etc… This is called “cartesian coordinates”. There were multiple spaces of those like object, world, screen, uv space and maybe more but the base rules were always the same most of the time. So far whenever we used coordinates we had a clear grid of 2 or 3 axes in which we could manipulate things and push them around.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |