Caulk: Difference between revisions
Line 22: | Line 22: | ||
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. | 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 | While caulk does not render, it does cut 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 at the pit lips 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's vis leaf. (If the game had multiple vis leafs from which to view the func_statics, they would appear unclipped from all.) | ||
To summarize, caulk is transparent, and in-effect shows the portal_sky through it, as well as any func_statics that pierce it into your vis leaf. That means you can cut a func_static house in half with a caulk brush, and still see both sides of it. Using portal_sky, this was not possible until recently. However, since TDM 2.05, the default behavior of portal_sky regarding clipping is now similar to caulk. | To summarize, caulk is transparent, and in-effect shows the portal_sky through it, as well as any func_statics that pierce it into your vis leaf. That means you can cut a func_static house in half with a caulk brush, and still see both sides of it. Using portal_sky, this was not possible until recently. However, since TDM 2.05, the default behavior of portal_sky regarding clipping is now similar to caulk. |
Revision as of 16:57, 23 October 2021
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:
- as a texture (found in textures/common/caulk), that 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.
- as a worldspawn brush with the caulk texture applied to one or typically all surfaces.
Main Use of Caulk - for Separating 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
While most any opaque worldspawn brush can be used to seal against the void (as discussed in Performance: Essential Must-Knows and other places), to specifically create a sky, the external, void-facing brushes have two choices for texture:
- portal_sky (found in textures/smf/portal_sky)
- caulk
For a caulk sky, besides the caulk brushes themselves, you must have at least one surface anywhere in the rendered area with the portal_sky texture. For example, in Figure 1 (from a 2013 example by Obsttorte), this is done using an out-of-the-way portal_sky-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 portal_sky texture sample to "fill in" those views. Figure 1b shows the same "pit" scene, but in-game, at a different angle.
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 cut 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 at the pit lips 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's vis leaf. (If the game had multiple vis leafs from which to view the func_statics, they would appear unclipped from all.)
To summarize, caulk is transparent, and in-effect shows the portal_sky through it, as well as any func_statics that pierce it into your vis leaf. That means you can cut a func_static house in half with a caulk brush, and still see both sides of it. Using portal_sky, this was not possible until recently. However, since TDM 2.05, the default behavior of portal_sky regarding clipping is now similar to caulk.
For more, see this forum post and this bug tracker entry about portal sky modes.
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.
- For more, see Fog Light and Simulating Atmospheric Perspective.
Other, Secondary Uses of Caulk as a Texture
As a DR Mapper Convenience
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 the view:
- (top) if you don't caulk the exterior (and just leave it as a stone texture). It is difficult to get a good overhead view of the work. Unless you set up caulking (or one of the alternative methods), you have to either select and hide the exterior brushes or fly inside the map.
- (middle) if you do caulk the exterior, when the caulk filter is not active.
- (bottom) with the caulk filter activated, for a superior overhead view into the work.
Alternative non-caulk methods to do this include:
- using DR Layers. Move all the exterior brushes into their own Layer, and hide that layer.
- with any brush used as a Portal Sky, keeping that texture on all faces, and adding a custom DR "Portal Sky" filter
To Avoid Drawing Unseeable Polygons
Caulk can be used to skip drawing of:
- 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. 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 Figure 3 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 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.