Report article RSS Feed Multiple Render Targets, Higher Resolution Monitors

This tutorial will explain how we implemented a system to workaround the Source Engine's limitation of having only 1 Ingame Camera active at a time, and how we managed to increase the resolution to improve quality of the rendered camera.

Posted by Mxthe on Jul 24th, 2012
Basic Mapping/Technical.

It is a known and grieved limitation, the Source Engine allows for only 1 ingame camera to be rendered in a map at all times.
Although you can change the point_camera to render for a func_monitor, you can only have 1 camera rendered at once, and the Resolution of said monitor is set at 256x256, no matter how much you resize your monitor in Hammer.

This is due to Source only having 1 RenderTarget texture, if multiple cameras would be active at once, and one would be pointing at the monitor, it would render the texture within itself, therefore generating an infinite render loop and crashing the game.

HAMMER


So this is why we have implemented a Hammer Keyvalue into the point_camera entity :

code:
Point_Camera Keyvalues :

Rendertarget : 1
Rendertarget : 2
Rendertarget : 3
Rendertarget : 4

Which are, respectively :

256A
256B
512A
512B

      

This simple Hammer Keyvalue that needs to be added to the point_camera's properties by turning SmartEdit off, allows to set an index for new Render Target textures for the cameras, therefore working around the limitation.

.VMT


What we had to do, was to make the engine build a new set of render target textures, and in order for us to reference them in the level editor, we created a set of VMTs that calls the corresponding engine texture.

code:
materials/dev/dev_monitor_256A.vmt
materials/dev/dev_monitor_256B.vmt
materials/dev/dev_monitor_512A.vmt
materials/dev/dev_monitor_512B.vmt

 

If you open up the VMTs, you will see the following code inside.

code:
dev_monitor_256A.vmt

"UnlitGeneric"
{
  "$basetexture" "_rt_CustomCamera_1"
  "%tooltexture" "dev/dev_monitor"
  "$surfaceprop" "glass"
}


dev_monitor_256B.vmt

"UnlitGeneric"
{
  "$basetexture" "_rt_CustomCamera_2"
  "%tooltexture" "dev/dev_monitor"
  "$surfaceprop" "glass"
}

dev_monitor_512A.vmt

"UnlitGeneric"
{
  "$basetexture" "_rt_CustomCamera_3"
  "%tooltexture" "dev/dev_monitor_512"
  "$surfaceprop" "glass"
}

dev_monitor_512B.vmt

"UnlitGeneric"
{
  "$basetexture" "_rt_CustomCamera_4"
  "%tooltexture" "dev/dev_monitor_512"
  "$surfaceprop" "glass"
}  

 

IMPORTANT : If no "$surfaceprop" is set, when you buildcubemaps the Monitor will NOT render.
Weird glitch, took us a while to figure it out.

You will notice the index of each _rt_CustomCamera_* refers directly to the number you need to enter in the point_camera's "RenderTarget" keyvalue.

So, if you place a func_monitor with the texture "dev_monitor_512A" applied to it, which is the Index number 3, you then need to have a point_camera with the keyvalue:
RenderTarget : 3

That is how they are linked together, now thanks to those 4 extra monitors, plus the original one, you can have a maximum of 5 monitors in game working independently.
Just avoid putting a point_camera and a func_monitor in the Same Room, especially if they are linked

Monitor Effect Overlay

If you want to add a "ScanLines" overlay to make it look like an actual MonitorTexture, you need to add a $texture2 texture set, and a few proxies effects.

I suggest you take a look at Valve's Monitor VMTs using GCFScape, then open
"/../steamapps/source materials.gcf"

Then browse to "hl2/materials/dev/"
Take a look at all the "dev_combinemonitors" and "dev_tvmonitors"
They have quite a couple of Monitor Effects there.


Programming by Carlos "Charly" Sotelo

Post comment Comments
MisterMister
MisterMister Jul 24 2012, 10:29pm says:

Wow keep em coming!, Last question will the gore system be implemented into the prologue? P.S. sorry for asking so many questions.

