Jump to content
  • Advertisement
Sword7

OpenGL Terrain mapping - more earthquake when closer to ground

Recommended Posts

The book you have spends a chapter on coordinate precision and render relative to eye (pp. 155ff.) and has exsample code in C#/GLSL but that is easily transferable. I could not explain it better (or shorter :-)) I have tried it out (it works), but with a different LOD algorithm than the examples in book (no chunked LOD or clipmapping because too CPU intensive). In my take on LOD of a height map only the bounding boxes of the nodes to render this frame have actual world coordinates, the terrain itself has no mesh except for a single one the size of a single node, which is passed around and sized accordingly in the vertex shader.

You find my blog entry here. Code fragments included. And the example code of the book's authors on github.

The matrices need not have double precision ! Only the view matrix has large numbers in the translation column which are stripped off before being passed into the shader. The matrices are applied in the vertex shader after the camera position (which is double) has been deducted from the world positions (which are doubles), leaving handsome float numbers behind. So, only world positions (depending on your LOD algorithm) and the camera position need double precision.

Btw., it took me several weeks to figure it out, so don't be too frustrated if it takes some time 🙂 Experiment with a huge subdivided icosphere/planet /whatever before applying it to your lod'ed terrain !

Edit:  @TeaTreeTim has solved much of this long ago with other approaches ...

Edited by Green_Baron

Share this post


Link to post
Share on other sites
Advertisement

Ok, I now found your blog after I searched for that. Thanks.  I will work on new LOD method to replace my old code that use trigonometry for LOD determination, etc.

Share this post


Link to post
Share on other sites
1 minute ago, Sword7 said:

Ok, I now found your blog after I searched for that. Thanks.  I will work on new LOD method to replace my old code that use trigonometry for LOD determination, etc.

One problem at a time .... 🙂

Share this post


Link to post
Share on other sites

If you're still at it, i have a correction to what i wrote above.

I am playing around with this a bit and have observed some jerking. This was due to my model-view matrix being just float. Better have it as double on the CPU, and after stripping it from the translation column, cast it to float before transmitting it to the shader. The rest of the matrix (rotation) are just small numbers that fit perfectly in float.

OpenGlobe has even the perspective matrices as doubles, but as long as the depth of field fits into a float that would not necessarily be necessary.

Still interested in other solutions !

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

  • 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!