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 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.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

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?
    User avatar
    Psychcf
    Forum addon
     
    Posts: 1554
    Joined: Sun Dec 03, 2006 11:38 pm
    Location: NY, USA

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?
    User avatar
    shaggy
    Alien trapper
     
    Posts: 419
    Joined: Tue Apr 03, 2007 6:12 am

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.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

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.
    User avatar
    [-z-]
    Site Admin and Nexuiz Ninja
     
    Posts: 1794
    Joined: Mon Nov 13, 2006 12:20 am
    Location: Florida

Tue Jan 01, 2008 9:21 am

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

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
    User avatar
    Strahlemann
    Keyboard killer
     
    Posts: 676
    Joined: Wed Mar 01, 2006 12:11 am
    Location: Ulm/Germany

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

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.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

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

Fri Jan 25, 2008 7:38 am

  • Just open the map in GtkRadiant...
    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.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Fri Jan 25, 2008 11:13 am

  • ... or read the old Capturecity Optimized thread made by divVerent :wink:
    Ronan
    Alien trapper
     
    Posts: 292
    Joined: Tue Mar 20, 2007 10:25 pm
    Location: France

Tue Dec 30, 2008 2:46 pm

  • I came here planning to read up about hint brushes. Well the reading is still no problem, but the initial post has lost its images which makes the whole thread a bit useless.

    divVerent has told me he does not have these images any longer. Is there anybody out there who does? Did someone perhaps save the whole page including the images?
    Now with new shiny avatar.
    User avatar
    PinkRobot
    Alien trapper
     
    Posts: 443
    Joined: Fri Jul 21, 2006 7:06 pm
    Location: #brlogetc


  • divVerent wrote: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

    [compilation simulated with CSG Subtract]

    Here, the green 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. 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 yellow area no longer has a line-of-sight connection to the green area, and the object will be skipped from the player's view point! Even when the [first] player is in the blue area, the second player won't get rendered. Looks like we've won... but wait, one thing got worse. Let's move the players 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.

    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 touch 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
    TVR
    Alien trapper
     
    Posts: 404
    Joined: Fri Jun 01, 2007 12:56 am



Return to Nexuiz - Editing




Information
  • Who is online
  • Users browsing this forum: No registered users and 1 guest