Sign in to follow this  
ndhb

OpenGL Large terrain with support for run-time modifications

Recommended Posts

ndhb    246

I just post to share some work with terrain rendering that I did for a university project. The project was about how to render very large terrains and still be able to make modifications to the terrain surface (erosion, explosions, etc.). The approach I came up with is based on the Clipmap Texture. The implementation was written OpenGL and Java and uses Shader Model 4 features (texture arrays, vertex texture fetch with a non-32f texture format). I used the 16385 x 16385 dataset from Puget Sound found here. The terrain is not textured because I wasn't able find a detailed aerial photograph of the area, but there is diffuse lighting. Here are two screenshots in which I added some bump-mapping noise. Flying above Mt. Rainier Looking towards Mt. Rainier Another screenshot uses a single dirt texture repeated across the surface modulated with noise. Computing procedural textures is something I would like to work on in the future. There are other screenshots in my paper. The paper also describes the approach in detail. Although the world probably doesn't need another terrain render algorithm, maybe someone can use this for something. I anyone has any comments or questions, I will try to explain or answer. I have uploaded a video of the runtime modifications to the terrain (it's compressed with www.xvid.org codec). There's also a video of the incremental updates as the detail center is moved around [Edited by - ndhb on November 17, 2008 8:39:32 PM]

Edited by ndhb

Share this post


Link to post
Share on other sites
Barking_Mad    148
Looks nice :)

Im looking into terrain rendering myself but deformation/modification isnt really on my list. However i do want to use authentic GIS/Bathymetric data for the terrain map.

Share this post


Link to post
Share on other sites
swiftcoder    18426
Congrats on the nice paper you have written there, especially a lot of good background information.

Re your method for avoiding T-junctions, the end result seems similar to that used in the Infinite Universe Engine (PDF). They restrict neighbouring tiles to differ by at most 1 level of detail, and pre-calculate the 16 unique index buffers, and use them based on the level of adjacent tiles. This results in a similar mesh configuration, but avoids the degenerate triangles and some complexity in the vertex shader.

Share this post


Link to post
Share on other sites
ndhb    246
Thanks Barking_Mad and Swiftcoder.

Quote:
They restrict neighbouring tiles to differ by at most 1 level of detail, and pre-calculate the 16 unique index buffers...


I just read the paper you linked to. I liked that the author points out the problems with cascading split/merge operations on the bintree. These are a serious concern when handling very large datasets with these CLOD algorithms (e.g. ROAM). Clearly this issue only becomes even more serious when the terrain can be modified (!) and it deterred me from pursuing a CPU based algorithm.

Yes, pre-computing different index buffers and binding them to the VBO as dictated by neighbouring levels, would also avoid these tile-transitions. Whether rebinding the index buffers (API function call overhead) or evaluating the instructions in the vertex shader (shader overhead) is faster, I can't really say without experimentation - I guess it largely depends on the number of patches/draw calls to cover the terrain is satisfactory detail.

Share this post


Link to post
Share on other sites
swiftcoder    18426
Quote:
Original post by ndhb
Quote:
They restrict neighbouring tiles to differ by at most 1 level of detail, and pre-calculate the 16 unique index buffers...
Yes, pre-computing different index buffers and binding them to the VBO as dictated by neighbouring levels, would also avoid these tile-transitions. Whether rebinding the index buffers (API function call overhead) or evaluating the instructions in the vertex shader (shader overhead) is faster, I can't really say without experimentation - I guess it largely depends on the number of patches/draw calls to cover the terrain is satisfactory detail.
I avoided the binding cost by placing all 16 index sets in a single buffer, and using different index ranges depending on the neighbour configuration.

Share this post


Link to post
Share on other sites
ndhb    246
Quote:
I avoided the binding cost by placing all 16 index sets in a single buffer, and using different index ranges depending on the neighbour configuration.


