Saturday, May 15, 2010

T-Junctions are the enemy.


I'm nearly done with main level construction and I'm freaking out -- I don't want to hit any BSP memory limits. This is the first time I've had to deal with BSP limits when working with Half-Life 2, and it's a testament to how big and bloated "Much Madness" has become. In terms of level construction complexity, this is nearing Adam Foster-like levels of what the engine can handle.

... and now I've hit a memory limit already and it's destroying me.

At this stage in development, there are three memory limits I'm worried about:
  • Waterindices @ (101%) I've tripped this one already. This is misleadingly named -- maybe before, it was actually used for water-related engine stuff, but now it's used to smooth out lighting errors (I think?) that occur when detail brushes touch world brushes to form T-junctions. I'm moving a lot of detail brushes 1-unit away to compensate, and that's resulted in some very marginal memory gains, but I'm still at a loss as to what exactly to do. I think converting func_details into func_brush might help too? Still at a loss for a quick and easy solution that won't require me to go through the entire map construction.
  • Entity count @ (???)I'm not sure what the current entity count is, because the in-editor entity count is wildly inaccurate (a lot of entities get stripped away after level compile). I've only scripted the intro and part of the first half of the game so far, so I'm going to need a lot of entities for that. The in-game limit is 4096 edicts, though the compile tools let you have 8192 because, as I said, it strips away a lot of the entities.
  • Entdata @ (120%) Adam Foster insists that entdata doesn't matter -- most of the Minerva maps are at ~180% entdata usage -- but it's still freaking me out. When a level compiler says "VERY FULL" in all caps, I tend to be wary.
Now look at these crazy bugs and glitches (that fortunately I've fixed or found workarounds to):


The one above happens when I tried to do a screen-blur effect with a reflection shader in the same camera view. I think they use the same screen buffer doodad graphics-jargony thing. Solution: Don't use the screen-blur effect since it's expensive and it looks bad anyway.


This one here is because I got rid of the screen blur effect, but then tried to pair a refraction shader with a reflection shader to make my own weird kind of dynamic water shader. (The built-in water shader does not work if you want the water to move.) Solution: Don't use the reflection shader since it's expensive and it looks bad anyway.

And for your enjoyment, I'll leave you with this, the last time I saw a compile log before all this T-junction nonsense...

Object names       Objects/Maxobjs  Memory / Maxmem  Fullness
------------       ---------------  ---------------  --------
models                 219/1024        10512/49152    (21.4%)
brushes               7208/8192        86496/98304    (88.0%) VERY FULL!
brushsides           53538/65536      428304/524288   (81.7%) VERY FULL!
planes               16224/65536      324480/1310720  (24.8%)
vertexes             53531/65536      642372/786432   (81.7%) VERY FULL!
nodes                 6080/65536      194560/2097152  ( 9.3%)
texinfos              8760/12288      630720/884736   (71.3%)
texdata                298/2048         9536/65536    (14.6%)
dispinfos                5/0             880/0        ( 0.0%)
disp_verts            1029/0           20580/0        ( 0.0%)
disp_tris             1792/0            3584/0        ( 0.0%)
disp_lmsamples      154408/0          154408/0        ( 0.0%)
faces                33064/65536     1851584/3670016  (50.5%)
hdr faces                0/65536           0/3670016  ( 0.0%)
origfaces            24853/65536     1391768/3670016  (37.9%)
leaves                6300/65536      201600/2097152  ( 9.6%)
leaffaces            40935/65536       81870/131072   (62.5%)
leafbrushes          11801/65536       23602/131072   (18.0%)
areas                   25/256           200/2048     ( 9.8%)
surfedges           262679/512000    1050716/2048000  (51.3%)
edges               164795/256000     659180/1024000  (64.4%)
LDR worldlights        389/8192        34232/720896   ( 4.7%)
HDR worldlights          0/8192            0/720896   ( 0.0%)
leafwaterdata            2/32768          24/393216   ( 0.0%)
waterstrips           2976/32768       29760/327680   ( 9.1%)
waterverts               0/65536           0/786432   ( 0.0%)
waterindices         64038/65536      128076/131072   (97.7%) VERY FULL!
cubemapsamples          50/1024          800/16384    ( 4.9%)
overlays                 9/512          3168/180224   ( 1.8%)
LDR lightdata         [variable]    11869988/0        ( 0.0%)
HDR lightdata         [variable]           0/0        ( 0.0%)
visdata               [variable]      166530/16777216 ( 1.0%)
entdata               [variable]      492298/393216   (125.2%) VERY FULL!
LDR ambient table     6300/65536       25200/262144   ( 9.6%)
HDR ambient table     6300/65536       25200/262144   ( 9.6%)
LDR leaf ambient     14503/65536      406084/1835008  (22.1%)
HDR leaf ambient      6300/65536      176400/1835008  ( 9.6%)
occluders                0/0               0/0        ( 0.0%)
occluder polygons        0/0               0/0        ( 0.0%)
occluder vert ind        0/0               0/0        ( 0.0%)
detail props          [variable]           1/231024   ( 0.0%)
dtl prp lght          [variable]           1/4        (25.0%)
HDR dtl prp lght      [variable]           1/4        (25.0%)
static props          [variable]           1/44646    ( 0.0%)
pakfile               [variable]     4515928/0        ( 0.0%)
physics               [variable]     2278055/4194304  (54.3%)
physics terrain       [variable]        1990/1048576  ( 0.2%)