Mapping 103: Brushwork

Alright, so you have created and spawned in your your first room, great work! This is only the beginning, but getting started can be the hardest part, so pat yourself on the back for that!

Let's move on to some other essential aspects to mapping, Texturing and Brushwork fundamentals.

Before describing anything, let's overview some of the most important hotkeys to remember. Write this down to help your memory and practice these button combos!

### Hotkeys:

Get accustomed to some of the most important keyboard shortcuts by going to Edit->Preferences->Shortcuts as well as Help->General->Mouse Shortcuts

* Merge brushes together using ctrl-u
* E, F and V keys are neat advanced ways to modify your selected brush's shape.
* Escape/C unselects a selection
* Middle mouse key copies a texture
* Shift + Middle mouse key pastes the active texture
* 1->0 keys - this changes your grid size. DO NOT GO LOWER THAN GRID 16 WHEN POSSIBLE.
* Alt + 1->0 keys hides aspects of your map
* Shift + [ / ] bracket keys - toggles camera modes (useful for various stages of map making)
* Tab helps you focus/de-focus your camera on a selected brush from a better angle.
* You can use your WASD keys in camera view to look around and mousewheel to move even faster. Your movement speed can be changed in preferences.
* CTRL + movement keys helps you 'nudge' brushes one grid at a time.
* ALT + movement keys nudges textures.
* Shift + Left click on a texture opens up the shader file so you can view the shader properties
* Spacebar duplicates a selection
* N pulls up your entity window
* / pulls up your model browser
* S pulls up your surface inspector (for aligning and transforming textures)
* G toggles grid guide, if a brush face or patch is selected it pulls up your UV editor for moving or aligning textures.
* Ctrl-G Snaps selected brushes to whichever grid you are currently on.
* Ctrl+X brings up a green line to help with aligning one brush with another.

These are some but not all of the shortcuts you should remember.

# Textures -> Shaders

A texture is the name given to the image applied to the face of a brush.

A shader is a computer program that calculates the appropriate levels of light, darkness, and color during the rendering of a 3D scene. For games it can also have other certain properties, things like surface properties (turning it into water etc) or lighting aspects and more!

A lesson on shaders will be later as it is quite complex, but for now just know that the engine by default will create a basic shader (meaning give it basic settings to be viewed in game) for that texture. A common rookie mistake is thinking you can have a texture in-game with no shader. Wrong! Netradiant will by default add a shader to any texture if it is not set. This allows it to properly light each brush in the .map file. If you give your shader certain properties, it will perform differently in-game or in the editor depending on what you want. The best example for interesting shaders with game mechanic-changing properties are found in textures/system (there is a tutorial explaining those shaders in Mapping 104).

All textures that you want to see in your editor and in-game must be either in a .pk3 or within base - subdirectory textures or MBII/textures. Try to keep your texture directory neat and remember that netradiant will load whatever is in a folder first, but MBII will load what is in a .pk3 last, which will overwrite anything in your folders. This can cause conflicts, so you may need to create a .pk3 which gets loaded last (zz\_z\_example.pk3) to insure all those assets get loaded last and thusly used in MBII.

A brush typically has 6 faces, all of which will have a texture applied.  At the simplest level a texture on a face will be a JPG or TGA file of anything from a single color up to an image of Jar Jar.

#### Engine Restrictions:

* Textures must be in powers of 2 or else the engine will not read them and are generally recommended to stay under 1024. You could go up to 2048 for a few textures (like skybox or a big terrain brush) but this could hurt performance a bit if an area is already too high in detail. MBII struggles on some computers which do not have a lot of VRAM, and adding a lot of high resolution textures only adds to this problem, reaching a limit for certain computers. Use sparingly.
	+ What do I mean by power of 2? Well, you could add a 1x1px texture, or a 1x2 texture, or a 8x8 texture, or a 8x16 texture, and so on. You cannot add a 1000x1000px texture as that is not going to get read by the engine as it is not the proper format. 1024x1024 however, would work. 2048p x 1024px would work!
* If you want to add a texture, please keep in mind that the file should either be a .jpg or .tga (which stores transparency similar to a .png, it just does so in a separate layer. I sometimes create a .png and then convert it to .tga using this GIMP plugin).
* JPEG textures are smaller than TGA textures in bytes. TGA textures have more quality than JPEG textures. Does file size still matter? Probably not, but just keep this aspect in mind when creating larger textures. Progressive jpegs are not supported by the engine, so be sure to save your jpegs properly.[1]

