# How to render a curved horizon when rendering terrain far away

For games with long view distance, it might look at bit weird when you fly high above the ground and the horizon is all flat.

So, how can I make a crumb/bend effect, when I fly high above the surface? Can this be done in the shaders?

If you're not sure what I mean, heres a picture:

A more clear example, though it might be captured with fish eye.

What would this best way to do this? I believe you could rotate and move (using transformationMatrix) all vertices a tiny little bit according to how far they are from the camera. But would this even create the desired effect, and would it be too resource extensive? Or maybe you know a whole another way to do it.

• Are you talking about the blurring at the edge of the horizon? I can't seem to find any form of "crumbing" in the posted image... Commented Jul 6, 2015 at 20:15
• +Alexandre Desbiens I could possibly find a better image. Commented Jul 6, 2015 at 20:16
• If you do find other images, feel free to edit them in, but please keep the original one. And if you want to adress a comment to someone, use the @ sign. Commented Jul 6, 2015 at 20:18
• @AlexandreDesbiens Oh yeah. Forgot it. Guees Google plus gave me a bad habit. Question is now updated with a better image. Commented Jul 6, 2015 at 20:20
• I do beleive what you are searching for is some kind of distance blurring. I still cannot find the meaning of the word "crumb" in the context of the images you provided. Commented Jul 6, 2015 at 20:22

## 2 Answers

One possible solution would be to actually curve the terrain model. If your game/physics engine wouldn't support this while the character (I assume there is a character) is on the ground, then you could have two models, one with curvature and one without, which you could switch between based on some sort of altitude threshold (supposedly the curvature of the earth becomes visible at 50,000 ft.).

• This is the approach that immediately came to mind for me as well. Could even switch out the detailed ground model for a sphere primitive with an appropriate texture. Commented Jul 7, 2015 at 17:42
• Rather than a model swap, you could apply some curvature in a vertex shader. That way you can ease the effect in & out without popping, and your gameplay / terrain systems can keep using the same assets and interacting in the same unbent physics space, unaware that anything has changed in the rendering. Commented Feb 4, 2017 at 15:28

You can achieve the second picture's curve quite easily by making your field of view wider in the projection matrix. Try a field of view around 180 degrees.

• This will distort the view, but not quite the way the question describes. Even with a wide field of view, a game camera still uses linear perspective, so straight lines in the world map to straight lines in the image (unlike wide field of view lenses in real cameras, which tend to introduce additional distortions in the process). In particular, the effect is view angle dependent, so looking along the horizontal plane will show content at the horizon less distorted than when pitching the camera down. Commented Feb 4, 2017 at 15:58