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: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Language subpage}}
{{LanguageBar}}
{{Source topicon}} {{CSS topicon}}
[[Category:Level Design]]
 
[[File:exemple_vraie_reflet.jpg|thumb|right|300px|Real-time Reflections in CS:S]]
[[File:exemple_vraie_reflet.jpg|thumb|right|300px|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.
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 {{src07|4}}, because has an entity for real-time reflections which can be applied to a wall: {{ent|func_reflective_glass}}, which uses the {{shader|LightmappedReflective}} shader.
This technique is mostly useless since {{src07|4}}, because it has an entity for real-time reflections which can be applied to a wall: {{ent|func_reflective_glass}}, which uses the '''[[LightmappedReflective]]''' shader. However, this technique is still useful on {{bms|1}} as "LightmappedReflective" no longer works after the game uses deferred renderer in later updates.


== How it Works ==
{{Bug|Looking at the reflections while having {{code|[[func_precipitation]]}} on the map will cause the rain, snow or ash effect to be rotated.|hidetested=1}}
 
==How it Works==
[[File:triple_material.jpg|thumb|right|300px|The three materials:]]
[[File:triple_material.jpg|thumb|right|300px|The three materials:]]


Line 15: Line 20:
* Something to overlay the water material (without this, it will not work properly).
* Something to overlay the water material (without this, it will not work properly).


=== Material for the Surface ===
===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.
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.


Line 26: Line 31:
  }
  }


=== Water ===
===Water===
 
  Water
  Water
  {
  {
Line 42: Line 46:
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.
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 ===
===Covering the Material===
It's pretty important to cover this material, but it doesn't matter how you do it.
It's pretty important to cover this material, but it doesn't matter how you do it.


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


== Translation Notes ==
==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.
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.

Latest revision as of 23:46, 9 September 2024

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.