Clever. I will try and play around with that idea when I find time for it :)

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  

  • Similar Content

    • By markshaw001
      Hi i am new to this forum  i wanted to ask for help from all of you i want to generate real time terrain using a 32 bit heightmap i am good at c++ and have started learning Opengl as i am very interested in making landscapes in opengl i have looked around the internet for help about this topic but i am not getting the hang of the concepts and what they are doing can some here suggests me some good resources for making terrain engine please for example like tutorials,books etc so that i can understand the whole concept of terrain generation.
       
    • By KarimIO
      Hey guys. I'm trying to get my application to work on my Nvidia GTX 970 desktop. It currently works on my Intel HD 3000 laptop, but on the desktop, every bind textures specifically from framebuffers, I get half a second of lag. This is done 4 times as I have three RGBA textures and one depth 32F buffer. I tried to use debugging software for the first time - RenderDoc only shows SwapBuffers() and no OGL calls, while Nvidia Nsight crashes upon execution, so neither are helpful. Without binding it runs regularly. This does not happen with non-framebuffer binds.
      GLFramebuffer::GLFramebuffer(FramebufferCreateInfo createInfo) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); textures = new GLuint[createInfo.numColorTargets]; glGenTextures(createInfo.numColorTargets, textures); GLenum *DrawBuffers = new GLenum[createInfo.numColorTargets]; for (uint32_t i = 0; i < createInfo.numColorTargets; i++) { glBindTexture(GL_TEXTURE_2D, textures[i]); GLint internalFormat; GLenum format; TranslateFormats(createInfo.colorFormats[i], format, internalFormat); // returns GL_RGBA and GL_RGBA glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, createInfo.width, createInfo.height, 0, format, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); DrawBuffers[i] = GL_COLOR_ATTACHMENT0 + i; glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0); } if (createInfo.depthFormat != FORMAT_DEPTH_NONE) { GLenum depthFormat; switch (createInfo.depthFormat) { case FORMAT_DEPTH_16: depthFormat = GL_DEPTH_COMPONENT16; break; case FORMAT_DEPTH_24: depthFormat = GL_DEPTH_COMPONENT24; break; case FORMAT_DEPTH_32: depthFormat = GL_DEPTH_COMPONENT32; break; case FORMAT_DEPTH_24_STENCIL_8: depthFormat = GL_DEPTH24_STENCIL8; break; case FORMAT_DEPTH_32_STENCIL_8: depthFormat = GL_DEPTH32F_STENCIL8; break; } glGenTextures(1, &depthrenderbuffer); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, createInfo.width, createInfo.height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthrenderbuffer, 0); } if (createInfo.numColorTargets > 0) glDrawBuffers(createInfo.numColorTargets, DrawBuffers); else glDrawBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer Incomplete\n"; glBindFramebuffer(GL_FRAMEBUFFER, 0); width = createInfo.width; height = createInfo.height; } // ... // FBO Creation FramebufferCreateInfo gbufferCI; gbufferCI.colorFormats = gbufferCFs.data(); gbufferCI.depthFormat = FORMAT_DEPTH_32; gbufferCI.numColorTargets = gbufferCFs.size(); gbufferCI.width = engine.settings.resolutionX; gbufferCI.height = engine.settings.resolutionY; gbufferCI.renderPass = nullptr; gbuffer = graphicsWrapper->CreateFramebuffer(gbufferCI); // Bind glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); // Draw here... // Bind to textures glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textures[1]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textures[2]); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); Here is an extract of my code. I can't think of anything else to include. I've really been butting my head into a wall trying to think of a reason but I can think of none and all my research yields nothing. Thanks in advance!
    • By Adrianensis
      Hi everyone, I've shared my 2D Game Engine source code. It's the result of 4 years working on it (and I still continue improving features ) and I want to share with the community. You can see some videos on youtube and some demo gifs on my twitter account.
      This Engine has been developed as End-of-Degree Project and it is coded in Javascript, WebGL and GLSL. The engine is written from scratch.
      This is not a professional engine but it's for learning purposes, so anyone can review the code an learn basis about graphics, physics or game engine architecture. Source code on this GitHub repository.
      I'm available for a good conversation about Game Engine / Graphics Programming
    • By C0dR
      I would like to introduce the first version of my physically based camera rendering library, written in C++, called PhysiCam.
      Physicam is an open source OpenGL C++ library, which provides physically based camera rendering and parameters. It is based on OpenGL and designed to be used as either static library or dynamic library and can be integrated in existing applications.
       
      The following features are implemented:
      Physically based sensor and focal length calculation Autoexposure Manual exposure Lense distortion Bloom (influenced by ISO, Shutter Speed, Sensor type etc.) Bokeh (influenced by Aperture, Sensor type and focal length) Tonemapping  
      You can find the repository at https://github.com/0x2A/physicam
       
      I would be happy about feedback, suggestions or contributions.

    • By altay
      Hi folks,
      Imagine we have 8 different light sources in our scene and want dynamic shadow map for each of them. The question is how do we generate shadow maps? Do we render the scene for each to get the depth data? If so, how about performance? Do we deal with the performance issues just by applying general methods (e.g. frustum culling)?
      Thanks,
       
  • Popular Now