Archived

This topic is now archived and is closed to further replies.

Texture Coordinates When Rendering Landscapes (ROAM)

This topic is 6024 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m just wondering if anyone out there knows of a good/fast way to generate texture coordinates for texturing a landscape rendered using ROAM (or any algorithm where the actual mesh rendered, changes between frames)?

Share this post


Link to post
Share on other sites
I don''t know if this is both ''good an fast'', but here''s what I do:

I use a same sized texture map for the entire terrain. You could use multiple bigger ones, and get more complex, but so far I''m not concerned with how it looks.

Since we have the indicies into the heightmap when we draw triangles I just use those as texture coords.

I generate u,v to pass to OpenGL in the following way:

float u, v;

u = float(x_index)/map_width;
v = float(y_index)/map_height;

You can see that the corner triangles will have texture coords of (0,0), and the extreme corner will have coords of (1,1)..

Looks and works fine. By scaling u,v by whatever you feel you can tile textures easily. Or you could detect when this happens and then use a different texture or whatever you want.


--------------------------
I guess this is where most people put a famous quote...
"Everything is funnier with monkey''''s" - Unknown

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ok, perhaps I wasn''t so clear in my question. The approach you describe is what I have also thought about. I don''t like it however, because the texture will be more stretched on steeply sloped triangles than it will on fairly horizontal ones, so the textures would be more or less distorted, depending on the slope of the landscape.

What I would like to know is if someone knows of an algorithm that produces "better" results. i.e. not projecting a texture down on the landscape, but rather projecting textures onto each triangle....

Then again... it might not look so good, there would be visible "seams" between different polys... Does anyone have a solution to those problems?

Share this post


Link to post
Share on other sites
That''s an interesting point. I''ve never done terrain, but if you drew your texture so that one pixel scales to some fixed ''real world'' length, then you could start in one corner and go along each triangle edge, doing something like:

u2=u1+xv*normlength
v2=u1+yv*normlength

where:

u1,v1=first vertex''s u coord
u2,v2=second vertex''s u coord

normlength=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*z1-z2))/(average length or scale)

xv,yv=normalised x,y direction vectors for the edge between vertices 1 and 2

basically scaling the change in u,v coords along each edge by the length of that edge. Maybe that would work.

Share this post


Link to post
Share on other sites