<p>A few options:</p>

<ol>
<li><p>Make the 0-1 discontinuity explicit in the mesh. That is create a 2 sets of vertices that lie exactly on the line where the value would be 1 or 0 (one set gets 1 and one gets 0) then connect the vertices up like they would makes sense.</p></li>
<li><p>Switch to a different texture mapping projection, I prefer a cubemap because it minimizes distortion at the poles and you don't need to have seams in the mesh.</p></li>
</ol>

CC BY-SA 4.0
2019-04-05T15:57:45.490Z
2019-04-05T15:57:45.490Z
ratchet freak
<p>I am trying to generate UV coordinates automatically to map a texture on a sphere.</p>

<p>The problem is with seams when going from 0.8 to 0.2 there is a discontinuity and interpolation in fragment shader is incorrect. It should go from 0.8 to 1 and then from 1 to 0.2. But instead it will interpolate directly between 0.8 to 0.2.</p>

<p><a href="https://en.wikipedia.org/wiki/UV_mapping" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/UV_mapping</a></p>

<p><a href="https://i.sstatic.net/2HK25.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2HK25.png" alt="enter image description here"></a></p>

<p><a href="https://i.sstatic.net/UPDcX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UPDcX.png" alt="enter image description here"></a></p>

<p>How to handle this discontinuity from 1 -> 0.</p>

<p>Here is what is currently happening at the seams 
<a href="https://i.sstatic.net/6Fg4m.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6Fg4m.png" alt="enter image description here"></a></p>

<opengl><shader><texture><uv-mapping><directx>
Sphere Texture Mapping Algorithm
Prototype
# Sphere Texture Mapping Algorithm

(Asked by: username_0 on 2019-04-05)

I am trying to generate UV coordinates automatically to map a texture on a sphere.

The problem is with seams when going from 0.8 to 0.2 there is a discontinuity and interpolation in fragment shader is incorrect. It should go from 0.8 to 1 and then from 1 to 0.2. But instead it will interpolate directly between 0.8 to 0.2.

<https://en.wikipedia.org/wiki/UV_mapping>

[![enter image description here](https://i.sstatic.net/2HK25.png)](https://i.sstatic.net/2HK25.png)

[![enter image description here](https://i.sstatic.net/UPDcX.png)](https://i.sstatic.net/UPDcX.png)

How to handle this discontinuity from 1 -> 0.

Here is what is currently happening at the seams
[![enter image description here](https://i.sstatic.net/6Fg4m.png)](https://i.sstatic.net/6Fg4m.png)

**Tags:** opengl, shader, texture, uv-mapping, directx


---

## 1 answers

### Answer by username_1 on 2019-04-05. Score: 1

A few options:

1. Make the 0-1 discontinuity explicit in the mesh. That is create a 2 sets of vertices that lie exactly on the line where the value would be 1 or 0 (one set gets 1 and one gets 0) then connect the vertices up like they would makes sense.
2. Switch to a different texture mapping projection, I prefer a cubemap because it minimizes distortion at the poles and you don't need to have seams in the mesh.


---

