Terrain renderer

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Terrain renderer

Post by scrawl »

Wanted to show this for a while - terrain renderer I wrote for OpenMW :)

[youtube]2wnd9EuPJIY[/youtube]

Differences to Ogre::Terrain:
- Pages are merged and split on demand, very important to render a large world without having too many batches.
- Normals stored in vertices, not in texture, to allow per-vertex lighting and support older cards.
- Different LODs are seamlessly connected instead of using skirts.
- Supports realtime self shadows
- Supports infinite number of texture layers by adding more passes if required.
- FFP fallback
- Shader isn't hardcoded and uses shiny for preprocessing.

TODO:
- Background streaming
- Geomorphing to make LOD transitions smoother
- Error metrics

Code (~2k lines): https://github.com/OpenMW/openmw/tree/m ... ts/terrain
Last edited by scrawl on Tue Jan 06, 2015 3:08 am, edited 2 times in total.
User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
x 218
Contact:

Re: Terrain renderer

Post by Jabberwocky »

Nicely done!
Writing terrain code isn't for the faint of heart. :)
How do you find it performs compared to an ogre terrain of equivalent size?
Image
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Terrain renderer

Post by scrawl »

How do you find it performs compared to an ogre terrain of equivalent size?
That wouldn't really be a fair comparison :)

You can't make this world as a single Ogre::Terrain object because there'd be far too many layers.
So you'd have to start splitting it up into chunks that are small enough to have a reasonable amount of layers. After doing that, you'd have an insane batch count.
In my terrain system, this is solved by merging these small chunks if they are far away and rendering them with a composite map only, which pre-renders the layers so the amount of layers doesn't matter anymore. Batch count is < 50, so the performance is pretty great!
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Terrain renderer

Post by syedhs »

Any precompiled binaries to download..? :)
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Terrain renderer

Post by scrawl »

There is no standalone demo. License - GPL3.
User avatar
nevarim
Gnoll
Posts: 675
Joined: Mon Jul 05, 2010 6:16 pm
Location: Pavia Italy
x 4
Contact:

Re: Terrain renderer

Post by nevarim »

great work!! :D
i'm a noob until proven otherwise :D
used in my project ;) and thanks to everyone :D
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS
User avatar
nevarim
Gnoll
Posts: 675
Joined: Mon Jul 05, 2010 6:16 pm
Location: Pavia Italy
x 4
Contact:

Re: Terrain renderer

Post by nevarim »

can be used on other project with only ogre?
i'm a noob until proven otherwise :D
used in my project ;) and thanks to everyone :D
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Terrain renderer

Post by scrawl »

nevarim wrote:can be used on other project with only ogre?
Yeah that should be possible. What you'd need to do is implement the Storage class. You will need your own way of storing the terrain data (or generate it procedurally).
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Terrain renderer

Post by scrawl »

I have added normal, specular & parallax mapping.
[youtube]t-NgplmbqpU[/youtube]
There are 2 important differences to Ogre::Terrain regarding this:
- normal & parallax mapping can be turned on/off separately for each layer. Useful if you only have those maps for some of the layers, or you want a layer to be completely flat.
- Instead of calculating the light contributions for each layer, the normals from all layers are "merged" and the final normal is used for lighting. While this isn't 100% accurate, it's virtually unnoticable and should be much faster (especially with more than one light - in my situtation, its 8 lights with 8+ layers, that'd be 8 instead of 8*8=64 lighting calculations...)
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Terrain renderer

Post by bstone »

An interesting idea. Have you done any benchmarking to compare the simplified approach in its performance to the original one?
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Terrain renderer

Post by jacmoe »

GPL is just /(#&¤(/&# useless! :o

You ought to be shot on the spot for announcing middle-ware with such a hideously ebola-ridden license.

If, however, you could release that part of your OpenMW engine under the MIT license, then we can start using it, improve it together and perhaps even make it the default terrain engine for Ogitor..
Oh, well... ;)

I do understand that you want OpenMW to be GPL, that's ok.

Come to think of it, I actually managed to convince the Daimonin developers to release their tiled terrain scenemanager under LGPL:
http://www.ogre3d.org/forums/viewtopic. ... 62#p130862

If you are in a position to do that, of course.

Eternal glory!
Remember that. :)

