Caulk

From The DarkMod Wiki
Jump to navigationJump to search

Introduction

"Caulk" is an old word, in verb form meaning "to make a ship or building watertight by filling the seams between planks with oakum or other material driven snug". A ship not properly caulked could leak, slow down, and sink. Reputedly, this inspired id co-founder John Carmack to chose the name "caulk" for a substance to seal internal and external leaks. The original purposes of caulk in Doom were likely to help avoid game slow-downs, and to close off any accidental tiny leaks by plastering the whole outside with it. From The Origins of Caulk

In TDM, the noun "caulk" can be used in two senses:

  1. as a texture, which appears pink/magenta in DR, but is not drawn in-game. Like other textures, it can be applied to the faces of brushes (worldspawns), func_statics, and so on.
  2. as a worldspawn brush with the caulk texture applied to one or typically all surfaces.

Main Use of Caulk - for Vis Leafs

It is the second meaning in which caulk is actually most useful: for defining and sealing, in conjunction with visportals, individual vis leaf areas of your map. This often takes the form of thin caulk-brush sheets sandwiched between non-brush opaque interior walls. Creating vis leafs is important to avoid unnecessary, performance-sucking rendering, and to provide more-plausible sound propagation. For more about this, see Visportals and Sound Propagation: Part 1.

Other transparent "no draw" textures on brushes do not have the sealing property that caulk has.

Another Important Use - Caulk Sky

To create a sky, the external, void-facing brushes have two choices for texture:

  • sky_portal
  • caulk

When using caulk sky, besides the caulk brushes themselves, you must have at least one surface anywhere in the rendered area using the sky_portal texture. For example, in Figure 1 (from a 2013 example by Obsttorte), [FIGURE 1 to do] this is done using a out-of-the-way sky_portal-textured cube brush. The engine will never render anything on the caulk brush surfaces themselves; they are merely views into the void, and the engine uses the sky_portal texture sample to "fill in" those views.

Figure 1 shows a simple "pit" scene in DR (top) and in-game (bottom).

There are two main reasons traditionally why caulk sky was useful in TDM.

Non-Clipping of Objects that Extend Into the Void

Consider a map object that pierces an external brush of your map. Assume that (in order to compile without leak) its origin is within the rendered volume, either naturally or by adjustment. If the external brush has portal_sky on its interior, the map object (prior to TDM 2.05) will be clipped there. Sometimes, that's not what you want.

While caulk does not render, it does cuts into other textures, but only if they are worldspawn. If you've converted them into func_statics, they will be rendered completely and not be cut off at the caulk surface. To ensure this happens, the func_static must reaching into the rendered area a bit. In Figure 1, the roof eaves on either side are part of larger roof wedges that the player can see when jumping up. They are func_statics that extend into the void, but with origins in the pit. (If the game had multiple vis leafs from which to view the func_statics, they would appear unclipped from all.)

For more, see [this forum post].

However, since TDM 2.05, the default behavior of portal_sky regarding clipping is now similar to caulk.

Atmospheric Fog

Dealing with fog effects is often tricky, particularly at the boundary of fog volume and sky. Portal_sky versus caulk sky can differ. Some starting points:

  • A Fog Light with spawnarg "noFogBoundary" lets fog paint on solid surfaces, while leaving empty space and caulk sky free of fog effects.
  • There is a variant of Fog Light called No Portal Fog, which will not apply opaque fog to Portal areas in view.

For more, see Fog Light and Simulating Atmospheric Perspective.

Other, Secondary Uses of Caulk

Other potential uses, of caulk as a texture, follow.

As a DR Mapper Convenience

Figure 2. Benefits of caulking as a mapping tool.

Some mappers like to caulk the exterior (void-facing) surfaces of their maps. While unnecessary for game play (since the engine ignores those surfaces automatically), it benefits editing. By using the DR Caulk filter, the mapper can easily switch off the exterior surfaces and see inside the map to get a better vantage point. Image 2 shows how the mapping works:

  • (top) for a mapper who does not caulk the exterior. It is difficult to get a good overhead view of the work, and the mapper has to either hide the exterior brushes or fly inside the map.
  • (middle) for a mapper who does caulk the exterior, when the caulk filter is not active.
  • (bottom) when the caulk filter is activated. The mapper has a superior overhead view into the work.

