Fake horizon with Vertex Shaders

Hello again,



I hear here and there about spherical worlds, but it sound very very complex, so I propose a cheat instead. I don’t know how Shader works, but it is apparently possible to create a vertex shader which will “bend” the terrain to simulate the curve of the planet… make a real horizon line.



Right now, the Terrain in my project looks like Discworld :smiley:

Is it possible ? How ? Do you know good documentation about Shaders ?

Yes, it’s not that difficult but you need to think a bit about it, I got something similar going but as it does not look right (got set back a few times as I found out the matrixes did not contain the values I expected them to have) I kept it for myself.

It’s just a matter of creating a material (or editing the general .vert file) to displace the vertice depending on the distance toward the viewer, ie, moving it downward. To get this effect to look realistic you need to do a few sine computations, which, imho are not that difficult, but I need to look into that a bit more, as I wanted to do it in the viewspace which appears to be not the right place, or perhaps I need to make a few more changes.



I wanted to add a screenshot of my modified mythruna shaders but it appears I forgot to take a shot when I had it running. If you want I’ll post back when I worked it out a bit better, I’m pretty much nearly done on it but need to find the right exact way to do so.

In my interpretation spherical worlds are much more than just a question of curved horizon. They are more about connecting opposing edges of the world together, so they form an “infinite” surface - spherical in real. If you want to have just a more “realistic” horizon, then sperical terrain would be too much pain, as you said a simple shader or post processor can do it. If you want to create a planet, then you must create an algorithm to connect the edges somehow (toroidal worlds are quite simple to create though, and they can be done with simple planes using terraingrid and something like (cell % torusSize)).



By the way, I think spherical world is not really about the curved horizon, the curve itself would not even be visible, only when viewed from far away.

Thank you for your answers,



I do already have an infinite detailled toroidal world in my project, with a detailled grid, and a very low resolution horizon grid for far vision. It works really nicely (see the screenshot). But when you watch a far away mountain, it really looks weird without the planeterial curve.



@baalgarnaal : It’s nice to know you are already working on this. I am very interested in your Shader :slight_smile: