A short explanation followed by a tutorial about the Player Model and the Mirror Reflections systems in Underhell.
Posted by Mxthe on Aug 17th, 2012
The Orange Box engine has an brush entity called "func_reflective_glass", it is a mirror entity.
Technically, it is a Camera and a Monitor within itself, which is why if you have more than one of these in a same room, you will get issues.
These mirrors look great and add a lot of realism to environments, unfortunately there is one thing that does not reflect : The player himself.
This is due to the player NOT having a model set in Orange Box, and even when set, it remains invisible when in first person mode.
Due to a small Third Person part in Underhell : Chapter 1, we had to create a functional and animated player model, that would closely follow the player's movement speed, animation and head direction, to try and make him as "alive" looking as possible.
This is why we manually animated and linked every single player behavior, down to lowering weapons, shooting, jumping and crouching, to a preset playermodel.
The default player model is : "models/player/jake_casual.mdl"
In order to change the player model, an input must be sent to the !player entity:
This input to the !player will set the playermodel to whatever is specified.
If the model path/name is not correct, the game will simply display an error message in the console, and the model will remain unchanged.
In order for any additional player model to be animated properly, the following lines must be added to the .qc of the model :
Yes, those are a lot of compiled animation models, but this gives many possibilities for the player model to be well animated or even be an actor during scenes, that can have many gestures/poses.
A feature commonly used in Underhell.
So we had our player model, fully functional in Third Person, but it would still not render in mirrors nor monitors.The main problem was, that in order for it to be rendered there, it also needed to be rendered in the "world" so that it could reflect properly, which means that if the player would look down while in first person, he would see INSIDE the player model, and cause very nasty visual bugs.
So, we thought of a system that would allow us to render entities ONLY in the "RenderTarget" textures, giving us not only the opportunity to render player in Mirrors and Monitors while in first person, but ANY dynamic entity in the game, can be added a keyvalue to be rendered only in Mirrors or Monitors.
This system gives us endless possibilities for scares, where "something" would only be visible while looking at it through a mirror/monitor.
The playermodel has this value set by default, in order for any entity to be rendered only in mirrors, the following keyvalue must be added in hammer, by turning smartedit off:
As previously stated in the Multiple Render Texture, placing multiple RenderTargets that use the same RenderTarget texture in one room, messes it up badly, and can even cause crashes.
The Multiple Mirrors feature is something that we have planned, however at the time we are uncertain if it is possible using the same technique used previously.
Whenever this feature is implemented and works correctly, I will edit this section and describe it's functionality.