### Nice **Caulk**, Bro

The most important and most used shader for mapping is called Caulk. Faces with caulk on them are not drawn, and so must never be somewhere that a player could look at it.  You've probably played a map where a caulked face is accidentally visible, and you get a weird hall of mirrors effect while you look at it.  Get used to the habit of making any surface that is not visible to your player in the map caulk. Caulk is a very important shader, one you will become very familiar with using as you map.

**Caulk is essentially 'null'** - no textures are rendered on anything which has this face.

**In making a map you should be trying to achieve your design aims by using the least number of brushes and the least number of visible faces as possible**.  One way to achieve the latter is to create your brushes initially entirely from the caulk texture.  Then you "paint" the visible faces with the required texture, safe in the knowledge that all the other faces are caulked. Another more modern method of doing things is to use the autocalk feature (F4) which will automatically paint anything facing the void as caulk. It actually works pretty well but it's better to get into the habit of creating your new brushes with caulk!

For example, say you created a brush to be used as floor in a room.  You decide to make the whole brush a wood texture and you slot the brush into place.  You forget to later caulk the bits you can no longer see, so you end up with 5 other faces that the engine must consider when deciding what to draw, when if they had all been caulk it would not present this overhead.  It may seem like small fry, but a big MBII map may have 8,000 brushes, and so about 48,000 faces, which translates to around 96,000 triangles to be considered and possibly drawn.  As you want to try to keep the maximum number of triangles drawn (tris are created out of brushwork during the compile process) to under perhaps 40,000 you need to ensure you **use caulk wherever possible**.

So let's start correctly with the flat square we've created.  We're going to make that the floor.  We caulk an entire brush by selecting the brush and right clicking this icon.

All brushwork which is hidden from the player or facing 'the void' should be caulk. This will also make editing your map easier because you can then hide the caulk when you don't need to see it. To hide various Caulk is found within 'system' in your texture browser. It can also be your default brush if you set it to be in the Brush settings of your Preferences (P).

Alt-6 is your hotkey for hiding and unhiding caulk. Generally speaking Alt + a number key will hide or unhide elements within your map depending on what it is.

*This is the bar which is used for hiding and unhiding certain elements within your map:*

### Painting Textures

Textures are applied in the 3D window. First you'll want to select a texture in your texture browser. This texture browser will show base jka textures by default and also have all MBII textures if your netradiant is set-up correctly. Once a texture is selected, use the middle mouse button to copy one texture and middle mouse + shift (or ctrl) to paste that texture on to your brush. Your next chapter is texturing, so for now just try putting any kind of textures together on your brushes and continue reading.

### Good Brushwork Habits lead to optimized maps

* Use the caulk texture for faces that are always invisible in game:

Prevent overlapping (brush) faces when possible. For faces which are not seen, this is less of an issue, but still good practice. For faces which are seen, this is important.

### **Structural** and **Detail** **brushes**

Get used to the habit of making any new brush you make that is not the outside 'hull' of the map into a detail brush. The hotkey with Netradiant-custom is **Alt-D**

This is a very important detail (heh) to remember. By default any brush you place is Structural. Now, to be clear a player in-game will not be able to tell the difference between Structural or Detail because both will be able to block player's line of sight. *But* the structural brush in this case is what blocks the compiler's view as well as what protects the rest of the map from the void. Imagine your map in two ways, the hollow room with no extra fluff to it and all of the decorative brushwork that gives it personality. The hollow part should all be made up of structural and the decorative stuff should all be made into detail. Your map will leak (causing it not to compile) if your structural brush integrity is flawed, so use good practice and properly hull your map with structural brushes.

This is a room with every brush as Structural:

The lines and colors pictured are visualizations of the portals created in the VIS stage of the compile. We get to see them using the .prtviewer plugin and by having -saveprt in our build.

Here is the same room, except all brushes excluding the outside hull have been turned into detail. Only 4 portals!

This is why 'blocking out' your map idea first before making it look good is recommended: You'll be able to more easily come up with good structural brushes for your rooms before you add anything else to it. You shouldn't make every brush in your map structural and you can't make every brush in your map detail. You use both, but generally speaking you create your basic map layout first using structural brushes. You test with a very simple 'blocked out' layout, see where your players end up on the map, and then once happy, start to add more detail as you go. Simple structural hulls around your map lead to simple portals generated by the compiler and faster compile times.

