What hint brushes do - small explanation

Post anything to do with editing Nexuiz here. Whether its problems you've had, questions, or if you just want to show off your work.

Moderators: Nexuiz Moderators, Moderators

What hint brushes do - small explanation

Postby divVerent » Mon Dec 31, 2007 12:25 am

What are hint brushes? There have been many myths about these, from "useless" via "impossible to understand" to "when you do it wrong, the map will come out all black". However, I will explain the truth about them here now.

Hint brushes are a tool to help q3map2 calculate visibility of maps in an efficient way. They cause more splits in the map, meaning more areas for visibility testing. Why are they needed? Why can't q3map2 do it on its own?

Let me explain it in 2D on the following simple map:

Image

We have two big "rooms", separated by two walls that form a hallway that connects the rooms. When we compile this map, q3map2's tries to separate the maps into "clusters" for visibility calculation purposes. For each cluster, it stores which other clusters it can see. How the clusters are separated, usually comes from extending existing structural (not detail) planes on the map:

Image

Here, the red cluster can see the yellow one, as the right part of the red cluster has a line of sight to the left part of the blue one. The renderer uses the list to know what to render - so when the player and the object stand in the indicated places, the object will get drawn even if it can theoretically not be seen by the player! In other words, q3map2's approach to do visibility calculation isn't perfect and needs help from you - the mapper.

What you now do is create a hint plane (that is, a brush that has common/hint on one face and common/skip on all others). The hint plane will be set so it goes exactly through the corners of the walls. In actual mapping, you'd set the plane to very slightly cut into these corners. I'll just show the actual hint face on my example:

Image

When we now run q3map2's BSP and VIS stage again, it will divide the map into parts like this:

Image

Now the red area no longer has a line-of-sight connection to the yellow area, and the object will be skipped from the player's view point! Even when the player is in the blue area, the object won't get rendered. Looks like we've won... but wait, one thing got worse. Let's move the player and the object a little...

Image

From the cyan area, the object will now get rendered as cyan's top left can see blue's top left. This was not possible before:

Image

so the map got WORSE! How to fix it... you guess it: MORE hint planes:

Image

It will now get divided like this:

Image

which, thanks to the added areas, is a better configuration than you got previously. But actually, q3map2 may have already added the portals I manually hinted here. In the engine, r_drawportals can show you how the portals ACTUALLY are generated.