Edit:
What piqued my interest was your comment in the Ogre Terrain Capabilities topic:
scrawl wrote:Ogre::Terrain does not scale well at all. It does not support varying heightmap resolutions depending on the distance, like you'd want for a very large world. This is one of the reasons I wrote a custom terrain system, which you can find here.
Damn you. :D
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
N0vember
Gremlin
Posts: 196
Joined: Tue Jan 27, 2009 12:27 am
x 24

Re: Terrain renderer

Post by N0vember »

I'm starting to get lost between all the Terrain solutions out there, their differences, their advantages.

So far we have :
- Terrain component, seems the less interesting to me (built-in)
- Volume component, with voxel-based terrain features : overhangs, caves etc... (built-in)
- Scape engine by decarpentier, very powerful GPU edition capabilities
- VoxelTerrain by markus, again, voxel-based
- This one, which strong point seems to be a "classic" terrain (not voxel) that can stream really big worlds with detailed texturing

An in-depth comparison would be cool one day, I really don't know what I'm gonna use :)
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: Terrain renderer

Post by al2950 »

N0vember wrote:I'm starting to get lost between all the Terrain solutions out there, their differences, their advantages.

So far we have :
- Terrain component, seems the less interesting to me (built-in)
- Volume component, with voxel-based terrain features : overhangs, caves etc... (built-in)
- Scape engine by decarpentier, very powerful GPU edition capabilities
- VoxelTerrain by markus, again, voxel-based
- This one, which strong point seems to be a "classic" terrain (not voxel) that can stream really big worlds with detailed texturing

An in-depth comparison would be cool one day, I really don't know what I'm gonna use :)
I second that, I am also a bit lost when comes to the finer differences and details of these terrain engines.
User avatar
stealth977
Gnoll
Posts: 638
Joined: Mon Dec 15, 2008 6:14 pm
Location: Istanbul, Turkey
x 42

Re: Terrain renderer

Post by stealth977 »

Well, we are looking for a better terrain renderer for Ogitor 15.10 a.k.a Malazgirt (Ogitor with Ogre v2 and OGF) since we are having too many problems with Ogre::Terrain.

As I wrote in one of my posts:
"Jack of all trades, master of none" is some famous saying you all know.

The problem with Ogre::Terrain is exactly like the saying, Ogre::Terrain is actually "Jack of all trades, master of none". It tries to do too many things, tries to meet all kinds of demands from the user:

- Different material shaders?, hell yeah!
- Awkward terrain orientation? hell yeah!
- Multiple vertex definitions? hell yeah!
....the list goes on....

but, the result is: bloated, slow, inefficient Terrain Rendering Implementation...So bloated that even if I wanted to create my own implementation, It would be much easier to start from scratch than to take it as a base and modify...
So, we need a Terrain Renderer which can handle large terrains (does not need to page everything, keeping all heightmap in memory is not expensive nowadays, but blendmaps sure need to be paged) with following properties:
- Fast Enough rendering with lod
- Multiple blendmaps/layers
- Self Shadowing and Shadowmaps
- Morphing vertices during lod changes
- Need to support run-time editing of blendmaps and heightmaps
- Opensource compatible non-intrusive license

If any of you know a renderer with above capabilities or have one they created, please lets us know and we can include/have full support for it...
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Terrain renderer

Post by jacmoe »

Just wanted to mention that IMO OpenMW is the coolest project using Ogre that I know of. :)

This is because Morrowind has to be the best game I've ever played experienced!
And because it is amazing what you guys have accomplished until now.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Terrain renderer

Post by scrawl »

I get your frustrations, but you could ask nicely before saying I "ought to be shot on the spot"?
I do understand that you want OpenMW to be GPL, that's ok.
I don't personally care for the GPL, however changing license at this point is next to impossible, all 100+ contributors would have to agree... assuming we can even still reach all of them. The license was chosen before I joined the project. Now we're stuck with it.

