float2 normd = normalize(vtx_position.xy);
// texture coordinates
float deg = atan2(normd.y, normd.x);
deg = degrees(deg);
if (deg < 0)
deg += 360;
deg /= 360;
l_newUV.x = deg;
l_newUV.y = vtx_position.z;
Btw the sphere has a radius of 1, so that the y coord is correct.
If it helps, this is sort of how it looks now (wireframe overlaid):
http://www.steik.org/dump/uv.jpg
Ps, I know that "deg" is calculated correctly and is always in the range of 0 to 1
Pps.. here is the model, for reference:
http://www.steik.org/dump/icosphere.jpg
UV mapping a sphere in shader
I have a sphere that I'm going to use as a skybox, and I need(because I can't do it propperly in Blender) to generate the texture coordinates in the shader.
I have a 360° texture that I want to wrap around the sphere, similar to this one:
http://mpan3.homeip.net/content/resources/earth-thumb/day-overcast.jpg
Anyway, everything works fine, except where I the texture will "seam" back together, then the texture repeats itself entierly instead of wrapping back to 0.
Not entierly sure how to fix this.
This is how i calculate the coords now (in CG):
(NOTE that coords are Z-up!)
The technique outlined by Robert Dunlop (http://www.mvps.org/directx/articles/spheremap.htm) should work fine for your dome although you'll probably have to make adjustments for the v component.
Regards,
ViLiO
Regards,
ViLiO
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement