Holes in the terrain

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Holes in the terrain

Post by Marc » Mon Mar 07, 2005 1:32 am

Hi !

Is there a default approach to making "holes" into the the heightfield based terrain to connect it to some underground dungeon, created as a normal mesh or static geometry?

I guess using portals would be a good way, but portals don't seam to be ready for use, according to this thread http://www.ogre3d.org/phpBB2/viewtopic. ... 58&start=0 .

So are there other ways to do it?

-
Marc
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Post by sinbad » Mon Mar 07, 2005 2:28 pm

I think you'd be best just to poke some solid geometry through it and slap a portal on the front (or a little way down the hollow section). You'd need a SceneManager that can handle portals of course...
0 x

User avatar
Falagard
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2060
Joined: Thu Feb 26, 2004 12:11 am
Location: Toronto, Canada
Contact:

Post by Falagard » Mon Mar 07, 2005 3:07 pm

Portals would be the best approach for this, but another possible trick is to write geometry to the depth buffer but not to the colour buffer where you want to "cut" the whole, prior to rendering the terrain. Then render the terrain and it won't render where the hole geometry was rendered.

Falagard
0 x

User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc » Mon Mar 07, 2005 8:34 pm

Falagard wrote:Portals would be the best approach for this, but another possible trick is to write geometry to the depth buffer but not to the colour buffer where you want to "cut" the whole, prior to rendering the terrain. Then render the terrain and it won't render where the hole geometry was rendered.

Falagard
to zbuffer-writing:
I thought of this zbuffer-writing way. But is it possible to doe that by defining just special materials? Or do I have to call some lower-rendering-methods myself?

E.g. if I just put an additional object in the scene with a material that writes zbuffer values somehow and ignores testing against the current zbuffer values. Then how can I be sure that this object, the underground dungeon and the terrain get drawn in the right order so that it looks right?

to portals: s. Chasters thread
0 x

User avatar
pjcast
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2543
Joined: Fri Oct 24, 2003 2:53 am
Location: San Diego, Ca
Contact:

Post by pjcast » Mon Mar 07, 2005 8:48 pm

I am working on a portal scene manager of my own, and have thought about this... I also thought of rendering an invisible quad to the depth buffer to make holes in terrains (for use of a portal)... I figured that, you would have to draw the underground first, then the invisible quad, than the terrain... You'llhave to ensure that the objects get drawn in the right order, which probably requires that they have different renderque priorities.

One drawback though, is overdraw... Since the terrain has not been drawn yet,there is no clipping performed on the underground, and then the terrain will just get drawn over parts that should not have been visible. In my case, I will use the portals edges to affect clipping, so there will not be lots of overdraw.

Though, I have not tested this yet as I have been working on other things so far.
0 x
Have a question about Input? Video? WGE? Come on over... http://www.wreckedgames.com/forum/

User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD » Mon Mar 07, 2005 9:57 pm

Alternatively you can hack the scene manager to leave holes in the terrain by modifying the index buffers. The holes would probably have to be the same size as the quads at lowest LOD for simplicity. This is probably a more complicated solution than the z-buffer approach. I think this is how they made holes in the terrain in e.g. FarCry.
0 x

User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc » Mon Mar 07, 2005 10:49 pm

[quote="pjcast"]I am working on a portal scene manager of my own, and have thought about this... I also thought of rendering an invisible quad to the depth buffer to make holes in terrains (for use of a portal)... I figured that, you would have to draw the underground first, then the invisible quad, than the terrain... You'llhave to ensure that the objects get drawn in the right order, which probably requires that they have different renderque priorities.
[/quota]
That only works correctly if you look from the terrain inside the underground. But if you look from the underground outside, you get wrong results. I guess you have to switch renderqueue priorities depending on where you are then.

@DWORD: Are you sure? I don't know, but I always thought they use portals in FarCry. They need them anyway to connect their different scenetypes efficiently. To your hole cutting method: Don't you get problems when the quad that you don't draw gets further away and together with the surrounding quads gets rendered in a lower LOD level? Then you would have to ignore that larger quad completely, what is obviously wrong, or you can draw it, closing the hole, what is also wrong. Or do I miss something?
0 x

