Chapter XI. Glass.

Glass surfaces: standard breakable glass, one-way glass, and a breakable one-way glass variant.

11.1

Breakable and Unbreakable Glass

In this article we will look at the creation of breakable and unbreakable glass. Before reading the article, familiarize yourself with the following entity objects:

1. Breakable glass

There's nothing easier than creating glass :) Here's how to create breakable glass:
Create a glass-shaped brush of any size (optimal thickness 2-4 units). Standard textures with the word are well suited for painting GLASS such as: GLASSBRIGHT, GLASSBLUE1, GLASSGREEN. We will use the latter, GLASSGREEN. In fact, almost any texture can be used for glass (except for special ones and water, of course), because... the object will still be transparent, but textures with the word GLASS will work better.
In the picture below you can see three glasses made from different entities with different properties: the left one is breakable, the center and right are unbreakable.
Three ways to create glass
So, you have created a brush, now turn it into func_breakable and set the following properties:
Strength — 30 ​​(glass strength. The higher the value, the more bullets you need to shoot at the glass for it to break);
Material Type — Glass (material, of course, we choose glass);
Render Mode — Texture (this mode makes the object transparent, you can also use Additive);
FX Amount — 40 (degree of transparency. The closer the value is to 0, the more transparent the glass and vice versa, the closer to 255, the more opaque. With fx amount = 0 the glass will be completely invisible)
Breakable glass is ready! We said that it is very simple.
For breakable glass (object func_breakable) you can additionally set the following flags:
Only Trigger — if checked, then the glass will break only from a trigger (the glass, i.e. the func_breakable object must be given a name and activated by a trigger for it to break);
Touch — if checked, the glass will break when touched by the player;
Pressure - if checked, the glass will break due to pressure (the player stood on the glass). Can, for example, be used to create breaking ice;
Instant Crowbar - instant destruction from the mount (used in HL)

2. Unbreakable glass

Safety glass can be made in three ways:
a) use func_breakable
Material Type — Unbreakable Glass (material: unbreakable glass);
Render Mode — Texture;
FX Amount — 40
b) use func_breakable and the Only Trigger flag
Material Type — Glass;
Render Mode — Texture;
FX Amount — 40
Flags:
Only Trigger — if this flag is set, the player will not be able to break the glass (neither with a knife nor with a weapon)
c) use func_wall
With func_wall it's even easier, because You only need to set the display parameters.
Render Mode — Texture or Additive;
FX Amount — 40 (degree of transparency. Values ​​from 0 to 255)
And this is what the glass looks like in the game. As you can see, there are no visual differences between breakable and unbreakable glass.
This is what glass looks like in the game (Render Mode: texture; FX Amount: 40)
As you can see, there are many options. Which one should I use? Yes, anyone. Although func_wall has fewer properties to set.
glass.zip [13Kb] - in the archive there is an example map in BSP and RMF formats.
11.2

One-Way Glass (Non-Breakable)

