Fr/Cubemaps
Cubemaps - Kesako?
Dans la réalité les matériaux reflette l'environnement autour. Réaliser ceci dans un moteur 3D en temps réel, demande beaucoup de ressources. Une technique à été développée pour simuler les reflets sans demandé trop de ressources matérielles : les cubemaps. Il s'agit de projeter sur un objet une texture et de calculer sa position par rapport au joueur. Cette texture d'environnement est calculée, puis plaquée sur les objets avec du reflet. Il en résulte des faux reflets, non en temps réel, qui on l'avantage de demander peu de ressource, mais l'inconvenient d'une qualité moindre et de ne pas refleter les joueurs en temps réelles. Cette technique est applicable dans le secteur du jeux video avec les moteur en temps réelle, mais aussi dans le milieu de l'animation avec par exemple 3DS max lors des rendus.
Beaucoup de matériaux spéculaire et d'environement font appell à des données externe pour calculer leur apparence. Ces données prennent la forme d'un "cubemap", une texture
qui represnte une arène de 360°.En utilisant le cubmap en un point de prélevement, les matériaux seront en mesure de rstituer plus fidèlement leur environement. Définir des cubemaps et leur position dans l'espace est facile, mais il est important de bien les placer pour des raison d'esthetiques et de performances.
Placement
Pour définir la position d'un cubemap dans l'espace dans une map, nous utilisons l'entité env_cubemap. Qhand la map est compilé avecVBSP, les surface de la geometrie de la map sont automatiquement associer au cubemap le plus proches.
Il est important de noter que les cubemaps peuvent avoir de multiples usages qui dependent de leur placement au sein de la map. Certains cubemap sont placé pour les reflection de la geometrie du monde statique. D'autre sont placer pour les reflections des entités commme les NPC ou le joueur. Le placement de ces cubemap dois suivre quelque règles simples suivant leur utilité pour avoir une qualité graphique optimal.
- If a cubemap is intended for NPCs or the player, it should be placed 64 units above the ground so that it most accurately represents the world at that point in space for a standing creature.
- Si le cubemap est destiné à la geometrie static du monde, il doit être palcé à au moins 16 unité de toutes les surface du monde.
- Les cubemap doivent être placer dans toutes les arène avec un contraste visuelle differents. Un couloir avec une lumière jaune vif aura besoin d'un cubemap, surtout si cette pièce est à coter d'une pièce avec une faible lumière bleue.
Building
Once a map has been compiled and lit by VBSP and VRAD (respectively), the cubemaps can be built. Run the map and allow the any node graphs or other pre-process activities to finish. Then use the buildcubemaps
console command to begin building the cubemaps for the level. In the upper left-hand corner of the screen you’ll be able to see each facet of the cubemap (six per cubemap) render. Depending on your video card, driver and complexity of your scenes, this can take seconds or minutes to complete. Once finished, the map must be restarted for the cubemaps to properly be applied to all surfaces.



sv_cheats 1
) before running the buildcubemaps
command.Cubemaps and HDR
If the map has been compiled with the HDR lighting option enabled in VRAD, cubemaps must be built in both HDR and LDR (non-HDR) modes. Building cubemaps in only one mode will mean that cubemaps will not be present the other mode. For information on how to build cubemaps under HDR, see HDR Lighting Basics.
Cubemaps should be built for LDR and HDR maps. Presuming you are already in HDR mode and have your map loaded fresh from compilation (VRAD must have the '-both
' parameter enabled). Go to the console and execute the following commands:
buildcubemaps mat_hdr_level 0 (to go to LDR) map mapname (to reload map) buildcubemaps mat_hdr_level 2 (to go back to HDR) map mapname (to reload map)
Testing
Cubemaps are best tested by using the impulse 81
console command. This replaces the current weapon model with the "cubemap weapon"; a set of spheres, each with different reflective surfaces. By moving around the level it is possible to see what cubemap is being applied at that position in space at any given time, as well as if that cubemap accurately describes the area’s lighting and color. This is the best way to assess the validity of your cubemaps.
For some reason, Team Fortress 2 does not have the "cubemap weapon". The Sniper's primary weapon, however, has a slightly reflective lens on the scope and the Demoman's Bottle, and thus will reflect the cubemap.
Performance
The env_cubemap
entity allows the user to define how large the target cubemap’s texture resolution is. While a larger texture resolution will provide more accurate and “sharp” results when sampled, it also incurs a cost in texture memory. Most cubemaps should only use the default setting in the env_cubemap
entity for their texture resolution (32x32 pixels for each surface). This is generally acceptable in normal conditions. Some exceptions may be necessary for areas of high reflectivity or detail, such as set-pieces for acting.
Because surfaces must approximate their surroundings via cubemaps, using too many cubemaps in a small area can cause noticeable visual discontinuities when moving around. For areas of high reflectivity, it is generally more correct to place one cubemap in the center of the surface and no more. This avoids seams or popping as the view changes.
To determine the cost of cubemaps in any one area, first look at the World Rendering category using the +showbudget
console command. If this category is registering an unusually high cost, it may be due to using too many cubemaps in an area. A simple solution to check for this scenario is to use Hammer to Hide all the cubemaps in the map, and then compile and run the map again. If the performance is noticeably better, cubemap density or resolution may need to be reduced.
Eventually this can also be checked by turning off cubemaps, by using r_specular 0
to disable it, however this needs confirmation.