Hello everyone,
I’ve been working since a few month on a glsl custom shader to make terrain LOD.
The purpose is to displace a plane in real-time, according to a heightmap, in order to make huge terrains. Instead of creating a millions-polygons mesh, this system displays more polygons near the camera, and less polygons far away.
This allow you to have at the same time a huge terrain, a high level of details, and a big distance of view.
My goal is to provide a ready-to-use script, that everyone could set up easily, without any coding knowledge.
It’s still far from being finished, but now I get my first promising result, so I share this to you.
current features:
real-time displace for LOD
multilayer shading with 4 materials
colormap, normalmap and specularmap for each of these 4 materials
That’s quite impressive, though I also can’t watch the videoclip.
I’d love to test this with large scale terrain data from satellite imagery (ASTER GDEM) where a single tile results in a mesh of 12.960.000 polygons. It would be lovely to have multiple tiles in an interactive enviroment.
@scrible : I actually use a 4096*4096px texture for a heightmap. And in the center area, I subdivided enough to have one vertex per pixel… Wich would give a 16 millions polygons mesh if there were no LOD… And I think all of this could be more optimised.
I will definetely ask for testers when the code will be less messy and more easily tweakable :]
@Solarlune: I’ve started writing glsl when I discovered the “xmb” file by mike pan and martinsh (where i realized that real-time displacement and much more was possible), but I don’t remember of a terrain script he did, and I don’t find it here in b.A… I would be curious to see it, if you remember where to find it?
Sorry for the video I actually put music on it… I didn’t expect youtube to be so fast
Anyway i will upload another one soon.
Yes, i’ve already seen this file (which is awesome btw), but the problem here is that the volume doesn’t exist, it’s faked. The shader displays on the surface of the plane what it had looked like if it was a volume, but the mesh is still a plane!
Basically, it means that you can’t fly (or walk) between two mountain, but only over a mountain.
It’s still a very good technique, but it’s useful only for far-away landscapes seen from above (or smaller details like rocks, bricks, etc…)
@Solarlune: yes I’ve already prepared my low-res mesh for collisions^^ …
@scribble: actually it only depends of your hardware. (My GPU can handle 8192px wide textures maximum…)
But we could imagine a multilayer technique where many maps combined generate the volumes. By tiling and sizing them in a smart way, we could imagine HUGE result,(or even an infinite landscape :eek:)
Fantastic! This is similar to the method I’m building for the planet’s surfaces on my game!
I use vertex color based on altitude to create the stencils.
I noticed the plane’s limits, you might have a plane’s size problem. If your planes are too small, it might be noticeable!
BTW, what kind of shader are you using? I know vertex shaders can’t do collisions, geometry shader?
@torakunsama : I guess you talk about those white lines ? They’re not plane limits because all the terrain is made of one mesh, but the tiling border of the repeating textures… I’m loooking for a way to get rid of this.
I’m using a vertex and a fragment shader. And for the collisions, like Solarlune suggested, I plan to add an invisible collision mesh (wich would have a lower resolution).
(the video seems to be blocked everywhere in the world expect at my house; so I’ll upload a new one as soon as possible)
Today I’ve had support for baked lightmaps, allowing you to have nice shadows or ambient-occlusion :
I also made the lighting process more optimized. Before, diffuse light and speculars were calculated for each of the 4 materials, then the materials were mixed. Now, normal maps of the 4 materials are mixed before, and the lighting process is made after this, in one time. This make the sript much shorter and the shader much faster to draw.
Another new thing: the size of the textures now change according to the distance. When you are near the ground, the texture is tiled a lot of time; while the far-away terrain have bigger textures.
This allow you to have details far away and near the player, without having these ugly patterns of repeating textures.
Wow, sweet results. Looks pretty great so far, and I really like that you can have different sets of repeating textures (one for close-up, one for far away). It’s looking pretty great so far!