Post tutorial Report content RSS feed Player Model and Mirror Reflections

A short explanation followed by a tutorial about the Player Model and the Mirror Reflections systems in Underhell.

Posted by on - Basic Mapping/Technical

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.

Player Model


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:

!player SetPlayerModel models/player/jake_guard.mdl 

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 :

$includemodel "player/male_anims.mdl"
$includemodel "humans/male_shared.mdl"
$includemodel "humans/male_ss.mdl"
$includemodel "humans/male_gestures.mdl"
$includemodel "humans/male_postures.mdl"
$includemodel "humans/female_shared.mdl"
$includemodel "humans/female_ss.mdl"
$includemodel "alyx_animations.mdl"
$includemodel "alyx_gestures.mdl"

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.

Mirrors


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:

code:
uh_rendermirrorsonly 1

Setting this keyvalue to any entity in the game, will tell the engine to render them only in "RenderTarget" textures, therefore only in func_reflective_glass or func_monitors.

Multiple Mirrors


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.

Programming by Carlos "Charly" Sotelo
Comments
Serathis
Serathis

Player reflections? In a Half Life mod? Hell must have frozen over! Nice.

Reply Good karma Bad karma+24 votes
Domo01
Domo01

It's not like this is the first mod to have reflections in mirrors. Still mighty impressive though.

Reply Good karma Bad karma+4 votes
TheJP3372
TheJP3372

I sense really creepy mirror scares coming o.0

Reply Good karma Bad karma+11 votes
Dønny
Dønny

in this case we need feet and legs too! i can't identify myself with a mute, astral entity anyways..

Reply Good karma Bad karma+3 votes
Phenixtri
Phenixtri

indeed a properly animated player view model capable of visibly interacting with physics props would really bring the games atmosphere to life. IE being able to see your own arm picking things up for example. Not even valve has had the balls to pull something like that off.

Reply Good karma Bad karma+2 votes
Mxthe Author
Mxthe

Yeah well don't expect that to happen any time soon.

Crysis kinda does that in first person for some objects, but you can't really pick up a lot of objects in the game.

The problem with this system comes in the fact that every object has different mass and shape, and the arms and hands would need to be animated correctly so the "carrying" would look right.

Doing this arm and hands animation for every possible object in the game is a nightmare.

It could be done procedurally, which is most likely what will happen, but game developers have more important things to do that work on such things.

Very few games allow you to pick up physic objects at all...

Reply Good karma+3 votes
Mkilbride
Mkilbride

Uh, what?

Valve has done that before in a game.

Also, there is a mod that allows you to pick up weapons. You see your hands go down, like Crysis and pick them up.

Can't find the mod right now though. It was basically CS:S with really advanced bots, more weapons,a nd changes, like SMOD, but wasn't called so.

Reply Good karma Bad karma-4 votes
Chad51
Chad51

Awesome

Reply Good karma Bad karma+1 vote
Dr.Goupyl
Dr.Goupyl

That's really neat, i like how you put small but cool extra details.

Reply Good karma Bad karma+9 votes
Sn4rk
Sn4rk

You can finally see yourself in mirrors? I suggest to make some scares like this :D example: You look at the mirror, everything looks normal. You look away, then you look back and "she" is standing behind you.

Reply Good karma Bad karma+1 vote
Azatoth027
Azatoth027

This.

Reply Good karma Bad karma+1 vote
Kisaraji
Kisaraji

It's one step to make the player fell that he isn't just a floating weapon!

Reply Good karma Bad karma+3 votes
itsthepopei
itsthepopei

Floating weapons have feelings too!!!!

Reply Good karma Bad karma+5 votes
IGotzNoSkittles78
IGotzNoSkittles78

The Player is not a weapon!! It's a pair of floating hands holding a weapon!

Reply Good karma Bad karma+1 vote
Dem-Gasmasks
Dem-Gasmasks

Can we just call it Field of View? Hands with a weapon seems weird for me :P

Reply Good karma Bad karma+1 vote
Rus[T]
Rus[T]

Wow, so weird this isn't supported by default, great work!

Reply Good karma Bad karma+3 votes
thedevon
thedevon

you should make a crazy mirror maze for one of the dreams

Reply Good karma Bad karma+4 votes
MisterMister
MisterMister

Thank You so much!

Reply Good karma Bad karma+3 votes
Dune_Jumper
Dune_Jumper

Too bad I won't enjoy looking at my reflection...I'll be too worried about what else is about to appear in the reflection.

Reply Good karma Bad karma+3 votes
CaptainCat
CaptainCat

Aright, now give us the lower half of our bodys. Please

Reply Good karma Bad karma+4 votes
Bor2571
Bor2571

I think this would be a good horror scene idea "You walk into the room and look at the mirror, the door shuts and you investigate, when you turn back and look at the mirror you see her then some creepy stuff happens like screaming then the lights go out and so on" don't you people agree with me.

Reply Good karma Bad karma+1 vote
Dr_Tomorrow
Dr_Tomorrow

Why Valve couldn't implement this stuff by now? I mean I feel that the whole Valve gaming company programmers are no better than Charly all alone...

Reply Good karma Bad karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Tutorial
Browse
Tutorials
Share
Related Mods
Related Games
Half-Life 2
Half-Life 2 First Person Shooter