Be aware that similar result can be achieved by the non-caulk-user by:

  • using DR Layers.
  • with any brush used as a Portal Sky, keeping that texture on all faces, and adding a custom DR "Portal Sky" filter

For more about sealing areas of your map against the void, see Performance: Essential Must-Knows.

Avoid Drawing Unseeable Polygons

Caulk can be used to skip drawing of:

Figure 3. Caulk applied to a func_static window.
  • back-surface polygons (tris) of a prop object, such as a door or window as in Figure 3. There, surfaces touching the wall are caulked, so are not drawn in game, saving tris. Testing (detailed further below) shows that such caulking is not worth the effort, unless you plan massive cloning of that prop object.
  • worldspawn brush surfaces entirely covered by detail work like patches.
    Figure 4. Caulk applied to a unseeable worldspawn brush surface.
    See Figure 4. The player can never see the caulked surface because it's hidden by the func_static vault. This not only saves tris (which is not really important), but also removes the "sparkling" of the other texture at the highest point of the vault.

Avoiding Z-Fighting

As just seen with the vault in Figure 4, caulking helps in certain circumstances. To reiterate, the caulked worldspawn surface does not "sparkle" or z-fight through the highest point of the vault, where the vault patch and the worldspawn brush are at equal height.

Caulking of Hidden Surfaces to Improve Performance? - Discussion, Testing, and Analysis

Introduction

Every now and then, caulking arises in debates: is it useful and beneficial to performance to spend a lot of time object-caulking? And if so, how much caulk is required to get a solid impact on fps rate?

As Image 1 indicated, to save a few polygons (tris), one can apply caulk on surfaces the player can never see in any circumstances, like wall-facing surfaces of prop windows and doors. This reduces the number of tris, and thus could potentially improve performance in some cases. But what does testing reveal?

Caulking That Cannot Affect Performance

There is no performance advantage to using caulk on any of these surfaces:

  • worldspawn surfaces on the outside of the map in contact with the void
  • worldspawn surfaces that are flush against another surface, for instance the bottom of a brush aligned with the floor.

The game engine removes these surfaces automatically, so caulk texture is not needed.

Testing and Estimating the Effect of Caulking on Performance

Tests performed in 2010 by Sotha gave the following results.

Caulking a medium complex scene with tens of windows and other objects (Knighton Manor start) did NOT have any effect on fps counts. Caulking did save roughly 1000 tris, but this is not sufficient to cause any fps improvement. The main benefit of caulking was the decrease of memory usage: 1000 saved tris saved 0.6MB of memory.

Testing indicated that on a rather high-end computer (for 2010) an increase of 23000 tris, 75 draws and 2500 shdw reduced the fps count by two. If a window consists of 5 brushes and the wall facing surfaces are caulked, this saves 5 surfaces and thus 10 tris per window. This would mean that 2300 windows should be caulked to get an improvement of 2fps. Basically this shows that caulking does not have much impact on modern hardware. However, on an older piece of hardware the amount of caulking needed for performance effect is lower, but even in this case it should be remembered that 1000 tris is roughly 20% of a single AI character.

How Should Caulk be Used? Perhaps Before Massive Cloning

Mappers may selectively integrate object-caulking in their ongoing work flow. Suppose the mapper builds a func_static window to be cloned and put everywhere. It is beneficial to use a few seconds to apply caulk on the source func_static and then get the caulking tris-saving effect on all the clones. This adds little work for the mapper, but, in a medium sized scene where the windows and other cloned (but caulked) objects are omnipresent, might easily save the a few thousand tris.

Conclusion

Mappers should not generally take extra trouble to caulk their individual objects, since solid performance increases do not occur with the levels of tris so saved. However, thousands of tris can be saved by simple workflow consideration, when working with objects which are cloned in large numbers.