I’m rendering a volume Earth. When I limit the uv to a certain latitude and longitude range, the texture boundaries stretch outward as shown.
How do I modify the code to remove this stretching?
The online demo is as follows
here
I’m rendering a volume Earth. When I limit the uv to a certain latitude and longitude range, the texture boundaries stretch outward as shown.
How do I modify the code to remove this stretching?
The online demo is as follows
here
For prevent this stretching you need to set values on the edges of your texture to fixed falue.
I added this line to your code after line 72 and the stretching is gone.
if (!(x*y%(size - 1))) d=0;
Sorry for ninja coding…
Thank you, the stretching has gone.
codepen.io/trushka/pen/GRVRvEj
I removed
bool withinLat = (lat >= uMinLatLon.x - PI / 2.0) && (lat <= uMaxLatLon.x + PI / 2.0);
bool withinLon = (lon >= uMinLatLon.y - PI) && (lon <= uMaxLatLon.y + PI);
because we can smply checks uv and don’t change pixel color, if uv is out of the range (0, 1). computeuv() returns already clamped value so we need to check that uv is not equal to 0 or 1.
And there is also no need to set constant values on the edges of the texture.