0

I have a terrain system set up which utilizes a quad tree and a gray scale height map to draw the terrain. I create one 64x64 flat triangulated grid, which is then drawn at various scales based on the quad tree node selection. In the vertex shader, I sample a 2048 x 2048 height map texture to obtain the y coordinate for the grid mesh. Here is the code used to sample the grayscale texture:

float3 CDLODSample(Texture2D hmText, Texture2D gDetTexture, float3 inPos){
    inPos.y = hmText.SampleLevel(gTriLinearSampler,    
(inPos.xz*gsamplerWorldToTextureScale.xy)+gquadOffset._m00_m01,0.5f).x; 
    return inPos;
}

I then scale the result of this sample by a constant to determine the height variation of the terrain. The issue is that as the size of the terrain increases (up-scaling the terrain to 16,384 x 16,384), the terrain appears jagged and low quality. Although there are still plenty of vertices, the vertices simply form larger, visible polygons. I have read about bezier surfaces and re-sampling algorithms, but these seem very costly in terms of performance. Is there a good way to dynamically re-sample terrain for a smoother output without hurting performance too much? If so, does Direct X have a sampler which will do something like this? How do games such as Battlefield 4 and Just Cause support large, smooth terrains with huge height variation? Do they simply stream very large height maps, or do they dynamically re-sample lower resolution height maps as needed? Any and all information and tips are much appreciated.

Ben Trapani
  • 271
  • 1
  • 4
  • 11
  • Is it an issue with the geometry resolution or heightmap filtering? If it's the former, look into tessellation or just increase resolution of your triangulated grid. If it's latter you could try to use something else than straight bilinear filtering (e.g. implement bicubic by taking several samples for each vertex). – JarkkoL Aug 13 '14 at 20:09
  • It is an issue with the heightmap filtering, since the geometry scale to world scale is 1 to 1. The geometry to heightmap size ratio is a lot larger than 1 though. How would someone go about implementing bicubic sampling? – Ben Trapani Aug 13 '14 at 20:13
  • 1
    You could try cheap approximation by taking 5 bilinear samples: center and half pixel offset up/down/left/right and averaging the results – JarkkoL Aug 16 '14 at 00:57

0 Answers0