Sign in to follow this  
dpoon

Procedural Terrain Texturing on the GPU

Recommended Posts

A recent project that I was working on required me to revisit the topic of terrain texturing. I started off by looking into an offline approach whereby a single large texture is generated from a height map and several tileable terrain textures. This seemed to work ok but most cards limit the max texture size to about 4K, and I didn't have the time to go into any kind of terrain paging scheme. I was looking for a quick and cheap alternative. Many sources on the web suggests that procedural terrain texturing on the GPU would give better result. My initial experiments with a fragment shader gives some pretty good results. At the moment I'm just blending 4 texture tiles and only using the height to color the terrain. I plan to add slope to the mix later on. I haven't found much in the way of how other people have been implementing this on the GPU. The way I've done it is to include 2 sets of texture coordinates with the terrain mesh vertices. The 1st set is for the height map. The coordinates are for a single height map stretched across the entire terrain. I then use the interpolated texture coordinates to determine the exact height of that pixel on the terrain in the fragment shader. The 2nd set of texture coordinates is what I use to give the terrain texture its overall resolution. Its how much the terrain texture tiles are tiled across the terrain. A low amount of tiling will produce results equivalent to a low res texture stretched across the terrain. The greater the amount of tiling the more detailed the resulting terrain texture will be. However too much tiling and the end result will look "funny" since the tiling will be very obvious. I've posted a demo together with source on my site www.dhpoware.com.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this