terrain detail

Started by draga, December 15, 2009, 04:18:27 PM

Previous topic - Next topic

EgonOlsen

Almost. I'll upload a zipped version today, if i find the time.

AW999

BTW, how did you make the sky in that program?  Are there any articles on creating a good sky?

EgonOlsen

#32
The sky is a shameless rip from raft's work on Aptal Karga...didn't i gave credit before? I guess, i've forgotten...shame on me... :-[

However, here's the file: http://www.jpct.net/download/misc/terrain.zip

As said, it's pretty hacky. Especially processing of the trees and generating the terrain texturing could be improved. Sources are included, i've put everything into one, uncommented (almost) file. It needs the jpct.jar that's included to run, it won't run with 1.19, because it uses some stuff that i've added for 1.20.

There are some keys:

1+2 : Move the sun. The lens flare doesn't take the mountains into account for performance reasons.
t: toggle trees (on by default)
d: toggle detail mapping (off by default)
CRSR+PGUP+PGDOWN: move
ESC: Exit

FPS will be printed to the console each second.

Edit: Performance on my main machine (Core2 Quad@3.2Ghz, Windows Vista Ultimate 32bit, 4GB, Ati Radeon HD 5870 - 1GB, Java6.something) at the starting position without moving the mouse.

With trees: 83fps (was 55 before optimizing...)
W/o trees: 1200fps

Edit2: Performance on my test machine with Intel onboard graphics (Core2 Duo@2.2Ghz, Windows XP, 2GB, Intel 945G, Java6.something):

With trees: 10fps
W/o trees: 31fps





AW999

Quote from: EgonOlsen on January 04, 2010, 09:59:01 PM
However, here's the file: http://www.jpct.net/download/misc/terrain.zip

Wow. Even on my machine, it runs with a framerate in the 20s or 30s, sometimes 40s or higher.
Since you provided the sourcecode, I assume we can freely adapt it for our own projects?

EgonOlsen

Quote from: AW999 on January 05, 2010, 12:35:26 PM
Wow. Even on my machine, it runs with a framerate in the 20s or 30s, sometimes 40s or higher.
Since you provided the sourcecode, I assume we can freely adapt it for our own projects?
Sure. The usual "do whatever you like with it"-license that i'm using for all of my sources applies here too. Just keep in mind, that the whole thing is just written to make it work. There have to be many many ways to do things better than i did in this demo.

EgonOlsen

BTW: If you have at least a dual core, it can be worth it to set Config.useMultipleThreads in the constructor of Terrain to true. If the graphics card can handle it, the demo scales pretty well (115 fps compared to the 83 of the single threaded renderer).

EgonOlsen

#36
Resurrected the old terrain stuff to play around with the shader based splatting method mentioned earlier.

See how the path winds through the mellow hills and the lovely meadows? Looks like Skyrim, doesn't it? Well, maybe not... ;)



BTW: The benefit of doing it this way is, that you can actually "paint" the splatting into a texture instead of relying on the height and some dubious alpha values.

Edit: Changed picture to one with better lighting.

Hrolf

Oo! Pretty! I wonder if shaders could also be used to fake up some sort of shadows?

EgonOlsen

I tried this by modifying the blend texture (i.e. the one that tells the shader which texture to use where) when planting the trees by placing a dark spot below each tree. It worked so far, but i forgot that i'm not rendering trees in the distance, so there were no trees but the dark spots remained, which made the terrain look like some kind of acne in the distance.