# Convert Object texture coords to Polar

I am building a procedural eye texture setup based around Object coordinates. As part of the project, I am trying to re-create a setup that is normally used for UV textures.

This tutorial shows how to re-map Rectangular coords to Polar in order to have a procedural texture radiate out from the center of the eye: https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Advanced_Tutorials/Procedural_Eyeball_in_Cycles

I am trying to re-create the same effect, but using Object Coords instead of UV. Is this possible?

• How about a color ramped circular gradient? – Duarte Farrajota Ramos Jan 17 '18 at 13:26
• It should be the same as using UV except that you won’t need to subtract 0.5 to move the origin as object coords are already centred around zero - ie, simply use arctan(y/x). – Rich Sedman Jan 17 '18 at 14:10
• @RichSedman Thanks. I've tried removing the subtraction and I'm still not getting the proper result. Can you post an answer with the nodes? Thanks. – Drudge Jan 17 '18 at 21:30
• @Drudge I've added an answer to include additional nodes to convert to properly to the range 0.0 to 1.0 (the arctangent returns radians for only half the rotation so needs some conversion). Hope this helps. – Rich Sedman Jan 17 '18 at 22:05

You can convert Object coordinates into Polar coordinates using the 'arctangent' trigonometric function by using :

arctangent(y/x)


This will produce a result in Radians (where there are pi radians in 360 degrees) although without additional nodes it will only produce results for half the rotation (and will produce negative values).

The following nodes should produce a result that varies from 0.0 to 1.0 :

To explain this a bit, the Object coordinates are split into the separate X, Y, Z components and the Divide node used to generate Y / X. This is passed to the Arctangent node which produces the angle (in radians) between -pi/2 and pi/2 for half a rotation (for the second half it repeats -pi/2 to pi/2). This is divided by 2*pi to convert it to the range -0.25 to 0.25 and 0.25 added to shift the range to 0.0 to 0.5. The Less Than node is then used to detect the second half of the rotation and add 0.5, resulting in the full rotation mapping from 0.0 to 1.0 producing the result shown in the image above.

Blend file included

The other half of the polar coordinates is the distance from the origin. This is simple to achieve as sqrt(x^2 + y^2) as follows :

Combining these into a nodegroup to allow it to be easily reused results in the following :

Using the nodegroup to build a procedural eye texture can produce the following :

Blend file included