User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD » Mon Mar 07, 2005 11:29 pm

Marc wrote:@DWORD: Are you sure? I don't know, but I always thought they use portals in FarCry. They need them anyway to connect their different scenetypes efficiently.
I'm quite sure this is how they make their holes in the terrain, but I don't know for sure either. Ofcourse they probably also use portals for the 'entrance' through the cut holes, and for their interiors. I just noticed that in their map editor, you could use a tool that removed/restored quads of the terrain by clicking. Then in their levels they placed some entities on those holes that covered the ugly edge and made a smooth transisition to interior.
Marc wrote:To your hole cutting method: Don't you get problems when the quad that you don't draw gets further away and together with the surrounding quads gets rendered in a lower LOD level? Then you would have to ignore that larger quad completely, what is obviously wrong, or you can draw it, closing the hole, what is also wrong. Or do I miss something?
That's why I wrote "the same size as the quads at lowest LOD". ;) The hole should be defined so that there are no lower LOD levels, i.e. for higher levels of detail more quads would be invisible for the same hole. I don't think this is too hard to achieve. For example you could have a map specifying (in)visible quads, and then when building the index buffers you check against that and just skip the quads that should be invisible.

Edit: But yeah, depending on the number of mipmap levels, the quads can get quite large, so this may not be optimal. Maybe some middle course would do the trick; when things are far enough to use lowest LOD, it probably doesn't make significant visible difference whether you render the terrain at the hole or not. I don't have FarCry installed right now, so I can't check how they do it unfortunately.
0 x

User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc » Tue Mar 08, 2005 10:25 am

Well, this really sounds like big holes. But perhaps that would be the better approach than rewriting the zbuffer anyway.

Is the FarCry Editor freely available via download? Or is it packaged in the box. I've only the demo that does not include the editor (surprise, surprise :) ).
0 x

User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD » Wed Mar 09, 2005 8:56 am

I don't know which method is easiest. It's probably using the z-buffer, but I don't know how much overhead the overdraw would cause.

The editor is packaged with the game. I can try installing it to see how they do it...
0 x

User avatar
pjcast
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2543
Joined: Fri Oct 24, 2003 2:53 am
Location: San Diego, Ca
Contact:

Post by pjcast » Wed Mar 09, 2005 9:12 am

Marc wrote: That only works correctly if you look from the terrain inside the underground. But if you look from the underground outside, you get wrong results. I guess you have to switch renderqueue priorities depending on where you are then.
Nope... If you look from under the terrain, the terrain is not drawn because of backfacing triangles... and in my case, with portals, it is the reverse of what happened before... The destination sector would be drawn first, than the current sector, in this case would be terrain, then whatever type of sector I'm in ;)
0 x
Have a question about Input? Video? WGE? Come on over... http://www.wreckedgames.com/forum/

User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD » Wed Mar 09, 2005 5:25 pm

Just checked how they did it in Far Cry. They're cheating. It appears they cut quad holes at the highest LOD, and then just ignore them for lower LODs, effectively capping the hole. This is from the editor with and without 'brushes':

Image Image

Here are shots with high/low LOD; notice the capped hole:

Image Image
0 x

User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac » Wed Mar 09, 2005 5:51 pm

That makes sense though, if you were far enough away to be in the 2nd lod, you probably won't be looking too closely at the entrances
and if they stick them out enough from the terrain it would be unnoticable
0 x
phear hingo

My Webpage

User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD » Wed Mar 09, 2005 6:05 pm

Yep, it's not very noticeable when far away. A simple way to overcome artifacts (visible errors?) would be to have a lower LOD version of the entrance too where the hole was capped, maybe with some texture looking like the interior, or not rendering the entrance at all. Then it wouldn't be necessary to render the interior.
0 x

User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc » Wed Mar 09, 2005 8:00 pm

pjcast wrote:Nope... If you look from under the terrain, the terrain is not drawn because of backfacing triangles... and in my case, with portals, it is the reverse of what happened before... The destination sector would be drawn first, than the current sector, in this case would be terrain, then whatever type of sector I'm in ;)
But this only holds if you have some special subset of all possible terrains. It could be possible that you look from inside your underground-dungeon, through the entrance onto some mountain. This mountain has to be drawn and does not get rejected because of backface culling.
0 x

