Visibilité



Sans VIS , tout ce qui est dans une carte est dessinée en permanence, indépendamment du fait que le joueur puisse le voir ou non, ce qui réduit les performances du jeu (et sa fréquence d'affichage). Très clairement, la liste de objets à afficher doit être découpée, mais comment ? Cela prendrait beaucoup trop de temps pour déterminer si un objet ou une surface peut être vu plutôt que les générer en premier lieu!
Les moteurs de jeux doivent faire un compromis. GorldSrc et Source utilisent tous deux le format BSP , basé sur l'implémentation Quake de
John Carmack. Cette page explique comme cela fonctionne et comment l'utiliser.
Feuilles
L'espace intérieur (i.e., non occupé par un bloc monde ) d'une carte BSP est divisée en feuilles . La visibilité entre ces volumes 3D est calculée au moment où la carte est compilée, et embarquée dans le fichier BSP pour utilisation par le moteur. Tout comme les blocs , les feuilles sont toujours convexes.
L'image ci-contre à gauche montre comment les feuilles devraient être générées sur un couloir en U (un découpage blanc a été ajouté pour plus de lisibilité). Il n'y a pas de ligne de mire entre les feuilles 1 et 3. Par conséquent lorsque la caméra est dans l'une de ces feuilles, le contenu de l'autre feuille n'est pas généré. Ce calcul très simple consiste à consulter un tableau de visibilité.
Il y a cependant un problème avec la feuille 2. Le contenu des 3 feuilles est généré lorsque la caméra est à l'intérieur de celle-ci, mis à part l'élimination des objets hors champ, même si le mur de gauche bouche complètement la vue. Il existe des outils permettant de surmonter ceci, que nous allons bientôt aborder. Gardez bien à l'esprit que dans beaucoup de situations, résoudre ce problème sera plus couteux que de simplement dessiner la scène de manière moins optimale.
Soyez bien conscient que les displacement s, point s et bloc s (incluant Blocs détail) n'affectent pas les feuilles. Créer un bloc monde NODRAW si cela pose problème: il est assez courant que des displacements soient créés comme des 'skins' détaillés par dessus un bloc de structure, par exemple.




Réduire le temps de compilation VIS
VVIS (ou VIS /HLVIS sur ) permet de calculer la visibilité entre les feuilles (tandis que VBSP (ou QBSP2 /HLBSP les crée). Cela ne devrait prendre que quelques minutes pour ce calcul, y compris sur des cartes de grande envergure. Si ce n'est pas le cas, vous devriez contrôler les points suivants. Même si ce n'est pas le cas, cela reste de bonnes pratiques !
- Utiliser des Blocs détail de la bonne manière.
- Conserver les bloc monde alignés sur la grille le plus possible. Des dimensions en puissance de 2 restent l'idéal.
- Utiliser de simples bloc monde qui n'ont pas été manipulés par d'autres outils, comme du découpage ou manipulation de sommets.
- Placer des func_viscluster(depuis
) sur de vastes zones avec une bonne visibilité. Les feuilles à l'intérieur se verront entre elles.
- Eviter de créer de grandes zones que le joueur ne verra pas, ou n’interagira pas avec dans un premier temps, dans la mesure du raisonnable. Utiliser une Skybox 3D pour réduire la taille du ciel, et créer une structure bloc monde sous les displacement s.
Souvenez-vous que le temps de compilation VIS et les performances en jeu sont deux choses bien différentes. Il est préférable de supporter un long temps de compilation dans la mesure où le raccourcir compromet les performances.
Contrôler les feuilles
Depuis Source 2007 et sous
Hammer++, Hammer possède une fonction permettant de visualiser les feuilles de la carte sur la vue 3D: Map > Load Portal File. Cela permet d'afficher les arêtes sous forme de lignes bleues. C'est un outil fantastique d'apprentissage. Vous pouvez en effet compiler la carte sans VIS ni RAD (puis recharger le fichier portal pour rafraîchir l'affichage), vous observerez les changements très rapidement.
Les utilisateurs de Source 2006 et antérieur devront utiliser l'application glview .

Pour visualiser les feuilles en jeu, il existe une variable de console nommée "mat_leafvis ". mat_leafvis 3
surlignera toutes les feuilles dans la PVS , tandis que mat_leafvis 1
n'affichera les contours de la feuille où la caméra se trouve actuellement. (Cette variable est un cheat )
Vous pouvez aussi inspecter la géométrie en utilisant la variable mat_wireframe . mat_wireframe 1
affichera un rendu de type fil de fer pour savoir comment les polygones sont dessinés dans la PVS . (Cette variable est aussi un cheat )
Conseils
Unfortunately, leaves don't always work out so well as they did in our first example. Consider the alternative layout on the left (in practice things would be configured as per the first image, but put that aside for a moment): in this example the leaves can all see each other, leading to the whole area being drawn at once for no good reason. This is where Hints come in.
A hint is a brush face textured with the special tools\toolshint
material, which slices any leaves it intersects in two (faces of the brush that should not split leaves must be textured with tools\toolsskip
). In our example, we would place a hint where the purple line indicates, so that it slices leaves 1 and 3 to the same shape that they were in our first example.
It isn't possible to merge leaves together, so after hinting there will be three separate leaves on the right-hand side. Thankfully this isn't a huge problem.

Blocs détail
As was mentioned above, leaves are molded around world brushes. But what if you don't want a brush to do that? If you have a brush that can be seen around at all times (e.g., a statue plinth, or a small free-standing wall), there’s no point in creating lots of extra leaves around it.
In these situations you want func_detail. It's an internal entity which makes the compilers ignore the brush when calculating visibility, without otherwise affecting its behaviour. It's not uncommon for large portions of a map's brushes to be detail .
Surfaces Nodraw
If a player cannot see a brush face without cheating or being a spectator, it's a good idea to apply the special toolsnodraw material (Dans ) or NULL texture (Dans
) to it. Nodraw removes the entire face when the map is compiled without affecting visibility, which reduces both rendering time and, since no lightmap needs to be calculated, map file size.
You do not need to apply Nodraw to faces that are touching the void (i.e., outside the map) or to brush faces touching other brush faces tied to the same entity (the world being one big entity of its own). See Brush#In-game .


