Skip to content
Dev Archive

The Dam - Just for 2 weeks, let’s all do the bump

by Angry Beaver

Archived from the original dev blog and left as it was written, so it reflects the game as it stood in 2008.

Man MC Hammer references will never get old. I missed last week’s article for no other reason than Personal Issues. This week, I’m going to be talking about displacements and how to use them, rather than post a rather monolithic blog it’s going to be split up into 2 parts, this is the first one and lays down a lot of the basics I’m going to assume people understand in the second blog so forgive me if it is a little basic.

The first big question regarding displacements is why you should bother. The main design for displacements was for use in Terrain, back in the old GoldSource days terrain was achieved by making a huge batch of triangular prisms and then vertex editing them into shape, yeah no really you young punks have it easy *shakes fist*. Displacements took the process and turned it into a much easier and better process, now one face can hold all that information and more. Because of this design their also useful for creating destroyed surfaces, uneven concrete/paving, and even for creating curved surfaces like a rounded edge. I recommend only using displacements when you have an uneven surface or a complex curve, using them for simple effects like cylinders and rounded edges is a waste (as many forum arguments have debated) as a lot more polys are used to make the displacement than would be needed by a cylinder primitive, which is one of several things that should be noted about displacements.

The first major thing of note is that a displacement always has to have 4 sides, the reason they have the quadrilateral is because the engine forms smaller quadrilaterals inside based upon first the power of the displacement and second the angles of the edges. With more or less sides the program would not be able to devise a neat and intelligent algorithm without a lot more program for honestly, very little gain, as many modelers know with the right touch and a sideways logic you can make nearly anything out of 4 sided shapes alone. The power affects how dense they are and the gain is exponential, a power of 2 gets 32 polys, 3 gets 128, and 4 gives 512. Powers should be used carefully but I’ll talk about that more next week Source has a way of handling all these polys known as “batch processing” to keep it cheap at even power 4.

Batch processing is what keeps displacements cheap, when several polys are on the same face, like a displacement, source will render them all in one batch instead of one by one. This cuts down the number of times the render needs to be initialized making the process go much faster. Batch processing isn’t use for every polygon at once because a few assumptions are made that could not be made about every polygon in a level, well that is unless your level sucks but I digress These assumptions are just one of the tricks used on displacements.

Another trick used on displacements is their lighting; the lighting is automatically smoothed between displacement faces that share an edge. When displacements are made incorrectly it can cause shadowing and other effects to appear in the wrong place on the surface. The lighting density on a displacement is also affected by how it’s made the surfaces with a low power and large surface area cannot handle small light map values. In fact you may find Hammer adjusting the light map value for you sometimes because of this much to my early frustration before I understood what was going on. Displacements use their vertices to extrapolate some of the lighting creating smoother lighting from a higher light map grid. This can be both an asset and a problem depending upon the situation.

The vertices on displacements can also be used to blend between two textures in a special blend material, displacement surfaces are the only faces capable of doing this blending so they may often be used just for the blending of textures though it’s often a waste a polys, time and effort when a few seconds in photoshop can do it for you. Textures on displacements are mapped onto the face on a per vertex basis. This means that parts of the texture will follow the vertex which means as you move vertices close/further apart the texture will get stretched smaller/bigger respectively. This stretching is often the main contributor to poor looking displacements.

Last but not least is a quick reminder that displacements don’t seal void so you will need walls behind them, techniques for that will be next week. So I know this weeks been a little bit of a dry Wall ‘O’ Text but that’s cause I’ve had to save most of the good stuff till next week. So till then my apologies and a reminder not to dismiss this info as it will be expected to be understood next week.