### Understanding **Leaks**

JKA follows the indoor engine philosophy: it expects maps to be massive airtight containers. If a map has a gap anywhere to the outside world it's considered a leak and won't compile. This is what a map looks like in-game when viewed from outside the airtight play space:

This looks nothing like the collection of 3D brushes used to make the map, because it has been processed further by the computer. During compilation only the sides of brushes visible when playing the map are kept; everything else is never seen and the compiler essentially "throws it away". You can see inside through the walls of this picture because the 'faces' or 'sides' of the map are only visible in one direction and have been caulked.

Leaks from the the warm, dark recesses of the game into the infinite void beyond are politely marked with red 'escape routes' by NetRadiant:

> If you have multiple leaks in hidden spots, try using Shift+Ctrl+K / Shift+Ctrl+L to move back and forward along the leak to find it (they can be navigated for within View>Camera and can be re-bound to a key if you go to shortcuts and re-bind them) q3map2 assumes that all objects are on the 'inside' of your map, therefore leak detection is done starting from these objects.
>
>

You also cannot store any type of entity outside of the boundaries of your map without causing leaks. This includes light entities! Patches also are not considered structural, so those need to have structural caulk behind them if they are touching the void.

Once leaks are fixed you can try compilation again. You can observe the compilation process in the console area of NetRadiant.

### Good Brushwork vs. Bad Brushwork

Turn a straight wall with many brushes and textures into one huge texture and one brush. It is about texture count and size versus brush count.

Example here would be two brushes on the left getting merged into one (Ctrl+U). The only reason you would keep these two separate would be if you wanted one to have different textures than the other. Otherwise it will be twice as much work for the compiler to compile.

**IMPORTANT**: For an example like a wall, where you want to have multiple textures but you don't want to have multiple structural brushes, You can create one large structural brush that is caulk, and then 3 detail brushes inside that large structural caulk brush. The structural brush will be invisible in game and you will have created a simpler structural hull than having 3 structural brushes.

### Using the grid (and staying on it)

One of the bigger mistakes a new mapper can make while starting their first big project is not keeping your brushwork aligned on a bigger grid. Generally speaking, the higher the grid you work on, the easier time you will have later on when you are fine-tuning the details of your map. Use the number keys on your keyboard to switch between grids. It is advised to never go lower than Grid8 if you can help it. This will especially come in handy later on when you start using Patches or diagonal brushwork. It will be a lot easier to align anything diagonal on brushwork you placed on a larger grid size! Do not use grid 1, it is a cursed place. :C

### Hiding/Revealing

Once a map is walled and roofed in it can be annoying to be constantly either hiding brushes or moving 'inside' the confines of your map's corridors to work on things inside the map. If you caulk the faces of walls, ceilings, floors etc that face *outwards* you can then tell NetRadiant to essentially 'filter' these surfaces out. Same goes for hiding entities, models, etc.

To make caulked surfaces invisible (*filter* them out), look in the *View->Filter* menu, but a more easier method is via Alt + # or filter things on and off with this UI:

Now you can work 'through' walls and look at things easier without seeing a bunch of caulk everywhere!

Another important hotkey to also remember for Netradiant is **H -** which hides whatever you selected. To reveal it again - Shift+H

### The Power of Grouping

Select a bunch of your brushes together and then click the group icon.

This will group all of those brushes so that when you press **Shift-E** after selecting any brush within that group, you can select that entire grouped chunk with ease. This will make moving complex pieces to other spots super easy. It is highly recommended when first starting on a map layout to make each room a group so you can keep things easily modular at first. Grouping things together turns them into their own entity, this is important to keep in mind for later advanced usages.

### Moving Entire Sections of Maps

Take a whole brush and drag it all the way around the area you want selected. Next, click **Select inside** in the toolbar.

Now you can mess with entire sections of maps! Useful for not only working internally, but also if you want to "borrow" something from another map in another instance of NetRadiant. You can also achieve this effect with **Select touching**.

### Resizing

> *Did you make your map or brushwork too big or too small?*
>
>

**Arbitrary scale** is a pretty nice tool for percentage-based transforming (found in Modify - > Arbitrary Scale). Try scaling stuff up in percentages of .25 to be safe. Avoid this for mass-scaling a bunch of stuff as it will probably throw everything off the grid.

