Xrays

From The DarkMod Wiki
Revision as of 23:13, 18 December 2021 by Dragofer (talk | contribs)
Jump to navigationJump to search

Xrays

Xray screens are flexible mapping tools that allow mappers to achieve a variety of effects related to the appearance and visibility of entities ingame. The effects that are possible with xrays and can be used in any combination are:

  • Changing the model and/or skin of entities seen through the xray screen. The xray version of the entity may either replace or blend with the normal version.
  • Hiding or revealing entities when looking through the xray screen.
  • Rendering entities in front of opaque obstacles.

Unlike in real life, xray screens in TDM don't use an xray light source. All that's needed for the xray feature is an xray screen and appropriate spawnargs on entities that should be affected by the xray feature.

Xray screens may be put on brushes/patches or in GUI overlays.


Spawnargs

The following xray spawnargs exist:

  • model_xray: switch to this model when seen through an xray screen.
  • skin_xray: switch to this skin when seen through an xray screen. 2.10 contains new generic skins "visible" and "invisible" which can be used by the "skin_xray" and "skin" spawnargs to change visibility.
  • xray: set to "1" to simply mark this entity as an xray enabled entity without changing its appearance. Useful if you only want certain xray effects, like rendering in front of other objects.


Materials

You'll need a material for an xray screen. TDM already contains these materials by default, with a warped version of each also being available:

  • textures/darkmod/sfx/xray: Shows xray-enabled entities through opaque obstacles and optionally changes their model and/or skin. Skin changes may be less visible than expected due to blending of normal and xray models.
  • textures/darkmod/sfx/xray_exclusive: Shows xray-enabled entities through opaque obstacles and optionally changes their model and/or skin. Excludes everything else.
  • textures/darkmod/sfx/xray_replacing: Replaces the model and/or skin of xray-enabled entities seen through this material. Doesn't show entities through opaque obstacles.


For GUIs (i.e. xray glasses), the following xray materials are available, with a warped version of each also being available:

  • xray_glasses_overlay_replacing: Replaces the normal model with the xray model. No xray vision through opaque obstacles.
  • xray_glasses_overlay_mixed: Shows both the normal and xray models transparently. No xray vision through opaque obstacles.
  • xray_glasses_overlay_exclusive: Shows xray-enabled entities through solid obstacles, optionally changes their model and/or skin and excludes everything else.

(See Xrays in GUIs for more details)


When working with these materials, it can be helpful to know what the 2 factors are that result in their differing behaviour:

1) xrayRenderMap: This keyword identifies an xray stage in the material. By default it will only show xray enabled entities and otherwise be black ("exclusive"), but you can add the word "inclusive" behind it so it also shows everything else.

2) blend mode: This affects how the xray view is rendered:

  • blend add results in literal xray vision, meaning that xray entities are rendered before everything else since they're just added on top of whatever else the player is seeing. This works best with a default xrayRenderMap ("exclusive"), since an "inclusive" xrayRenderMap would result in everything else being shown twice, at double brightness.
  • blend blend means that the xray view replaces the normal view, swapping an entity's normal appearance for its xray appearance and (if exclusive) replacing everything else with blackness.
  • For GUIs, special blend modes are used in the default materials to allow the xray effect to only occur on parts of the screen. If you want your xray GUI to affect the whole screen you may use a regular blend mode as above.


Xray demo map

You may download a small test FM demonstrating the xray feature from here. It consists of a small room with various xray-enabled entities, and you start looking through a wooden frame containing an xray screen. You'll also find a pair of equippable xray glasses on the table. See below for some screenshots from the test FM using various materials:

Uses material: textures/darkmod/sfx/xray_replacing
Uses material: textures/darkmod/sfx/xray
Uses material: xray_glasses_overlay_replacing_warped
Uses material: xray_glasses_overlay_mixed_warped


Supported entity types

This is how the following entities can be affected by the xray feature at present:

  • Entities with models, including AIs: "model_xray" and "skin_xray" both work.
  • Brushes and patches: "model_xray" and "skin_xray" both work.
  • Lights: currently no way to manipulate these with the xray feature.
  • Func_emitters: "skin_xray" works, but not "model_xray".
  • Func_smokes: no way to manipulate these with xrays, and it looks unlikely that it'll be implemented due to how func_smokes work.


Limitations

  • The xray system doesn't affect solidity or frobability of xray-enabled entities, so separate scripting is required to handle this. Ideally this would be part of a scriptobject of an equippable item like "xray glasses" - see Xrays in GUIs for more.
  • Xray vision to see entities through solid obstacles only works if the entity is already being rendered. You can't see entities in neighbouring rooms if all the visportal to that room are closed. This would be a good reason to keep such xray screens stationary.


See also

Xrays in GUIs: Describes how the equippable "xray glasses" inventory item was made.