Preventing stretched textures on terrain

Started by
15 comments, last by Ostsol 20 years, 4 months ago
For a heightmap with vertices that have shared texture coordinates there really is no way to avoid the texture stretching. A solution would require splitting the hightmap up into smaller patches in a manner that each patch was comprised of only vertices that could support shared texture coords. This would allow you to alter the texture coordinates for the steep areas to get rid of the stretching.

Of course, I could be wrong, but AFAIK theres no easy way around the problem.

-=[ Megahertz ]=-
-=[Megahertz]=-
Advertisement
Hi again Ostsol. Well I looked into this more and it seems my original idea was a little too simple. My mistake. Sorry. :-)

I spoke to a friend who did some university research on UV mapping last summer. He came up with a method that works quite well, but the math involved is complex. It involves eigensystems/PCA. Are you familiar with that? If you want to give it a shot, let me know and i''ll send you the details. But just so you know, it''s not something that will be easy to implement unless you''re using matlab. :-)

shadow
Well, I''m willing to try. . .
-Ostsol
There is no good way to fix it. Even the most advanced games (Asheron''s Call 2 for example) pretty much ignore it and let the stretching happen. Yann L mentioned something a while ago about adjusting uv coordinates with his bezier patch terrain that let him fix it but I don''t know if he went into any details.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Hi Ostsol.

Here is one method that will give you reasonably good results, but its only practical for low vertex counts for obvious reasons.

build an adjacency matrix for the vertices(edges).

Below is a matlab function that takes that matrix, and minimizes the error in the distances between vertices. It returns the texture coordinates. You will need an understanding of some graph algorithms (dijkstra) and eigensystems to understand what is happening.

I didn't write this code (my friend did), but I understand it if you have questions.

function texcoords=MDStexgen(edges)

N=size(edges,1);

diss=zeros(N);
for(j=1:N)
[d p]=dijkstra(edges,j);
diss(:,j)=d;
end

diss(find(isinf(diss)))=1;


J=eye(N)-(1/N)*ones(N,1)*ones(1,N);
B=-0.5*J*(diss.*diss)*J;
[v,e]=eigs(B,2);
texcoords=v*sqrt(e);



[edited by - shadow_bobble on December 14, 2003 12:11:01 AM]
Hmm. . . Perhaps I''ll just stick with stretched textures. . . Besides, my polygon counts are pretty high.
-Ostsol
I know how to manually compensating for UV stretching in a 3D editor, by stretching the UVs on slopes. This means compressing the UVs on level areas to get enough space for the stretched areas.

Maybe you could use the vertex normal as an offset for the UV coordinates?
______________________________________________There are only 10 types of people in the world: Those who understand binary, and those who don't.

This topic is closed to new replies.

Advertisement