In this article we will tell you how to create glass that is transparent on one side and opaque on the other. As a result, we will get the following:
Glass is transparent on one side and opaque on the other
In the picture you see two glasses. They are made using a similar technology, however, the left one can be broken, but the right one cannot (you can read about breaking one-way glass in the next article of the Tutorial). In the meantime, let's start making unbreakable glass.
It's quite simple. Let's create a brush in the right place - the future glass - and paint it on one side with a texture GLASSGREEN (or any other suitable for glass), and on the opposite side - texture {BLUE (see picture below).
Texture GLASSGREEN on one side and {BLUE on the opposite
Now let's turn this brush into func_wall and set the following properties (surprise, surprise :)
Render Mode — Solid;
FX Amount — 255
Do these properties remind you of anything? That's right, these are the properties we set for all transparent gratings, fences, stairs and other similar objects with blue parts. After all, the blue parts in the game will be transparent. This means that the side of the glass with texture {BLUE will be absolutely transparent, and the opposite one, which has a texture GLASSGREEN - completely opaque (with the same properties).
So, half the battle is done. Why only half the battle? Here's why. Agree that it will be quite strange to see opaque glass on one side and not see anything on the other (after all, the blue part will be completely transparent, as if there was no glass there). Bad.
And this problem can be solved very simply. It is necessary to create ordinary glass func_wall (exactly the same dimensions as the first one), paint it over with texture this time on all sides GLASSGREEN and set the following properties:
Render Mode — Texture;
FX Amount — 70 (this is the transparency of the glass, values ​​from 0 to 255)
Place the second func_wall glass with the GLASSGREEN texture close to the first glass with the {BLUE) texture
We place the second glass close to the first, to the side that is painted with texture {BLUE. Now the player will look through this second glass, which has a transparency of 70, and will perfectly see everything that is behind it (in our case, the hostage, see the very first picture). Approaching the glass from the other side, the player will not see anything. The trick works!
If it is still not clear how exactly to place the second glass, here is a picture with a top view. Two purple rectangles are our two glasses.
t11glass7 Well, in what places to use such glass is up to you. You can place it in a place where you need to give one of the teams the opportunity to camp, for example, terrorists defending a room with hostages, etc.
In our next article we will tell you how to do exactly the same trick, but only with breaking glass. Yes, of course, we will use instead func_wallfunc_breakable, but that's not all. There is also a little trick.
oneway_glass.zip [15Kb] - in the archive there is an example map in BSP and RMF formats.
11.3

One-Way Glass (Breakable)

In this article we will continue our experiments with one-way glass and make it breakable. If you have thoroughly mastered the material in the previous article and understood how the one-way glass trick works, then you will not have any problems.
So, we already have one-way glass. Now let's make it breakable. To do this, the first glass, one side of which is painted with texture {BLUE, let's turn from func_wall V func_breakable (select it in 3D view, press Alt-Enter and select func_breakable from the list).
Now let's set the properties:
Name — glass1 (glass name, please specify);
Material type — Glass;
Strenght — 50 (in this case, the strength of the glass is not important, more on that later);
Render Mode — Solid;
FX Amount — 255
As you can see, the display parameters are the same. Now select the second glass, which is completely painted with texture GLASSGREEN. We also turn into func_breakable and set the following properties:
Name — glass1 (necessarily the same name as the first glass);
Material type — Glass;
Strenght — 50 (strength);
Render Mode — Texture;
FX Amount — 70 (transparency from 0 to 255, the closer to 0, the more transparent the glass)
It would seem that's it – start the game and break the glass. But it's not that simple. We have two glasses, therefore, we need to break 2 glasses, but the player is fully confident that there is only one glass. Having broken one of the glasses, the player will be surprised to find the second and realize that he was cruelly deceived :)
Our task is not only to deceive the player, but also to prevent him from noticing the deception :) This is precisely why it is necessary for both glasses to break at the same time when the player breaks only one of them.
Let's move on to implementing this idea. Look at the picture below.
t11glass8 The dotted line indicates a new object that we will now create. This too func_breakable . The dimensions of this object are exactly the same as those of the glass, only slightly wider in thickness (wider than both glasses combined).
Let's paint all sides func_breakable texture {BLUE. In the figure below, this object is shown in 3D view (the glass is not visible, because the new object should be a little thicker, i.e., both glasses are inside this object).
Create a func_breakable, painted on all sides with the texture {BLUE
Properties func_breakable the following:
Target on break — glass1 (enter the name of the two glasses here, it is the same);
Material type — Glass;
Strenght — 1 (strength*);
Render Mode — Solid;
FX Amount — 255
That's all. Now, in fact, the player will not break glass at all, but our new absolutely transparent object func_breakable. And he, in turn, will instantly break both glasses at once. The player is deceived, the windows are broken, the trick works, you can drink beer :)
* The desired glass strength must be set in the parameter Strenght exactly a new object func_breakable. It is clear that the player will not shoot at the glass, but at this invisible object, so the strength of the glass itself is not taken into account.
As singer Valeria said in one advertisement several years ago: "the result is obvious":
The left glass from func_wall is unbreakable, the right glass from func_breakable is breakable
That's all. We sorted out the glass.
oneway_glass.zip [15Kb] - in the archive there is an example map in BSP and RMF formats.