Strange dots appearing in ProceduralTexture


I am converting a map of the Earth given as a longitude/latitude map into a sprite sheet for icospheres.
The conversion is done with a ProceduralTexture.

In the stripped-down playground example I am only using a single triangle, namely triangle 4 in the top left corner of the sprite sheet.

There is a strange effect displaying dots along the 0° meridian, which I do not understand. The dots do not occur in the input texture and the 0° meridian is not at a border. (Actually the 0° meridian is in the

With variations of the code I was able to move the dots elsewhere in the output, but could not get rid of them.

Does anyone have an idea where these dots come from and how to get rid of them?


Welcome aboard!

There’s a discontinuity at x=0 for atan:


When doing texture(base, vec2(lon / ${TAU}, lat / ${TAU/2} + .5)), the GPU uses the (u,v) values from this call + the (u,v) values for the neighboring pixels to calculate derivatives to choose the right mipmap. At the discontinuity point, this calculation will be wrong and a wrong mipmap will be chosen.

The easiest fix is to disable mip mapping (3rd parameter of Texture constructor):

Or you can try to calculate the derivatives yourself and use textureGrad instead of texture.

Thanks a lot. That solved my problem.

I was aware of the atan discontinuity, but thought that this is no problem with
baseTexture.wrapU = B.Texture.WRAP_ADDRESSMODE;
(and of course with using the two-argument atan instead of the 1-argument variant).

I would never have thought of a mipmap issue, in particular since I was not aware that mipmaps are enabled by default.

Just in case that anybody having a similar problem stumbles over this thread:
My playground version is stripped down even more and contains the fix (disabling mipmaps).

And if you’re curious, here’s the application: Sphere Texturing.
Select triangulation method “[babylon] icosphere” to see that there are no more dots.