Renderman Shading Language has a great potential to create custom image filters. Powerful mathematical functions in conjunction with the ability to access the coordinate information of every point in an image, gives the user a wide freedom to produce and modify different effects. This page demonstrates creating what most digital artist know as "Polar Coordinate" filter which converts the coordinates of an image from Cartesian to Polar or vice-versa.
|
Definition of Polar Coorditane System: |
||
![]() |
In mathematics, the polar coordinate system is a two-dimensional coordinate system in which each
point on a plane is determined by a distance from a fixed point and an angle from a fixed direction. |
|
|
Conversion between Polar and Cartesian Coordinates: |
||
![]() |
The two polar coordinates r and θ can be converted to the Cartesian coordinates
x and y by using the trigonometric functions sine and cosine: |
|
|
RSL implementation |
||
surface
Polar(float Kfb = 1,
RecToPolar = 0; /* [0 or 1] */
string mapname = "")
{
color map = 0.0;
float ss1 = 0.5*(1-t*sin(2*PI*s));
float tt1 = 0.5*(1-t*cos(2*PI*s));
float ss2 = (atan((s-0.5),(t-0.5))+PI)/(2*PI);
float tt2 = 2*sqrt(pow(0.5-s,2)+pow(0.5-t,2));
if(mapname != "") {
if(RecToPolar == 0)
map = texture(mapname,ss1,tt1);
else
map = texture(mapname,ss2,tt2);
}
Oi = Os;
Ci = Oi * Cs * map * Kfb;
}
|
This is the implementation of mathematical formulas in RSL which is arbitrarily called "Polar".
There is a points to be considered while calculating the conversions: |
|
|
Polar to Rectangular Conversion |
||
|
In Polar to Rectangular conversion we have to use the first set of the above formulas. |
||
|
Rectangular to Polar Conversion |
||
|
In Rectangular to Polar conversion we use the second sets of formulas. |