Conclusion:
  • a hint brush contains one common/hint plane. All other faces shall be common/skip.
  • hint brushes force a subdivision in the BSP tree
  • typically, you want to place hint brushes so they slightly cut two corners, and extend to the walls behind the corners; but it usually won't help if you make a hint brush that's just an extension of an existing structural face, as these ALREADY serve the same way
  • you may need to also add extra hint brushes to compensate for performance losses when using hint brushes
  • how exactly you need to put hint brushes on your map is not always easy to decide. On capturecity for example, I got a huge optimization by putting hint brush pyramids on the rooftops (so what's on the roof isn't rendered when looking from below) and around the car models (so they don't get rendered unless they are REALLY in view). This case here was just a very simple example. I don't think there are existing algorithms to generate a good hint brush configuration, so you have to experiment with it and do it by hand.
  • use r_drawportals 1 to actually view how the map is subdivided. Use r_useportalculling 0; r_showtris 1; r_showdisabledepthtest 1 to see what's actually rendered in game, so you see what you can optimize.
  • for testing performance, record a demo of jumping a bit around on the map. Play the demo as timedemo with different compiles if your map to see how performance changes when using hint brushes
Last edited by divVerent on Tue Jan 01, 2008 12:42 am, edited 1 time in total.
1. Open Notepad
2. Paste: ÿþMSMSMS
3. Save
4. Open the file in Notepad again

You can vary the number of "MS", so you can clearly see it's MS which is causing it.
divVerent
Site admin and keyboard killer
 
Posts: 3809
Joined: Thu Mar 02, 2006 4:46 pm
Location: BRLOGENSHFEGLE

Postby Psychcf » Mon Dec 31, 2007 1:56 am

I get the jist of it, but it's still a bit hard to understand for me...

So basically, the engine tests to see if any part of each area is in view, and if it is it renders the whole section? Is that because testing each brush is too cpu intensive?
Psychcf
Forum addon
 
Posts: 1554
Joined: Sun Dec 03, 2006 11:38 pm
Location: NY, USA

Postby shaggy » Mon Dec 31, 2007 3:47 am

I've seen other maps like this.

Yet, I still don't understand it. Div, will it stuff up my map if I don't do this?
shaggy
Alien trapper
 
Posts: 419
Joined: Tue Apr 03, 2007 6:12 am

Postby divVerent » Mon Dec 31, 2007 9:19 am

[TSA] Psychcf wrote:So basically, the engine tests to see if any part of each area is in view, and if it is it renders the whole section? Is that because testing each brush is too cpu intensive?


Almost right.

The map compiler does that test in the -vis stage. For each cluster, it stores which other clusters can be seen. The engine uses this information to know what to render. What the engine then needlessly renders gets overdrawn by stuff that's closer, so it still LOOKS right - but it's a waste of performance to render stuff that can't be seen.

And it's indeed done because doing that calculation in the engine would be too CPU intensive.
1. Open Notepad
2. Paste: ÿþMSMSMS
3. Save
4. Open the file in Notepad again

You can vary the number of "MS", so you can clearly see it's MS which is causing it.
divVerent
Site admin and keyboard killer
 
Posts: 3809
Joined: Thu Mar 02, 2006 4:46 pm
Location: BRLOGENSHFEGLE

Postby [-z-] » Mon Dec 31, 2007 8:18 pm

Very interesting stuff. Well written explanation. Still going to take me some time to get used to though.
[-z-]
Site Admin and Nexuiz Ninja
 
Posts: 1794
Joined: Mon Nov 13, 2006 12:20 am
Location: Florida

Postby PinkRobot » Tue Jan 01, 2008 9:21 am

Good job, thanks for this clear explanation !
Now with new shiny avatar.
PinkRobot
Alien trapper
 
Posts: 443
Joined: Fri Jul 21, 2006 7:06 pm
Location: #brlogetc

Postby Strahlemann » Tue Jan 01, 2008 3:44 pm

Good explanation div :)

One thing to add: it's also possible to see the generated portals in-editor.
Compile your map and add the "-saveprt" switch to your VIS stage. This will prevent q3map2 from automatically deleting the mymap.prt file after the compile.
Now you can open up your map in Radiant and go to Plugins->prtview->Load .prt file
bleach->aneurysm->straledm5->dieselpower->space-fun->o-fun->runningman->runningman1on1->aggressor(conversion)->soylent->bloodprison->bluesky->ruiner->reslimed->strength
Strahlemann
Keyboard killer
 
Posts: 676
Joined: Wed Mar 01, 2006 12:11 am
Location: Ulm/Germany

Postby TVR » Sat Jan 19, 2008 5:12 am

Your explanation did not cover the rule of hinting, corner to corner traces; the following figure denotes the example fully hinted according to this rule:

Image

Note that each line touches at least 2 outside corners, or 1 inside corner & outside corner [but never 2 inside corners], without going through walls. This perfectly emulates all inter-room view frustums, reducing compile time & removing all overdraw solvable using hint brushes.
TVR
Alien trapper
 
Posts: 404
Joined: Fri Jun 01, 2007 12:56 am

Postby divVerent » Sat Jan 19, 2008 7:59 am

Exactly, that would be good hinting... but wasteful. It would be impossible to edit a map with THAT many hints in GtkRadiant, and would take ages to get it done.
1. Open Notepad
2. Paste: ÿþMSMSMS
3. Save
4. Open the file in Notepad again

You can vary the number of "MS", so you can clearly see it's MS which is causing it.
divVerent
Site admin and keyboard killer
 
Posts: 3809
Joined: Thu Mar 02, 2006 4:46 pm
Location: BRLOGENSHFEGLE

Postby Dokujisan » Fri Jan 25, 2008 1:42 am

Weren't hint brushes used to "fix" capture city because it had problems with performance?

If so, could anyone explain exactly what was done? A real world example might help me to better understand how hint brushes are used.
Dokujisan
Forum addon
 
Posts: 1199
Joined: Sat Oct 07, 2006 4:31 pm
Location: Louisville, Kentucky

Next

Return to Nexuiz - Editing

Who is online

Users browsing this forum: No registered users and 1 guest