Terrrain LOD [UPDATE: dynamic shadows !!] huge open world for all (glsl shader)

Thanks guys :slight_smile:

Last news: I made a grass shader from the Terrain shader, that displays grass around the Player. The current features are:

  • Grass is lit exactly the same way the terrain is, so its shading match the ground (grass is shadowed like the groud, etc.)
  • Grass smoothly fade out when the player go away
  • Grass only appear on grassy area (no grass on sand, rock or snow)

Suddenly the landscape became more alive !

As you may see in the pictures below, there are some problems with alpha sorting (polygons are not rendered in the back-to-front order, wich result in alpha artifacts :confused:




This is seriously amazing, benj. Really, really awesome.

JoyGasm! Amazing!

Do you have a game in progress?

It reminds me of new vegas!

Can I play around with pushing my game into your system? (Wrectified)
How many copies of a in game item do I need (resolutions etc)? is there a sprite as the final/least detailed level supported yet? (like a silhouette on the horizon?)

I need to use this to do something along the lines of Mordor, but a future world, without the lava, and the plant life is very mutated looking…

Whoa! Nice grass. I’m eager to dissect the file and see how you did it. And great job on the physics system.
This would look awesome when combined with Martinsh’s water shader and 2D filters. Then just sprinkle in some tree models, and you have an amazing graphical showcase for the BGE!

Maximum awesomeness. :slight_smile:

I would like to see the blend when your finished.Maybe you can put it on dropbox.If dropbox can handle textures.

Awesome work.
I’m very curious about it’s algorithm.

Hi ! Thank you for your nice replies :slight_smile:

The grass shader works exactly the same way the terrain does : the grass object is deformed to match the terrain height, it is moved to follow the Player, and it’s UV are shifted back so the deformation keep matching the terrain while the object is moved.
The grass mesh is made to be a repeating pattern of polygons, so the movements are unnoticeable.
And the grass mesh has another UV layout used for grass color and grass alpha mapping.

I am currently implementing laser blaster lighting work into the system (terrain and grass), once this is done, I will clean the code and share the .blend :slight_smile:

@ laserblaster : The Texture2DGrad is a very convenient function to avoid tiling artifacts, but it has a huge framerate impact on my config. Your last demo runs at 20fps, but and it runs a 120 fps if I replace Texture2DGrad by Texture2D !! So I think we should keep the tricky margin solution to avoid seams … :confused: Or maybe there is a more efficient way to use Texture2DGrad ?

@ BluePrintRandom: You can definitely use it for your game :slight_smile: Im not sure to understand well your question: actually this system does not replace any mesh by another one, it just move the terrain to keep the higher polygon density area near the Player. Spawning objects and replacing their meshes is something different, but it could be done in addition to my system (Z4urce posted a nice threaded system for this) !

Thanks Benj I will try and “mix” the two base environments,(your terrain LOD and his Mesh Lod)
and make a tech demo!
:slight_smile:

blender game engine is shaping up!

The margin solution is a good idea to have no matter what. Even with texture2DGrad, there would still be some bleeding issues on the edges of tiles if not for the margins. What texture2DGrad does is fix the weird looking seams caused by the texture derivatives being calculated incorrectly. The error manifests itself as 2x2 pixel artifacts along tiling edges. But if it has such a performance impact, then please do get rid of it!

My GPU, despite being incredibly cheap, has a fairly modern architecture, so I didn’t see much of a performance impact. But to have the best performance for everybody, I agree it’s a good idea to go back to the original method. You should definitely keep my new method of calculating specular highlights, though. It looks quite a bit better than the original.

I second a new blend file with physics and grass! Keep up the great work benj!!!

It looks very impressive, “bravo”!

Unfortunately, it doesn’t work on my computer (Win7, NVidia GT650M):





Any idea why? Is my graphics card not compatible?

Anyway, thank you benj for those great pictures!

EDIT: In fact, the LOD shader does work, but the “texturing”, particularly the fog, does’nt. After some researches, the problem seems to be in the variable “zNear”. When I replace it with “zFar” in the “beauty” definition, there is no more problem (appart from some little side effect, see below).


Here a higher resolution picture of the side effect; sorry for the new post, but I’ve already 3 images in the previous one.


@laserblaster : I will definitely keep your specular calculation method! And implementing the multilight version is a priority…!

@Matpi : This is very weird, I can’t figure how the zNear variable could affect the way the textures are tiled :confused: And your graphic card should be compatible (seems to be one year old maximum). Is your GPU driver up to date ? Does any error or warning appear in the system console ? Does the problem remain if you replace “beauty” by “material” at line 206 (to get rid of the fog) ?

The code is still messy, I need to remove useless stuff, clean it and comment it. I also have to make some little changes everywhere to make to whole thing more adaptative. I’m really lacking time, but hopefully I could share a clean .blend within a few days.

Nice work no matter how long it takes, do you have a game on a back burner for after this benj ?

I would help with this but I am not sure if I am advanced enough in python yet,
Do you need a game modeled? Roughs? rag dolls? story boarding?

My game progresses slowly as I need alot of help most of the time,
but I can fire out art no problem :slight_smile:

Another problem I just noticed is the following:
It exists an angle of view (approximately 50-55° from the horizontal orientation) from which I don’t see the terrain anymore:






Before I go deeply in the code, I think of a “division by 0” problem, or maybe a vector problem (collinearity, etc.)… Is that possible? :confused:

BTW I tried the multilight version, applying the corrections + what I’ve already talked about (adding “1.0-”). It works! Thank you laser blaster!
Only little problem: some aberrations (white square + black line):


But that’s already better!

@Matpi: I think you’re using the old version of my file. Check my later posts in the thread (and I’ll update the old post as well). The newer version shouldn’t have the problem with the white square and black lines. As for your problem with the terrain disappearing, that’s a side-effect of BGE’s view frustum culling. Although the vertex shader displaces the terrain to create height, the actual mesh object is just a flat plane. So when the plain gets out of the view frustum, Blender culls it and the terrain disappears. To solve this, go into edit mode on the terrain mesh, duplicate one of the triangles, scale by factor 0, and place it above the tallest mountain. (my newest version should have that fix, BTW)

@laser blaster: Totally right. I forgot about the new posts… Sorry! :frowning:
Now it works, the side effect is minimized (almost not noticeable anymore)! Awesome! Thank you so much! :D:D

EDIT: btw I get about 20-30 fps.

YOu’re welcome. :slight_smile: 20-30 fps seems kinda low for a GT650. Is it a lot slower than benj’s version? The culprit may be the calls to texture2DGrad. In any case, turning down the AF helps the framerate a lot for me.
Also… updating your GPU driver may fix your problems. It sounds like lame advice, but it works surprisingly often.