Jump to content
The Dark Mod Forums

Have we been selling visportals short?


Springheel

Recommended Posts

 


Ok, I've listened to the video

Sorry for that :(

 

:) :) :)

 


My question is, what value is added by having the large, closed visportals there?

The yellow areas aren't taken into consideration for rendering. Note that this refers to tris, not lights or shadowcasters. Destined misunderstood that, as you've already noticed (see my note at the end of the post).

 

As the areas get culled via the visportal (the small ones), it is clear they will be discarded during this process anyway. However, this still has to be calculated. So if the big visportal weren't there, for each tris in the yellow area the engine would have to check whether it gets culled by the visportal or not. Due to the big closed visportals the tris in the yellow area gets completely ignored, because it is already clear they will not be visible for the player. Note that this is no draw call.

 

Draw calls means that something should get rendered by the engine. The major part in regards to performance optimization takes place in the frontend, though. And the only thing that gets rendered there is the depth image. So as I stated in several similar threads the draw call is no sufficient indicator for the performance impact. Most missions that suffer performance issue do not suffer them because a lot of stuff gets rendered (at least not only), but because a lot of stuff has to be discarded during the preprocessing of the rendering. This means that the renderer has to deal with a lot of stuff that never gets rendered, which is a waste of computing time.

 

 


This means: if there is a light in the yellow part that extends into the corridor, it would not show.

 


2. Additional lights and shadow-casting objects in sealed off areas are taken into consideration if they could potential be seen (casting shadows or throwing light into visible areas)

This statement means the exact opposite. See the linked webpage for a detailed description with images (the latter ones will make it much more clear what is meant).

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

So if I get this right, closed visportals are a shortcut--if things are behind an opened visportal, the engine has to check and see if they are visible to the player. If they are behind a closed visportal, that check can be skipped because the engine knows right away they're not visible.

Draw calls means that something should get rendered by the engine. The major part in regards to performance optimization takes place in the frontend, though. And the only thing that gets rendered there is the depth image. So as I stated in several similar threads the draw call is no sufficient indicator for the performance impact. Most missions that suffer performance issue do not suffer them because a lot of stuff gets rendered (at least not only), but because a lot of stuff has to be discarded during the preprocessing of the rendering. This means that the renderer has to deal with a lot of stuff that never gets rendered, which is a waste of computing time.


Is there any console command to show how much preprocessing is taking place? How can a mapper tell whether his visportal is doing any good if draws and even shadows don't tell the whole story?

  • Like 1
Link to comment
Share on other sites

 


So if I get this right, closed visportals are a shortcut--if things are behind an opened visportal, the engine has to check and see if they are visible to the player. If they are behind a closed visportal, that check can be skipped because the engine knows right away they're not visible.

Now you've got it :)

 


Is there any console command to show how much preprocessing is taking place? How can a mapper tell whether his visportal is doing any good if draws and even shadows don't tell the whole story?

Not that I know off. It is a matter of mission conception anyways. If an area behind an opened visportal is for the most part not visible, the visportal is doing a bad job. If a visportal is only open when you can see most of the respective visleaf, it does a good job. You cannot completely avoid the above mentioned check, though. You should just make sure it doesn't get out of hand.

  • Like 1

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

So basically it works like in other engines. In UE2, back when it had ZonePortals, I saw similar behavior, especially while working on a nature/pagan setting. At some angles, grass and vegetation meshes were popping in gradually, based both on player FOV and the ZP placement. You could also adjust how aggressive portals were in terms of cutting stuff off.

Edited by Judith
Link to comment
Share on other sites

edit:

I did a test using your setup above and could not confirm your claim. The large visportal was even closed from the player's position. There was NO difference to drawcalls or shadows, regardless of whether the large visportal was present or not. This suggests that the 3 AI are not being drawn even with only 1 visportal.

The second large VP is red, which means its closed. So anything behind that should be not be rendered, the only thing I can think of is that because you used Ai instead of ordinary entities. What did r_showtris 2 show being rendered..?

 

edit - Obs post above put it better

Edited by Bikerdude
Link to comment
Share on other sites

he second large VP is red, which means its closed. So anything behind that should be not be rendered,

 

 

Nothing is being rendered even if that visportal isn't there, which is why the drawcalls didn't change when it was added.

 

The key is that it's not about rendering...it's what the engine has to do to decide what is being rendered. That's the piece that has been missing from most of our documentation.

 

That fact also severely undermines using drawcalls or even shadows as a primary performance guide. As far as those two things are concerned, you could have every visportal in your map open and it wouldn't make a difference.

  • Like 1
Link to comment
Share on other sites

Hmm.

 

I know that SteveL worked on func_occluders to work more like typically engine occlusion culling.

 

I wonder if you just had VP's that span an open area every 100 units (etc) if it would act the same?

Eg. The blocking geometry in front of the next nearest open VP would cause the shortcut to kill

all the rendering behind it just like an occlusion system.

 

That would also explain the strange performance characteristic where a long view which is barren of geometry

still has a large impact on rendering whereas a short view with TONS of complex geometry can perform very well.

It's the increased search space for the algorithm as you go further from the source of the view frustum.

 

Experiment:

 

post-3763-0-15038200-1498166689_thumb.jpg

 

???

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Can anyone confirm that visportals not in the players field of view (eg, behind him) are automatically closed?

Link to comment
Share on other sites

They are.

 


I wonder if you just had VP's that span an open area every 100 units (etc) if it would act the same?

Eg. The blocking geometry in front of the next nearest open VP would cause the shortcut to kill

all the rendering behind it just like an occlusion system.

I'm not sure this approach would work very well once the missions become sufficiently large. The more vp's you have the more complex is the BSP tree. I guess sooner or later you could reach a point where this could become a problem.

 


