# Spherical Mapping HELP!

Hello everyone.

I'm new to this forum and it looks like a great place to find useful information and help. I thought I would post my question here and see if some of you could help me. I am (somewhat) new to programming so please bear with me.

I am coding a photoshop plugin in which I want to take an image and map it into a spherical system. Just like spherically texture mapping a sphere in any 3D software, only since we will always be looking at it from the front, there is not need to code rotation, scales, etc.

Anyways, I have been looking everywhere for the algorithm to do this, which I assume must be fairly easy, but have had no success. I found the code for the farmiliar 'lens effect' which we all have seen in popular screensavers, but that is a different effect than the one I'm going for.

So my first question is, does anyone know a simple algorithm (even if it is a hack) to do this?

My second question is:

Below, I have the Pseudo-code which sort of gives me what I need. It maps the image into a sphere, but the lower half of it get garbled. I was wondering if anyone could point out what I am doing wrong. I'll post the code below, but remember that this is for FilterMeister, a photoshop C-based compiler so it may not work on other compilors. Still, it should give you an idea of where I am, if I am going in the right direction, and where I have my bug. If you wish to see it in action, simply download the FilterMeister photoshop plugin from http://www.filtermeister.com and insert this code.

%ffp

ctl[1]: "Red",fontcolor=black, range=(0,255), Size=(60,*), pos=(255,50), val=90, track

forEveryTile:
{
float PI=3.141592654;
float TWOPI=6.283185308;
double um,vm,z;
int x,y;
z=0.5;

for(y=0;y=0)
else
um=um*X;
vm=vm*Y;

pset(x,y,0,pget((int)um,(int)vm,0));
pset(x,y,1,pget((int)um,(int)vm,1));
pset(x,y,2,pget((int)um,(int)vm,2));

}
}

return true;
}

Well, that's it. I have been puzzling over this for a week now, so ANY help will be GREATLY appreciated. Thank you to everyone in advance!

-Richard