KF SDK: Textures and Static Meshes
Two tutorials by mapper K-2 from the killingfloor.ru forum (2011) on working with textures and static meshes in the KF SDK, plus a few useful clarifications from the discussion threads. The editor fundamentals (brushes, lighting, paths) are covered in map editor basics and the mapping guide.
Texture Browser
A texture is an image applied to surfaces. You view, select and edit textures in the Texture Browser: View > Show Texture Browser or the button on the top toolbar. It also opens when the editor starts.
Browser elements:
| Element | Purpose |
|---|---|
| Top field | Currently open texture package |
| Bottom field | Group within the package |
| Show-all button | Show every texture in the package |
| View mode | Textures in the package |
| Used in map | Only the textures used in the map |
| Most Recently Used | Recently used textures |
| Properties | Open the selected texture's properties |
| Source package | Open the package the selected texture comes from |
| Group switcher | Quickly jump between groups |
The browser opens and creates .utx texture packages, which are split into groups. A filter helps find textures quickly, and the preview size is changed on the View tab.
Applying and aligning textures
To apply a texture to a brush, select the surface and click the texture in the browser.
If the texture lands wrong or does not line up with its neighbours, the most precise way to fix it is the Pan, Rotate and Scale tools in Surface Properties:
| Field | What it does |
|---|---|
| Pan | Texture offset (in pixels, relative to size) |
| Rotate | Rotation and mirroring |
| Scale | Texture size as a pixels/Unreal Unit ratio |
| Scale for U and V | Same, but separately for horizontal and vertical: lets you stretch or squash the texture |
| Relative checkbox | Whether the change is relative to the current size |
| Lightmap size | Lightmap resolution for this surface |
U is horizontal, V is vertical. Hold Shift to pan or rotate the texture in the opposite direction.
There are also the Texture Pan and Texture Rotate tools. In Texture Pan, holding Ctrl with the left or right mouse button pans the texture, and both buttons together change its size. Texture Rotate works the same way but rotates.
Importing and exporting textures
In the Texture Browser choose File > Import. In the import window:
| Field | Meaning |
|---|---|
| Package | Package to import into. Use MyLevel to store the texture inside the map file without an extra package. If you imported into a separate package, you must save it |
| Group | Group, as you like |
| Name | Texture name. If a texture with this name already exists, it is replaced |
| LOD | Levels of Detail: several versions of the texture at different detail levels, switched by distance to the camera. Leave at 0 for maximum quality |
| Masked | For textures with fully transparent areas |
| Alpha | Same, but with partial transparency (alpha). If unsure, tick Alpha |
| Generate MipMaps | Generates smaller copies of the texture. Safe to enable |
| Detail Hack? | Only for detail textures (see below): blurs them at large distances |
Texture sides must be powers of two (16, 32, 64, 128, 256, 512 and so on). Supported formats: dds, tga, bmp, pcx, upt. If an import silently does nothing, see the texture import item in the mapping guide's known errors.
The best option is dds (DirectDraw Surface). After import you can convert a texture to dds and compress it: select it and choose Tools > Compress (also available from the right-click menu). Compression types:
| Type | Alpha | Note |
|---|---|---|
| DXT1 | Opaque | Highest compression |
| DXT3 | Explicit | Often used for light coronas |
| DXT5 | Interpolated | You will not go wrong with DXT5 |
After compression the browser shows a tag in brackets next to the texture name, for example [DXT3], meaning compression succeeded. Watch the size: a dozen textures of 1024×1024 and up in one package can weigh around 100 MB, and players will wait a long time downloading it from the server (a note by UltraKill in the discussion).
Transparency without surprises (killingfloor.ru forum, threads "DDS и иже с ним (война с форматами текстур)" and "Текстуры без фона"). A DDS with alpha saved from Photoshop often comes out wrong: smeared colours instead of a transparent background, or alpha in "blocks". It is more reliable to save the image as a 32-bit TGA with an alpha channel, tick Alpha when importing into the SDK, and compress it to DXT5 (or DXT3) in the editor. In the alpha channel black is the transparent part and white the visible part; if you get an empty transparent square after import, check the alpha channel. If you do save DDS from Photoshop (NVIDIA Texture Tools plugin), pick DXT5 and remember the Alpha checkbox on import. Paint.NET can save DDS without a plugin.
To get a texture out of the editor: File > Export or right-click → Export to File…
Texture properties
Open properties via Edit > Properties or by right-clicking the texture.
| Group | Contents |
|---|---|
| Animation | Simple frame-swap animation: a single texture's properties only hold the next frame and the switch rate. Not the best approach |
| Material | The texture's material. Picking an EST in SurfaceType sets hit and footstep sounds and impact particles (wood, glass, metal, etc.) |
| Quality | bHighColorQuality and bHighTextureQuality. No visible difference between True and False |
| Surface | bAlphaTexture — partial transparency (can be set on import); bMasked — parts of the texture are either fully transparent or opaque; bTwoSided — two-sided texture, not a very useful feature |
| Texture | Detail texture, DetailScale, LOD and LODSet (see below) |
| TextureFormat | Just shows the texture format |
Detail textures
Details are usually small grey textures layered over the base texture to improve how it looks up close. In KF they are in the Detailtextures_T.utx package.
- Select the detail texture in the browser.
- In the base texture's properties, Texture group, click Use in the
Detailfield. - Adjust the size ratio in
DetailScale: the higher the value, the finer the details.
The same group also has LOD (the higher it is, the blurrier the texture) and its type LODSet, but setting them is optional.
Glowing textures (shader)
A clarification by K-2 from the discussion on making a texture glow like neon signs:
- Create a new shader in the Texture Browser.
- Put the desired texture into the
DiffuseandSelfIlluminationfields. - If only part of the texture should glow, add a
SelfIlluminationMask.
The SelfIlluminationMask texture needs an alpha channel: make transparent every area that self-illumination should not affect; a smooth gradient transition is possible. Simple masks can be made even in Paint.NET by erasing parts; for complex ones, Photoshop or similar is better.
Animated textures
The editor offers two ways.
Frames with an _aXX suffix
Import the frames with an _aXX ending in the name, where XX is the frame number starting at 00:
name1_a00
name1_a01
name1_a02
The next frame is set automatically in each texture's Animation group. Speed is set with FrameRate. The monitor screens on KF-Icebreaker partly use this method.
MaterialSequence
- In the Texture Browser choose File > New.
- Set the package, group and name, and choose
MaterialSequenceinMaterialClass. - Add frames in the
SequenceItemsfield with Add. - Set three parameters for each frame (table below).
| Parameter | Meaning |
|---|---|
| Action | The stage: FadeToMaterial — the image smoothly blends into the next (often used for map previews); ShowMaterial — the image is simply shown (several of these in a row switch instantly) |
| Material | The frame texture |
| Time | Stage duration |
The resulting sequence is displayed as 1 pass. The map's loading preview itself is set in F6 > LevelSummary > Screenshot (a tip from BAHO in the discussion).
Static meshes
A static mesh is a polygon mesh; most of the architecture in Unreal Engine is built from them. "Static" means it cannot be animated, but it can be moved and resized in real time without recompiling. Meshes come in any shape and size, flat or 3D.
For complex shapes, static meshes are more convenient and flexible than BSP: a model can have hundreds of triangles, and the engine handles a static mesh more easily than BSP of the same shape.
Static Mesh Browser
Opened from the View tab or a dedicated toolbar button. It is similar to the Texture Browser: you can pick an object, inspect it and apply textures to it. The camera in the browser window works the same as in the editor. The browser works with .usx packages.
Textures are applied on the Materials tab. A model can consist of several parts with their own textures; each part has its own numbered tab, starting from 0.
- Select a texture in the Texture Browser.
- In the Static Mesh Browser open Materials and the tab for the part.
- Click the
Materialfield and press Use.
Some meshes have one part, others fifteen; at first you will have to guess which texture goes where.
To add a mesh to the map:
- right-click the spot in the viewport → Add Static Mesh: 'name';
- or press Insert Static Mesh into Level in the browser: the mesh appears at the camera position of the active 3D viewport.
The Frame Current button aligns the browser view, taking camera rotation into account.
Importing meshes
- In the Static Mesh Browser choose File > Import.
- Pick the file. Supported formats are
aseandlwo;aseis the one mostly used. - Set the package, group and name in the import window.
The mesh is imported without a texture (it gets a NULL material) unless the texture was imported beforehand under its original name. In that case reapply the textures on the Materials tab. After texturing, save both the mesh package and the texture package.
UltraKill suggested in the discussion adding type suffixes to package names: _sm for meshes, _T/Tex for textures, _S/Snd for sounds, _A/Anims for animations (for example Tank_sm and Tank_T). Package names should have no spaces and use Latin letters only.
Converting models from other games
There are many 3D programs; K-2 used MilkShape 3D, which is simple and convenient for basic operations.
- Import the model into MilkShape: File > Import, choosing the format.
- Export it to
ase: File > Export. - Import the
aseinto the editor as described above.
Older MilkShape versions need a plugin for ase export; according to the discussion, MilkShape 3D 1.8.5 Beta already has ASE export built in. Textures are not required in MilkShape: if it complains Error opening following textures and the model is white, that is fine — the point is to get an ASE file and apply textures in the editor.
Scale of S.T.A.L.K.E.R. static meshes. From the "Статические меши из Сталкера" (Static meshes from Stalker) thread on the killingfloor.ru forum: Rainishе criticised a posted static mesh pack for broken proportions. According to him, static meshes from Stalker levels must be scaled up 60.5 times in 3ds Max (not 80 to 1) and given a vertex weld with a 0.0001 parameter.
For exporting models from 3ds Max via ActorX, see the separate article.
Porting whole maps from other games and merging maps
From the killingfloor.ru forum threads "importing in SDK" and "скрещивание карты" (Crossing maps). A map from Quake III, Counter-Strike or Serious Sam cannot be imported into the SDK: the engines work differently, so such maps can only be recreated, extracting and converting their textures and objects. Only maps from Unreal Engine 2 games carry over whole (from Unreal Engine 1 and 3, with distortions). According to K-2, a stable port of a UE2 map needs:
- the original game's editor (Unreal Editor version 3.0 or later);
- all resource packages moved into the KF folder (resources "embedded" in myLevel need extra steps);
- copying all objects of the map in the original editor and pasting them into KF SDK: only classes that exist in KF get pasted, and their properties stay as in the original;
- adaptation to the specifics of the particular map.
Two maps are merged into one the same way: a piece of one map is copied and pasted into the other. Gaiver5 and krestps warned that paths and movers will almost certainly need fixing afterwards.
Converting brushes to static meshes and back
- A solid brush becomes a mesh: right-click its outline → Convert > To Static Mesh. A window like the import window appears. Faces are split into triangles; applied textures and the current Pivot are kept.
- Converting a group of brushes at once merges them into one object. You can likewise convert a group of static meshes again to merge them into one (for example, a stack of books or a pile of crates).
- A static mesh can be turned back into a builder brush: Convert > To Brush.
- Movers cannot be converted, only their "sources". Conversion errors (for example
Assertion failed: StaticMeshActor) are fairly common, and there is no cure for them. To move an object to another map with all its properties, simply copy (Ctrl+C) and paste (Ctrl+V) it: everything is kept in the clipboard, so you can paste even after restarting the editor (K-2's answer in the "Вопросы, вопросы и еще раз вопросы." (Questions, questions and more questions) thread).
Moving a mesh into MyLevel
A method by UltraKill from the discussion: the mesh is stored inside the map file, so no separate package has to go into the map archive.
- Select the mesh in the Static Mesh Browser.
- Edit > Rename…, enter
MyLevelas the package, anything you like for the rest. - Check that the mesh appears in the
MyLevelpackage and save the map. - Restart the editor and open the map: the mesh is there.
Objects from another map's MyLevel can be moved by copying: open that map, select the objects, Ctrl+C, open your map and Ctrl+V. If you use meshes from your own separate package instead, that package and its textures have to be distributed with the map.
Mesh properties in the map
The main properties of a placed mesh, Display group. If unsure, better leave the defaults alone.
| Property | Meaning |
|---|---|
AmbientGlow | Static glow: makes the object brighter without other light sources |
bAcceptsProjectors | Whether blood splats etc. stay on the object |
bAlwaysFaceCamera | Flat objects only: if True, the front side always faces the player's camera (sometimes used for tree foliage) |
bShadowCast | Whether the model casts shadows. Quite an important setting |
bUnlit | If True, the model is fully lit regardless of light sources |
CullDistance | Draw distance in UU: beyond it the object is hidden. 0 means unlimited |
DrawScale | Model size, keeping proportions |
DrawScale3D | Size along X, Y and Z separately (relative to DrawScale). Negative values mirror the model. You can also scale quickly with the DrawScale3D field on the bottom toolbar |
ForcedVisibilityZoneTag | Tag of the zone where the object is forced visible; it is hidden in other zones |
Skins | A skin texture that replaces the one set in the mesh browser without changing the mesh itself (also used to add coronas to light sources) |
StaticMesh | Current mesh and its path (package, group, name) |
Collision settings:
| Property | Meaning |
|---|---|
bAutoAlignToTerrain | Snaps the position to the terrain; very handy |
bBlockActors, bBlockKarma | Do not mean much: collision is governed by the two settings below |
bBlockNonZeroExtentTraces | Whether to block non-zero-extent traces: players, zeds, thrown items |
bBlockZeroExtentTraces | Whether to block zero-extent traces: bullets, grenades, etc. |
bCollideActors | Whether the object interacts with its surroundings. If False, none of the bBlock settings apply |
bPathColliding | Whether the object blocks AI path building on compile |
bUseCylinderCollision | Cylinder collision (better left False) |
CollisionHeight, CollisionRadius | Height and radius of the cylinder collision |
SurfaceType | Surface type. Irrelevant: it is set by the applied texture |
Mesh collision and lighting
Clarifications by K-2 from the discussion (2015):
- Complex models usually get an invisible simplified collision model, so players do not snag on small bumps and the computer has an easier time with collisions. Without one, and always for zero-extent traces (bullets, grenades), the original polygon model is used for hit checks.
- In UE2, static meshes are not lit with lightmaps like BSP but per vertex (Vertex Lit). Without a very dense mesh they cannot get realistic shadows; this shows most on low-poly or heavily scaled objects as uneven shading across neighbouring triangles, or black areas near vertices covered by other geometry. Terrain has the same problem. Where shadows on objects matter, a projector with a pre-made texture is usually added.
- Complex BSP shapes of a couple of thousand polygons run many times slower than static meshes and often cause "black holes" due to BSP tree problems. Epic Games built "Lego-like" mesh sets: wall, floor and ceiling sections with fixed sizes in multiples that join almost seamlessly.