User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc » Wed Mar 09, 2005 8:04 pm

DWORD wrote:Yep, it's not very noticeable when far away. A simple way to overcome artifacts (visible errors?) would be to have a lower LOD version of the entrance too where the hole was capped, maybe with some texture looking like the interior, or not rendering the entrance at all. Then it wouldn't be necessary to render the interior.
But that way, they can't have large entrances right? Only some of the size of the smallest Quad. Did they really limit themselves that way? Can you remove 2 or more neighbouring quads in the editor to make larger entrances? What happens then if you switch the lod level? Does the bigger entrance disappear too even though the cheating gets clearly visible?
0 x

User avatar
pjcast
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2543
Joined: Fri Oct 24, 2003 2:53 am
Location: San Diego, Ca
Contact:

Post by pjcast » Wed Mar 09, 2005 8:19 pm

Marc wrote:
pjcast wrote:Nope... If you look from under the terrain, the terrain is not drawn because of backfacing triangles... and in my case, with portals, it is the reverse of what happened before... The destination sector would be drawn first, than the current sector, in this case would be terrain, then whatever type of sector I'm in ;)
But this only holds if you have some special subset of all possible terrains. It could be possible that you look from inside your underground-dungeon, through the entrance onto some mountain. This mountain has to be drawn and does not get rejected because of backface culling.
I'm sorry, but I'm not following you logic...

If I understand what you are saying... you have a mountain underground?... that has a portal that is looking out into the terrain... it would be terrain (destination), invisble portal, than current sector (mountain and underground).
0 x
Have a question about Input? Video? WGE? Come on over... http://www.wreckedgames.com/forum/

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Post by jacmoe » Wed Mar 09, 2005 8:31 pm

Marc is sitting in his underground dungeon looking at a mountain outside. :)
((That mountain is of course part of the terrain))
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD » Wed Mar 09, 2005 8:32 pm

They can have larger entrances by removing more neighbouring quads as they do in the screenshot. Yes, I think they really did limit themselves that way. They completely ignore the holes for lower LOD, but ofcourse that limits the usability. :?
0 x

User avatar
pjcast
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2543
Joined: Fri Oct 24, 2003 2:53 am
Location: San Diego, Ca
Contact:

Post by pjcast » Wed Mar 09, 2005 8:47 pm

jacmoe wrote:Marc is sitting in his underground dungeon looking at a mountain outside. :)
((That mountain is of course part of the terrain))
If that is the case... it still works... it's not a matter of rendering something, than portal, than terrain... It is a matter of rendering the destination, the portal, then the current sector.. Regardless of whether or not terrain is even involved.

So, in this example: outside terrain - including mountains... than the portal, than the current underground sector... I don't see how there is a problem.
0 x
Have a question about Input? Video? WGE? Come on over... http://www.wreckedgames.com/forum/

User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc » Thu Mar 10, 2005 12:09 am

pjcast wrote:
jacmoe wrote:Marc is sitting in his underground dungeon looking at a mountain outside. :)
((That mountain is of course part of the terrain))
If that is the case... it still works... it's not a matter of rendering something, than portal, than terrain... It is a matter of rendering the destination, the portal, then the current sector.. Regardless of whether or not terrain is even involved.

So, in this example: outside terrain - including mountains... than the portal, than the current underground sector... I don't see how there is a problem.
Ah ok, that's what I meant with "I guess you have to switch renderqueue priorities depending on where you are then.".
0 x

User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Post by Marc » Thu Mar 10, 2005 12:23 am

sinbad wrote:I think you'd be best just to poke some solid geometry through it and slap a portal on the front (or a little way down the hollow section). You'd need a SceneManager that can handle portals of course...
... that can be downloaded here http://www.ogre3d.org/modules.php?op=mo ... 57ae08a338

Do you know more details about Chasters code? I posted to his thread but noone reacts. Do you have some, at least semi working code of it? Do you still think adding a general portal concept that primarily allows for mirrors and such effects is the best way or just writing some custom portal scene manager (and then some custom scene managers that can handle several rendering algorithms itself and also connects them by itself through selfdefined portals)?
0 x

Post Reply