func_detail
s into one at compile time, so faces of func_detail
s that are flush with each other don't need to be nodrawn, either.(Dans

Areaportals (seulement dans
Source)
In the image to the left all of the leaves can see each other, and this time there is very little that hint brushes can achieve.
In this situation we should create Areaportal s at the mouth of selected openings. These make the engine perform the per-object line of sight testing that Carmack created the BSP/visleaf system to avoid—but with that system behind it, and with the calculations restricted to when the camera looks through the areaportal, performance can be gained if one blocks enough objects from view.
The image has areaportal locations marked over each mouth, but placing all four would likely hinder performance more than help it. Your strategy depends on the relative cost of each area—in most situations, creating the large areaportal to the right and leaving the corridors alone would be best.
(It is possible to use hints to reduce visibility in this situation, but only with a ridiculous number of them at very precise angles, which impacts performance in its own way. If you can't see across a room for hint brushes, then you should be using an areaportal!)



Occluders (seulement dans
Source)
Sometimes you want to block visibility in a way that visleaves simply don't allow: consider a destructible free-standing wall behind which are standing several expensive character models. You don't want to draw the models if they aren't being seen, but without any connected world brushes to work with except the ground you can't do it by separating leaves.
An Occluder is the tool for the job. It's a brush that hides models (not brushes, alas) behind it when enabled, in a similar manner to an areaportal hiding things that aren't behind it. For obvious reasons, it should be entirely contained inside an opaque object.
It is possible, however, to convert some brushes into models with something like Propper . That way, it's possible to hide more models with an occluder. This should be done on detail brushes, which aren't used for cutting visleaves .
Draw Distance
If you are dealing with a large open area without any cover at all then there isn't a lot you can do but remove detail or employ fog to disguise a low draw distance. Configure draw distance with Map > Properties > Far z_clip plane.
Draw distances can also be applied selectively to props, even prop_static, with the Start Fade Dist/Pixels
and End Fade Dist/Pixels
keyvalue s. As the names suggest, these values can represent either distance in units or pixels on-screen as per theScreen Space Fade
KV.

If you enter fade distances on props, it’s a good general rule to have the difference between the two numbers (start and end) be 200. It looks pretty good, and the larger that number is, the longer the model incurs an increased cost to render. Fading models do not go through the fast path and incur additional sorting cost.
func_lod is a special brush entity that can fade out. You can't use any brushes tied to it as any other entity, however!
Sample Maps
sourcesdk_content\hl2\mapsrc\
sdk_func_detail.vmf
sdk_hints.vmf
sdk_occluders.vmf