Difference between revisions of "Environment Maps"
(Example image) |
(Batch update) |
||
Line 16: | Line 16: | ||
== Placing an [[entity info_envmap|info_envmap]] == | == Placing an [[entity info_envmap|info_envmap]] == | ||
What you'll need to do first is place an info_envmap in the area you want to reflect, you'll will need to specify two keys and values: | What you'll need to do first is place an info_envmap in the area you want to reflect, you'll will need to specify two keys and values: | ||
− | * | + | * {{keyname|env_size}} - the size in pixels of the cubemap images (eg. {{keyvalue|128}}) |
− | * | + | * {{keyname|env_name}} - the path and name of the resulting cubemap images (preferably in the form ''{{keyvalue|mapname/location}}'', for example {{keyvalue|valley/treatment_plant_office}}). |
Once your info_envmap entities are set up, compile your map. | Once your info_envmap entities are set up, compile your map. | ||
− | After it's compiled, load it up, bring down the console and type | + | After it's compiled, load it up, bring down the console and type {{consolecmd|makeenvmaps}}. This will locate all info_envmap entities and make the environment maps. |
− | |||
− | |||
+ | For best results during this stage, make sure you are running the game in 640x480 and a 4:3 aspect ratio ( {{consolecmd|r_aspectratio 0}} ). | ||
== Used with a [[entity light_ambient|light_ambient]] entity == | == Used with a [[entity light_ambient|light_ambient]] entity == | ||
Setting one up with a light_ambient is fairly straight-forward. | Setting one up with a light_ambient is fairly straight-forward. | ||
− | Bring down the console and type | + | Bring down the console and type {{consolecmd|editAmbient}}, this will load the [[Ambient Light Editor]]. |
− | At the bottom of the window it will say '''Env. Cubemap''' with a dialog box and button next to it, click that button and go to the | + | At the bottom of the window it will say '''Env. Cubemap''' with a dialog box and button next to it, click that button and go to the {{filename|/base/env}} folder where your new environment maps are stored. |
Locate the environment map which matches the area you are lighting and click OK. | Locate the environment map which matches the area you are lighting and click OK. | ||
You may need to reload the engine for these changes to take effect. | You may need to reload the engine for these changes to take effect. | ||
− | |||
== Used with an [[entity info_envbound|info_envbound]] entity == | == Used with an [[entity info_envbound|info_envbound]] entity == | ||
Line 43: | Line 41: | ||
With the brush(es) selected, right-click and navigate to ''info_envbound''. | With the brush(es) selected, right-click and navigate to ''info_envbound''. | ||
You'll then need to add one key and value to this entity: | You'll then need to add one key and value to this entity: | ||
− | * | + | * {{keyname|env_name}} - the environment map you want to use (eg. {{keyvalue|env/valley/treatment_plant_office}}). |
Line 49: | Line 47: | ||
'''NOTE:''' Try to avoid having the origin of your ''info_envbound'' inside other brushes, as this will stop it from working. | '''NOTE:''' Try to avoid having the origin of your ''info_envbound'' inside other brushes, as this will stop it from working. | ||
− | |||
== Display environment maps in a [[materials|material]] == | == Display environment maps in a [[materials|material]] == | ||
Line 86: | Line 83: | ||
=== Using a predefined template for reflections === | === Using a predefined template for reflections === | ||
ETQW also has a set of templates for more accurate reflections ("fresnel" effect, so that the reflection gets more pronounced when seen from a wide angle). These are used primarily for windows and glass effects. | ETQW also has a set of templates for more accurate reflections ("fresnel" effect, so that the reflection gets more pronounced when seen from a wide angle). These are used primarily for windows and glass effects. | ||
− | There are several different templates depending on what effect you want, these are fully shown at the top of the | + | There are several different templates depending on what effect you want, these are fully shown at the top of the {{filename|base/materials/window.mtr}} file. |
Here is an example of a material using the ''templates/windowglass_specular'' template. | Here is an example of a material using the ''templates/windowglass_specular'' template. |
Latest revision as of 15:31, 21 November 2007
Environment maps are made up of 6 images that form a cube (also known as cube maps) to create a fake reflection used on windows, scopes, and any other material that uses environment maps.
Contents
Using Environment Maps
First you need to create environment maps that match locations in your level. You can do this by placing info_envmap entities in editWorld.
Once you have created an environment map for your level, there are a few ways you can define areas for it to be used in:
- Use it with a light_ambient entity.
- Use it with an info_envbound entity.
Once these areas are defined, you can set up materials to use the cubemaps as environment reflection images.
Placing an info_envmap
What you'll need to do first is place an info_envmap in the area you want to reflect, you'll will need to specify two keys and values:
- env_size - the size in pixels of the cubemap images (eg. 128)
- env_name - the path and name of the resulting cubemap images (preferably in the form mapname/location, for example valley/treatment_plant_office).
Once your info_envmap entities are set up, compile your map. After it's compiled, load it up, bring down the console and type makeenvmaps. This will locate all info_envmap entities and make the environment maps.
For best results during this stage, make sure you are running the game in 640x480 and a 4:3 aspect ratio ( r_aspectratio 0 ).
Used with a light_ambient entity
Setting one up with a light_ambient is fairly straight-forward. Bring down the console and type editAmbient, this will load the Ambient Light Editor.
At the bottom of the window it will say Env. Cubemap with a dialog box and button next to it, click that button and go to the /base/env folder where your new environment maps are stored. Locate the environment map which matches the area you are lighting and click OK.
You may need to reload the engine for these changes to take effect.
Used with an info_envbound entity
Repeat the process of placing an info_envmap for each new area you want to have a unique environment map.
To add them to areas that don't use portals (like building interiors) that would be too difficult to portal off, you can use an info_envbound brush entity, which means when a player walks into this brush volume it'll switch to the environment map that you specified in the entity.
To do this, you'll need to drag a brush out over the area you want - the area can consist of multiple brushes. With the brush(es) selected, right-click and navigate to info_envbound. You'll then need to add one key and value to this entity:
- env_name - the environment map you want to use (eg. env/valley/treatment_plant_office).
Compile your map. Once it's done, load it up and check out your new environment map inside the info_envbound area.
NOTE: Try to avoid having the origin of your info_envbound inside other brushes, as this will stop it from working.
Display environment maps in a material
You can use environment maps in a material, to make reflective surfaces look more convincing. The game will automatically choose the correct environment map for the location the material is in. For example, if a player with a sniper rifle walks from an outdoor area into a building, you will see the reflection on the scope change to use the building's environment map as they enter the room. This means your materials will always look consistent with the environment that surrounds them.
Here's how to set up an environment map stage in a material:
material models/mapobjects/automobiles/car_reflect { surfacetype "metal" { diffusemap models/mapobjects/automobiles/car03_d.tga specularmap models/mapobjects/automobiles/car03_s.tga bumpmap models/mapobjects/automobiles/car03_local.tga } { maskcolor map makealpha( models/mapobjects/automobiles/car03_s.tga ) } { blend gl_dst_alpha, gl_one maskalpha program sfx/cubemap red Parm0 green Parm1 blue Parm2 } }
You can see above that the material has 3 stages.
- The 1st stage is the standard setup of diffuse, normal and specular maps.
- The 2nd stage is where we define the mask that controls the amount of reflection. In this case we're just using the same image as the model's specular map. If you wanted a 100% reflective material, your image here would be pure white. Pure black means no reflection at all.
- The 3rd stage defines the use of the environment map by program sfx/cubemap. This renderprogram will automatically choose the correct environment map to be drawn on top of your material.
Using a predefined template for reflections
ETQW also has a set of templates for more accurate reflections ("fresnel" effect, so that the reflection gets more pronounced when seen from a wide angle). These are used primarily for windows and glass effects. There are several different templates depending on what effect you want, these are fully shown at the top of the base/materials/window.mtr file.
Here is an example of a material using the templates/windowglass_specular template.
material textures/window/ghosttown_window1_framed { nonsolid noshadows translucent useTemplate templates/windowglass_mask < "textures/window/ghosttown_window1_framed_d.tga", "textures/window/ghosttown_window1_framed_local.tga", "textures/window/ghosttown_window1_framed_mask.tga", 2, 1.0, 0.6 > }
If you use a template like this, it will automatically set up the environment maps in the template. The reflection amount is controlled by the alpha channel of the diffuse texture.