**Snap to Grid**. Simply select the brushes/patches/entities (or individual vertex points using the V tool) you want to snap to your currently selected grid and press Ctrl+G to snap them to your currently-set-grid. Very powerful tool!

# Cool new Netradiant-custom Features

## Quality of Life Tweaks

### Preference Tweaks

* Within Edit>Preferences
	+ Brush > Always use Caulk for new brushes (I prefer this as a time saver)
	+ Brush > New Brush Type - Valve 220 is the latest and will help improve your workflow when aligning textures. Older maps use Brush Primitives.
	+ Camera > Camera View Preferences
		- Sometimes it takes forever to move from one side of the map to the other, increase these values to be a bit more speedy when using WASD.
		- There are other ways to move fast within the editor
		- Ctrl+M3 in 2d view
		- Tab on selection of brush
		- Scroll when alt+M2 orbit mode
		- Scroll when tab on selection

#### Color Scheme

I prefer the *Maya/Max/Lightwave Emulation* themes.

I also suggest misc>themes>gtk themes>human radiant dark or 'gui theme' for a nice darkmode experience.

### Troubleshooting

#### Clipping Plane

You may have troubles with the default clipping plane distance:

The 3D camera in NetRadiant can only see for a certain distance -- everything beyond that point is literally *clipped* out of existence. The 'clipping plane' represents the mythical flat surface separating what you can and cannot see. I have accidentally turned this on once or twice and gotten really frustrated when I couldn't figure out how to turn it off! You can toggle it here:

The clipping plane's distance from the camera can be extended by pressing **Ctrl+]**. Larger clip distances can reduce the frame-rate of the 3D view, because more things will have to be rendered.

#### CSG Tool

You can use the CSG tool to easily create rooms and extrude faces of your brush. Try making a new room with this tool by making a very large brush and creating a hollow:wrap

#### Subtract

You can use the Subtract Tool (shift-H) to cut shapes into other brushes

*Be careful using this tool as it does not create optimal cuts on more complex brushes. Only use this for very simple cuts (like the above example) and keep an eye on the console for how many 'fragments' were created from each subtract (in this case 4 fragments from one subtract makes sense)*

Now look at how quickly I have created 3 rooms and 3 halls using these two new features. First I set up my three brushes like this, where the hallways are slightly clipping into the brushes:

    Next I create rooms via the CSG tool

    This creates lovely, mitered rooms (you'll notice the connecting faces are angled which is better for optimization and a good practice for all brushwork)!
I now select just my hallways and click the subtract tool:

    I simply delete the hallway and 'subtracted' wall faces within the rooms and I now have a very fast method of getting new rooms and hallways made without having to do every single brush!

    If I made a mess of things with the subtract tool and created too many brushes from the subtract, I just need to move things around a bit and merge the brushes of the floor or wall to be merged. This process will feel seamless once you get it down.

Ok, nice. You got some rooms, now let's put a chair in it. Rich Diesel wants us to make chairs in his tutorial, so let's become chairmasters, but let's use the power of Netradiant to help us a bit instead of doing it the way he wanted.

We no longer need to painstakingly paint every non-visible face caulk to keep our brushwork optimized. In this case I built four chair legs which have both the top and bottom faces un-caulked.

        After adding the top part of my beautiful chair (notice how I mitred the top aspects), I am going to autocaulk the whole selected chair (F4]. After doing so you can see it caulked the hidden areas. Amazing! Huge time saver. This autocaulk does it's work depending on your camera position and the surrounded brushes selected.
Since I did not select the floor when I first did my autocaulk, the bottom floor-facing faces of my chair are not autocaulk. Easy fix, just select the floor too.

    And it's done! Our chair has proper caulk and it barely took any time at all. Rich Diesel would be in awe. Autocaulking is a powerful new tool within Netradiant-custom.

Time for another neat 'brush-building' feature:

#### Arbitrarily adding vertex points

With your brush selected and V pressed once, you can click any area in space to add a new brush point to that camera view area.

This takes a bit of practice and involves the right camera angle/placement, but is very useful in the right scenario. It works in the 2D view as well. If clicking outside there, it inserts two points which is easy for 2d shapes. I like using this with a system/clip brush and covering up a model.

More of these features are showcased at https://garux.github.io/NRC/

Next chapter: Mapping 103: Texturing