Looking for opinions on handling texture coordinates (tu/tv)

Started by
9 comments, last by QuadMV 18 years, 9 months ago
I have a dilemma with my terrain engine and I’m looking for some opinions on how to best handle it. I’ve noticed that for textures close, I want to tile them more heavily so they appear more hi-res. However, for the terrain that is further away, this doesn’t look good, so as the terrain gets further I want to decrease the tiling and stretch more of the texture as it fades into the distance. My dilemma is that the texture coordinates are imbedded into the triangle strip, which is then stored into the vertex buffer. I’m currently pre-creating all of this and I’m getting great frame rates out of my terrain. I think the only way to do what I’m suggesting is to modify the vertex buffer on ever frame, or at least every few frames, and recalculate the tu/tv based on a simple distance algorithm. I’m concerned that this will have too great an affect on my frame rate? Any suggestions, thoughts or ideas are welcomed. Thanks, QUAD
3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.
Advertisement
I suppose you could do the modify the UV data dynamically (which will affect the performance of course), but I'm just wondering... hasn't mip-mapping helped at all?
"There is no dark side of the moon." - Pink Floyd
Wouldn't changing the texture coordinates have very very strange effects when walking the terrain? (Such as comparable to popping/morphing with meshes)

As changing the resolution would also make e.g. grass look close when far away as you have made it larger (like the triangles close to you).

I would say, creating your own (sharper) mipmaps would do much better. Or changing textures at different depths to compensate.


I agree with Syranide, changing UV-coordinates dynamically when you move around would definitely look strange, as if the terrain would be morphing, like those neat slimy alien landscapes :) But as I think that´s not the thing you´re trying to achieve, I wouldn´t do that, and it would probably be a bad idea performance-wise anyway....
First of all you should get a texture with less obvious tiling "artifacts", if possible with higher resolution, so you don´t have to tile it that often. Second thing I´d try is to blend a second texture over it, perhaps with an alpha map based on some random function (like Perlin Noise or something like that). That should make tiling far less obvious.
As Specchum mentioned - have you looked into the possibilities of Mip-Mapping?

It's been ages since I've needed to bother with such things, but I was reading a thread on DIRECTXDEV a week or so back about being able to bias the LOD, such that if (by default) all terrain was set to LOD==3 you could, conceivably, have 2 higher detail textures for use nearer the camera and then at least a few more for the distant geometry.

EDIT: IDirect3DTexture9::SetLOD( )

I'd definitely look into exploring MipMaps - they essentially do what you're trying to emulate, and I'd be surprised if they weren't an order of magnitude faster than modifying your UV's [grin]

One other thing... for the texture popping artifact, you can try lerping between two textures in two texture stages to "fade" rather than "pop" between the LOD's. I had the code to an engine that did this quite nicely [smile]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

If you decide you really do need to modify UV coords on the fly, look into vertex shaders.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Thanks for all the replies. You might be right in that changing the texture coords is visible, but my expectations are such that it might be less obvious than what you are all expecting. I'm not talking about large jumps but subtle changes based on distance. Since most of your attention would be to your local surroundings, having the local tiling remain maxed that you always see the same hi resolution for local terrain will minimize any popping (I think).

Mipmapping in my experience is providing the look I want. I am using it to blur/soften/smooth the distant textures which is working correctly. However, I have found when I manually stretch the distant textures they look a lot better. The problem is when I walk close to them I no longer want them stretched.

I put together a test that has produced promising results. I'll post either some screen shots and/or a demo executable that will demonstrate my findings.

Specchum, do you have any more details on vertex shaders that you could provide? I am using a pixel shader to perform the terrain texture blending (splatting) but that was mostly copied code and I don't know it well enough to understand how it would help here, or what the technical differences are between a pixel shader vs a vertex shader.

There were a few comments about blending textures to minimize the tiling effect, and this does work where many textures are blended, but where I have a very grassy field, or a dirt road, or an area that is highly repetitive, the patterns in the textures stick out like a soar thumb.

Thanks

3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.
Quote:Original post by QuadMV
Specchum, do you have any more details on vertex shaders that you could provide?



I think you refer to superpig. :) I myself am not sure how such a vertex shader could be implemented. Changing the UV co-ords in the shader is simple enough but what logic would be at the core?
"There is no dark side of the moon." - Pink Floyd
Quote:Original post by QuadMV
Thanks for all the replies. You might be right in that changing the texture coords is visible, but my expectations are such that it might be less obvious than what you are all expecting. I'm not talking about large jumps but subtle changes based on distance. Since most of your attention would be to your local surroundings, having the local tiling remain maxed that you always see the same hi resolution for local terrain will minimize any popping (I think).


My point was that, oh everyone is so happy, you are running on this beautiful hill with flowers on the ground (in the textures) and everything is soooo pretty, and then you look to the horizon and see the very same flower 1km away, but still looking just as large (or just very large).

So if one is going to perform this it should be rather cruical that you do not have objects/patterns in the textures which can easily be recognized (as for looking brutally big).


You might want to look into something called "detail texturing". It basically adds more texture detail for up-close things.

This topic is closed to new replies.

Advertisement