This article relates to the game "Counter-Strike: Source". Click here for more information.
This article's documentation is for anything that uses the Source engine. Click here for more information.

True reflections under CSS

From Valve Developer Community
Jump to navigation Jump to search
English (en)Français (fr)Translate (Translate)

Real-time Reflections in CS:S

Using the Source engine, the only way to get real-time reflections is to use the "water" shader (typically used for water textures). Typically, reflections are made possible by cubemaps, which are low-quality and pre-calculated but sufficient for most materials. Cubemaps are not useful for a mirror which requires a real-time reflection. There is a trick, however, that makes it possible to use real-time reflections in a custom material. this technique consists in superimposing (overlaying) 2 shaders: A normal transparent shader and a water shader (for reflections only). This technique is ideal for a floor, but unfortunately cannot be applied to a wall due to an engine limitation with the water shader. The water shader reflects everything in the world except for the player.

This technique is mostly useless since Source 2007 Source 2007, because it has an entity for real-time reflections which can be applied to a wall: func_reflective_glass, which uses the LightmappedReflective shader. However, this technique is still useful on Black Mesa as "LightmappedReflective" no longer works after the game uses deferred renderer in later updates.

Icon-Bug.pngBug:Looking at the reflections while having func_precipitation on the map will cause the rain, snow or ash effect to be rotated.

How it Works

The three materials:

You need to use 3 layers of materials:

  • Normal material (in alpha) on the surface where players will walk. Optional.
  • A material with the Water shader which will show reflections in real time.
  • Something to overlay the water material (without this, it will not work properly).

Material for the Surface

Create a brush that is 1 hammer unit thick and apply the material to it with alpha. It is important to leave a gap of any width between this material and the water, or the alpha will not work and you will have a kind of blurry effect.

Example :

LightmappedGeneric
{
         $alpha 0.6
         $basetexture ...
}

Water

Water
{
          %compilewater 1
          $reflecttexture _rt_WaterReflection
          $reflectamount 0.1  // The lower the value, the more reflections you will have.
          $reflecttint "[1 1 1]"
          $normalmap ....  // Indicate a texture of solid colors, such as a solid white texture.
          $fogenable 0
          $fogcolor "[1 1 1]"
          %compilepassbullets 1  
}

The parameter "%compilepassbullets" 1 will make the material unresponsive to external effects, balls and players who step on it will have no effect on it. This setting is essential for CSS, because the balls go through the Blocks, every time you shoot on the ground you will have a SPLASH, which is not realistic. You can also, thanks to this compilation parameter, run on this surface, as on a mirror.

Covering the Material

It's pretty important to cover this material, but it doesn't matter how you do it.

Tutorial

http://www.interlopers.net/tutorials/19882

Translation Notes

I'm going to follow this tutorial to learn how it works, and then rewrite the page in a way that English readers can understand.