It's the increased search space for the algorithm as you go further from the source of the view frustum.

I think it is more that you will likely have more adjacent visleafs and therefore more stuff that needs to get tested. For each light in an adjacent but closed off visleaf you have to check whether its light volume is in the visible part of the BSP tree. More of such leafs means more to test, which is bad. I don't think distance or tris size plays any role here.

 


At some angles, grass and vegetation meshes were popping in gradually, based both on player FOV and the ZP placement.

This sounds like an additional optimization step on top of the basic visportal structure. idTech4 doesn't go that far.

 

All engines are using such techniques btw. Engines meant for creating inner areas due rely more on the visportal approach (even the DarkEngine did, although the portals were created automatical there, possible due to the low poly count back in the day), open world engines rely more on tiles, as vp's don't work there very well. Some engine might feature both, dunno.

  • Like 1

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Engines like UE3 and newer don't use portals at all, they all rely on automatic culling and LODs. Since they use static lighting and lightmaps, they're much more forgiving in terms of perfomance, but you have to be careful about your models, because they act as occluders. That means e.g. one mistake, like a small space or hole in your wall model, or improper placement, will cause the whole location behind it to be rendered.

Link to comment
Share on other sites

  • 4 weeks later...

I don't like that you are talking about performance of rendering as a binary thing: engine either renders an object or not.

It is much more complex. Aside from draw calls (which are very important), there are other things involved.

For instance, pixel fill rate (think about pixels you have to fill with data) and other read/writes to memory.

Also, the complexity of the per-pixel visual effects (which are done in pixel = fragment shaders).

So it is all more complicated: the engine is big, and it is very hard to fully understand all the performance details.

 

First I'll try to correct some misunderstanding here (well, at least I think so):

  1. An entity cannot be culled out only because it is occluded by some set of entities. So if there is a candle behind a crate (or several crates) in a room, the candle will be rendered regardless of crates presence. In my opinion, there is no efficient way to check that the candle is fully behind a crate or a barrel, that's why I think so.
  2. Quake 1 really has software renderer with zero overdraw, but Doom 3 renderer does not have. If engine renders several surfaces which are located on the same place on the screen (and thus occlude each other), then even occluded pixels would take some time to render. However, Doom 3 performs "early depth pass": it renders all the geometry without any lighting/coloring/texturing at the very beginning of the frame to produce depth map. After that it renders everything again, but all the complex math for lighting/texturing (i.e. fragment shader) is done only for the pixels which are actually visible and not occluded by anything. For the pixels which are occluded, only depth calculation and comparison is done (which is much cheaper than full rendering). So you pay for visible pixels, and pay much less for occluded pixels.

As you see, the only way to not pay for triangles and draw calls is to cull the surface completely in frontend.

This is what I'll try to explain now: let's go back to portals culling.

 

Let's call arbitrary convex polygon on screen "winding". For instance, every portal that you see with r_showPortals is rectangular, and its winding (which is a 2D thing) is a 4-gon.

Every area can be seen by player through a sequence of portals (let's call it "portal path"). For the area where the player is located there are zero portals in this sequence.

Given a portal path, you can intersect the windings of its portals, and you'll get a polygonal winding through which you see the area at the end of the path.

For instance, on this picture the outside area is visible through two portals, which together yield 5-gonal winding (marked by orange color):

post-3344-0-71322300-1500632076_thumb.jpg

 

Now the main rules are:

  1. If the windings of the portal path have empty intersection, then it is culled out.
  2. if one of the portals is sealed (maybe closed door), then the portal path is culled out.

If all portal paths leading to an area are culled out, then it is not rendered and you don't pay for it.

If there is a single remaining portal path into an area, then its winding (recall that it is intersection of path's portals) is used to cull out the entities in the area: if an entity's bounding box is not visible through the winding, then entity is not rendered (so you do not pay for it). If there are several portal paths leading into an area, an entity is drawn only if its bbox gets into at least one winding (I think so). Unfortunately, I cannot say how the winding of the portal path affects the world geometry, but I can imagine that surfaces (sorry, I don't know if "surface" is a known concept/term in DR) which are surely not visible through the winding are culled out too.

This is not over yet. There is also an OpenGL thing called "scissor test", which allows to skip rendering of pixels outside of a specified (axis-aligned) rectangle on the screen. Doom3 uses it heavily: when rendering an area, it sets scissor rectangle to be minimal rectangle bounding the windings of all the portal paths leading to the area (usually one portal path leads to an area, but not always).

 

As you see, even portals which can be seen through by player (drawn as green when you enable r_showPortals) can help a lot with culling. Note that the description above explains the final effect of portals culling, but does not exactly describe how the implementation works internally. Also, I think that the overhead introduced by portals is pretty low: you should not be afraid that setting 2x more portals would waste CPU time (I suppose so).

 

Note that there are also shadows, which are culled by different code. For each shadow-casting light, a similar procedure is started from the light itself. It does not matter whether portal is sealed or not here. The algorithm for culling by portal path seems to be completely different in this case, but it also takes into account the fact that even visible portals limit the range through which the light goes.

 

 

Having said all that, I'd like to ask a question: has anyone seen a case when adding a portal (or several portals) seriously reduces performance?

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Having said all that, I'd like to ask a question: has anyone seen a case when adding a portal (or several portals) seriously reduces performance?

Yes, from memory when you have a big open area and the geom dosen't allow for efficient culling with VPs. The town area in one of my early maps, St Albans cathedral - that was a a bloody night mare due to my virgin VP skills. It was on that map I learned about the inefficiency of too many horizontal VPs and that it was better to use vertical.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 3 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...