However, as for the Terrain code, it was written by me exclusively, so I hereby release it under the MIT license.

By the way, the video player used in openmw is also released under MIT.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Terrain renderer

Post by jacmoe »

scrawl wrote:I get your frustrations, but you could ask nicely before saying I "ought to be shot on the spot"?
I know I have clunky way of asking nicely. I do have a grudge to bear against the GPL for middle-ware. 'Diplomat' is not exactly my middle-name. ;)
Has probably to do with the fact that I am Danish. We have a weird sense of humor.
I apologize for having offended you.

That said:

What a wonderful gift, Scrawl :D

You really took me by surprise.
Am definitely going to integrate it into Ogitor, if it's okay with you. :)
<edit>
And now I feel really guilty. I guess I had it coming.
</edit>
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Terrain renderer

Post by frostbyte »

"ought to be shot on the spot"
he meant using this...http://www.dreamstime.com/royalty-free- ... age2323317 :D
By the way, the video player used in openmw is also released under MIT.
this is a must have in the new OgreADDON repo...http://www.ogre3d.org/forums/viewtopic. ... 25#p514142
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Terrain renderer

Post by scrawl »

this is a must have in the new OgreADDON repo...http://www.ogre3d.org/forums/viewtopic. ... 25#p514142
Why? There is an active repository on github... having another one would only cause confusion, and one of them would get outdated eventually.
If you want to contribute, just send a pull request :)
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Terrain renderer

Post by jacmoe »

Now that I effectively bullied it to be relicensed :oops: I will clone the repository at Github, make a copy of the terrain component and make sure to issue pull requests. Should we decide to use it for Ogitor then we will most probably going to add at least GPU editing like in Scape.
And we are definitely going to port it to Ogre 2.0 as soon as possible.

The code should be attributed to Jannik 'Scrawl' Heller from the OpenMW team, right? :)


<edit>
Ogreaddons is primarily for projects without an active maintainer.
OpenMW does not fall into that category :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Terrain renderer

Post by Kojack »

The original Morrowind terrain was one of the more interesting ones I've reverse engineered. If I remember correctly (it was a long time ago) it was something like 65x65 heights in a land block with each height being a signed 8 bit offset from the height to the left, except the first height of each row came from the first height of the row below it, and the whole land block having a float initial height.

(I could rant about OpenMW's GPL and how it's blocked adding Oculus support which would have been awesome, but I won't. This is about terrain)
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Terrain renderer

Post by frostbyte »

sorry, i'm a bit ignorant when it comes to git/hg...
just figured it will be better if the coolest plugins would be gathered under one umbrella...
and this one is definitely one of them...
offcourse, you are right about the confusion that can be created
apperantly their isn't an easy automatic solution to bitbucket<-->git sync
found this http://www.metallapan.se/bitsynchub/ but it works the other way around...

anyway thanks for MIT-ing the terrain component, i also wanted to try it but the GPL scared me away...
Ogreaddons is primarily for projects without an active maintainer.
ok..thanks for clearing...
Last edited by frostbyte on Tue Feb 03, 2015 10:45 pm, edited 1 time in total.
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Terrain renderer

Post by jacmoe »

Something like this? ->

Code: Select all

/*/////////////////////////////////////////////////////////////////////////////////
/// An
///        ___                        __    __ 
///       /___\_ __   ___ _ __   /\/\/ / /\ \ \
///      //  // '_ \ / _ \ '_ \ /    \ \/  \/ /
///     / \_//| |_) |  __/ | | / /\/\ \  /\  / 
///     \___/ | .__/ \___|_| |_\/    \/\/  \/  
///           |_|                              
///                 file
///
/// Copyright (c) Jannik Heller (scrawl) of the OpenMW project (openmw.org)
///
/// The MIT License
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
////////////////////////////////////////////////////////////////////////////////*/
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Terrain renderer

Post by scrawl »

Code: Select all

/*
 * Copyright (c) 2015 scrawl <scrawl@baseoftrash.de>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
Post Reply