+5 votes     reply to comment
Mxthe
Mxthe Jul 24 2012, 10:59pm replied:

Yeah, Prologue will be re-released alongside Chapter1, with all the new features.

+8 votes     reply to comment
Light_Kill
Light_Kill Jul 25 2012, 7:49am replied:

Nice job Mxthe, can't wait this sweet release :D

+1 vote     reply to comment
IGotzNoSkittles78
IGotzNoSkittles78 Jul 25 2012, 12:16am says:

It's great to see something like this from a coder. Normally when the word "Coder" comes into mind for game design, is something like "Advanced AI", "Bad-*** Weapons", or anything along those lines. Pretty neat to hear something that benefits the development aspects of a mod rather then mindless fun(Not that there's a problem with that).

+3 votes     reply to comment
IGotzNoSkittles78
IGotzNoSkittles78 Jul 25 2012, 10:33pm replied:

Oh woups, I meant to type this comment on another tutorial page for Underhell. Well I sure look stupid in front of anyone that's read this page before I typed this.

+1 vote     reply to comment
Mxthe
Mxthe Jul 25 2012, 10:57pm replied:

Well I could always delete your comment if you'd like, but where would be the fun in that ?

+3 votes     reply to comment
Darkamo
Darkamo Jul 25 2012, 2:32am says:

great !!! i can't wait for the release of the Chapter 1 ! because i'm waiting it and waiting , waiting is hard ;)

+3 votes     reply to comment
Mkilbride
Mkilbride Jul 25 2012, 4:58am replied:

Yes, waiting is very hard.

Underhell was truly a breakthrough in the stale FPS genre and I've been waiting ever since for EP1. :P

+2 votes     reply to comment
greeneyedgirl927
greeneyedgirl927 Jul 25 2012, 7:21am replied:

But were almost there. ;)

+1 vote     reply to comment
Darkamo
Darkamo Jul 25 2012, 12:02pm replied:

yes were almost ther you right and the expectation is closing right ?

+1 vote     reply to comment
killbotvii
killbotvii Jul 31 2012, 5:00pm replied:

Whoops, I accidentally voted down your comment! I meant to vote up, my appologies!

+1 vote     reply to comment
redalpha01
redalpha01 Jul 25 2012, 8:29am says:

Aren't portal's portal multiple render cams?

+1 vote     reply to comment
{{)ark}_}{ue
{{)ark}_}{ue Jul 25 2012, 10:59am replied:

Portal also runs on a different version of the source engine...right?

+1 vote     reply to comment
zonbie
zonbie Aug 18 2012, 2:49pm replied:

Portal renders a finite number of iterations through the portal before rendering a black hole instead, thus breaking the chain. you can control how many times it renders before quitting, and that is a user-controlled optimization setting in the options.

+1 vote     reply to comment
Arkanium
Arkanium Aug 1 2012, 10:33am says:

Thanks, this is pretty useful.

redalpha01 has an interesting point though, since Portal's portals can essentially have a camera pointing at its own monitor without crashing the game. Even if it's a different version of Source, I'd be interested as to how that works.

+1 vote     reply to comment
creater
creater Aug 1 2012, 12:47pm says:

when are you going to realese underhell weve been waiting for months now

-1 votes     reply to comment
creater
creater Aug 1 2012, 12:49pm says:

can you atleast giveout a little gameplay and some scares on your youtube channel

-1 votes     reply to comment
Guest
Guest Jan 15 2013, 9:04pm says:

This comment is currently awaiting admin approval, join now to view.

The_Mighty_Atom
The_Mighty_Atom Jul 15 2014, 1:19pm says:

So does this only work with your mod, not with vanilla HL2/Ep1/Ep2? Because I just tried it in unmodded HL2/Ep1/Ep2 and I couldn't get it to work, I kept getting the purple-black checkerboard textures ingame.

+1 vote     reply to comment
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Tutorial
Browse
Tutorials
Report Abuse
Report article
Related Mods
Underhell (Half-Life 2)
Underhell Half-Life 2 - Single Player Adventure
Related Games
Half-Life 2
Half-Life 2 Single & Multiplayer First Person Shooter