Jump to content
  • Advertisement
Sign in to follow this  
WebsiteWill

Texture Layering and Tiling Question

This topic is 4233 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

Morning everyone: What would I have to do in XNA to tile a texture over a terrain such that I have a base texture stretched over the entire terrain (maybe tiles a couple of times) then I want to blend other textures with this base (and possibly with themselves). Do I need to export my model from Max with multiple UV coordinates or do I write a shader that just "knows" that I want to apply texture 1 over the entire terrain (tiled x times) and then blend textures 3 and 4 using texture 2 as a mask, etc, etc as many layers as I need to go? Also I want the option of doing things like making texture 3 a little shiny and reflective or other effects. Seems like this would not be too hard to do with shaders but, so far, everything I am reading seems to point back to needing texture coordinates when you export the mesh from Max. However, if I have multiple UV sets then I get confused about how I would make sure the right UV set get used with the right texture, and then there's still the issue of blending. Thanks for the ideas. Webby

Share this post


Link to post
Share on other sites
Advertisement
You don't need texture coordinates for terrain. Just use the local or world 2D vertex position coordinates in the shader (ignore the vertical coord). For example, if you use XZ for your horizontal directions, do something like

TextureUV.u = Pos.x * scale;
TextureUV.v = Pos.z * scale;

Where "scale" is a constant you chooose that determines how stretched your texture is.

That will look a little funny for steep hills though.

Share this post


Link to post
Share on other sites
Yeah, but keep in mind that I am modeling this terrain in Max and not using anything like a heightmap. Steep cliffs, overhangs, caves, etc are all a possibility with this. So just using the X and Z coordinates doesn't seem like it would work for me very well, unless I am missing some point here.

Webby

Share this post


Link to post
Share on other sites
jaafit's idea is only likely to be robust on classic height-map terrains.

In your case, a more "triangle soup" approach you'll almost certainly need multiple UV's. The only situation where you can avoid this is if you can write shader-code that derives/computes additional sets of UV's from one or more base sets. That is, all UV's are mathematically related.

Do some research into Texture Splatting - might not be exactly what you want, but it should at least give you some ideas and directions...

hth
Jack

Share this post


Link to post
Share on other sites
Well, I'm going for maximum control over the texturing phase. I'd like to be abl eto model my terrains in Max then export them and have my engine display them very similarly. I realize I have to keep my details in Max down to a minimum but I'm ok with that. THe texture coordinates and texture creation phase is a pain here though.

So, once I make my polygon soup I guess my only true option would be to map the UVW coordinates on the mesh in Max then export those. They can be loaded one time into the terrain engine so I don't think this would slow down my rendering any more than texture splatting.

Guess I need to figure out how to "easily" manipulate the UVW coordinates in max.

Webby

Share this post


Link to post
Share on other sites
Ok, here's a thought.
I have two base textures that are 512 x 512 (or whatever size necessary)
I also have 2 (or more) detail textures that are 512 x 512 (whatever size).

The base textures are spread over the entire terrain (blended where necessary by a black and white map.
Also, the detail textures are simply spread over the entire terrain (tiled more to keep the detail). The detail textures are then blended into the base textures using another blend map. Actual algorithm doesn't apply correctly, it's just an idea.

I am thinking that with this approach I could model the entire terrain in Max, UVW Wrap then UVW Unwrap then adjust the texture coordinates until the base textures fit where necessary (to ajust for those nasty steep cliff artifacts) where necessary. Then, shouldn't I be able to use these same single set of UVW coordinates for any texture getting applied to the terrain that doesn't have more specific needs?

I know that if I needed to splat a random texture somewhere on the map then I'd likely need another UVW set for that, but for basic terrain texturing, this should work.

It seems like the tiling of the texture is done in DirectX or by the shader itself so I don't see a need for multiple UV sets per vertex.

Thoughts?

Thanks,
Webby

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!