Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float3 TexToSphere(float x, float y, float width, float height)
- {
- float temp = y;
- y = x;
- x = temp;
- float southLatBound = -180;
- float northLatBound = 180;
- float westLonBound = -90;
- float eastLonBound = 90;
- float lonExtent = eastLonBound - westLonBound;
- float latExtent = northLatBound - southLatBound;
- float xDelta = lonExtent / float(height);
- float yDelta = latExtent / float(width);
- float lon = westLonBound + xDelta * x;
- float lat = southLatBound + yDelta * y;
- float r = cos((3.14159 / 180) * lon);
- float xp = r * cos((3.14159 / 180) * lat);
- float yp = sin((3.14159 / 180)* lon);
- float zp = r * sin((3.14159 / 180) * lat);
- return float3(xp, yp, zp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement