Render Scheming Part 1: In the heat of the night
by Gerald Fishel · 03/30/2009 (10:33 am) · 12 comments
In my last blog I introduced the post-processing framework and some of the things that were possible. That's all completed and I'm going through channels to get it up in the GarageGames store, so it should be available soon.
Now we'll look at what we can do when we take things a step further with the scripted render manager, which will be a more advanced version of the post processing manager.
These are a bit more involved, and take a bit more setup, so I'll break this up into a series showing different effects that can be done in each blog.
With the post-processing manager I demonstrated a simple night vision effect. It looks pretty cool, though it's not all that practical by itself without doing some other stuff behind the scenes to brighten things up.
Here I'll show a slightly improved night vision, along with a thermal vision effect similar to the thermal vision in Rainbow Six Vegas.
Now a bit about what's going on. The render manager is built upon the same framework as the post-processing manager, but adds the ability to render the scene or parts of the scene during each pass instead of just rendering quads. When a pass is rendered an optional scheme can be defined. A scheme may look something like this:
This just defines a scheme and sets the default material to "NoRender", which is a special material that means to skip the render. So when we use this scheme in a pass we'll only be rendering objects with materials that have a technique assigned for this scheme.
And then you would define a render pass that uses that scheme like so:
This says that we're going to do a scene render, we're going to use the depth buffer, we want to clear the color buffer before we render, but we're not going to clear the depth buffer, and we're going to render with the ThermalGlowScheme. The scene was previously rendered normally, so we keep the depth buffer from that render pass and only render heat-emitting materials in this pass, which is where the schemes come in.
We can assign scheme techniques to materials like this:
A technique is just the name of another material. HeatEmitter is a material that calculates a heat index based upon some parameters, and a luminance value derived by casting a light from the viewers position. This gives us a range from red and yellow for surfaces that are at angles to the viewer and bright white for surfaces facing us. For most characters this is good enough for our purposes. If we have other objects that need to calculate heat values differently, we can assign a different scheme to them. For instance objects that don't emit heat but are out in the sun can display a light pink heat signature where the sun is shining on them directly. You could use a different heat lookup texture for something more like a Predator type of thermal vision.
ThermalGlowMaterial just renders a solid pink, which is then passed through a blur filter in subsequent passes, which gives us a pink glow. Then we blend our heat rendering on top of that, which gives us a discreet pink glow surrounding our red-yellow-white thermal bloom.
The entire process actually takes 8 rendering stages, and I don't want to blow up the size of the blog by rolling it all out here, but it's pretty simple to setup using the render manager with the render schemes.
---
I'll be posting several more blogs in this series as I go along, with nice effects like motion blur, depth of field, ambient occlusion and all of the usual suspects, along with a number of different glow effects (so we can yank that hardcoded glow buffer out of the engine), and some other special goodies that I've come up with ;) In all there's about 200 different effects that I've come up with this system, though I'll just be showing some selected samples in these blogs, and probably a comprehensive list at the end (they'll all be included in the pack).
Assuming everything goes smoothly with getting the post processing manager up here, the advanced system should be ready to go in a few weeks.
Cheers
Edit: Here are some screenshots for the Vimeo impaired:


Now we'll look at what we can do when we take things a step further with the scripted render manager, which will be a more advanced version of the post processing manager.
These are a bit more involved, and take a bit more setup, so I'll break this up into a series showing different effects that can be done in each blog.
With the post-processing manager I demonstrated a simple night vision effect. It looks pretty cool, though it's not all that practical by itself without doing some other stuff behind the scenes to brighten things up.
Here I'll show a slightly improved night vision, along with a thermal vision effect similar to the thermal vision in Rainbow Six Vegas.
Now a bit about what's going on. The render manager is built upon the same framework as the post-processing manager, but adds the ability to render the scene or parts of the scene during each pass instead of just rendering quads. When a pass is rendered an optional scheme can be defined. A scheme may look something like this:
new MaterialScheme(ThermalGlowScheme)
{
defaultMaterial = NoRender;
}This just defines a scheme and sets the default material to "NoRender", which is a special material that means to skip the render. So when we use this scheme in a pass we'll only be rendering objects with materials that have a technique assigned for this scheme.
And then you would define a render pass that uses that scheme like so:
new RenderPass( ThermalGlowPass )
{
input = "none";
renderScene = true;
useDepth = true;
clearColor = true;
clearDepth = false;
scheme = "ThermalGlowScheme";
targetOutput = 4;
};This says that we're going to do a scene render, we're going to use the depth buffer, we want to clear the color buffer before we render, but we're not going to clear the depth buffer, and we're going to render with the ThermalGlowScheme. The scene was previously rendered normally, so we keep the depth buffer from that render pass and only render heat-emitting materials in this pass, which is where the schemes come in.
We can assign scheme techniques to materials like this:
new Material(SpaceOrc)
{
baseTex[0] = "Orc_Material";
bumpTex[0] = "Orc_Material_normal";
cubemap = WChrome;
pixelSpecular[0] = true;
specular[0] = "0.5 0.5 0.5 0.5";
specularPower[0] = 8.0;
};
function SpaceOrc::onInit(%this)
{
%this.setTechnique("ThermalScheme", "HeatEmitter" );
%this.setTechnique("ThermalGlowScheme", "ThermalGlowMaterial" );
}A technique is just the name of another material. HeatEmitter is a material that calculates a heat index based upon some parameters, and a luminance value derived by casting a light from the viewers position. This gives us a range from red and yellow for surfaces that are at angles to the viewer and bright white for surfaces facing us. For most characters this is good enough for our purposes. If we have other objects that need to calculate heat values differently, we can assign a different scheme to them. For instance objects that don't emit heat but are out in the sun can display a light pink heat signature where the sun is shining on them directly. You could use a different heat lookup texture for something more like a Predator type of thermal vision.
ThermalGlowMaterial just renders a solid pink, which is then passed through a blur filter in subsequent passes, which gives us a pink glow. Then we blend our heat rendering on top of that, which gives us a discreet pink glow surrounding our red-yellow-white thermal bloom.
The entire process actually takes 8 rendering stages, and I don't want to blow up the size of the blog by rolling it all out here, but it's pretty simple to setup using the render manager with the render schemes.
---
I'll be posting several more blogs in this series as I go along, with nice effects like motion blur, depth of field, ambient occlusion and all of the usual suspects, along with a number of different glow effects (so we can yank that hardcoded glow buffer out of the engine), and some other special goodies that I've come up with ;) In all there's about 200 different effects that I've come up with this system, though I'll just be showing some selected samples in these blogs, and probably a comprehensive list at the end (they'll all be included in the pack).
Assuming everything goes smoothly with getting the post processing manager up here, the advanced system should be ready to go in a few weeks.
Cheers
Edit: Here are some screenshots for the Vimeo impaired:


#2
So is your special render pass system using the existing RenderPassManager or RenderBinManager in TGEA?
Those are scriptable to some extent in TGEA. In Torque 3D the entire render bin creation and ordering is done in script.
03/30/2009 (11:07 am)
Very interesting stuff.So is your special render pass system using the existing RenderPassManager or RenderBinManager in TGEA?
Those are scriptable to some extent in TGEA. In Torque 3D the entire render bin creation and ordering is done in script.
#3
03/30/2009 (11:41 am)
@Tom, yes it uses the existing RenderPassManager system, slightly modified. The new render manager essentially hijacks the existing RenderPassManager, and then calls back into it as necessary. I considered just replacing the RenderPassManager but wanted to keep it as unobtrusive on the existing engine code as possible. The biggest changes are in the materials.
#4
03/30/2009 (6:13 pm)
Hate to be a bother, but Vimeo hates me and the video doesn't play. Would you mind posting a screenshot of the two effects?
#5
03/30/2009 (7:06 pm)
@Bryce, no bother, I added a couple of screenshots.
#6
@Bryce, try refresh the page and hit play again.
03/30/2009 (7:25 pm)
Impressive work! That subtle pink glow is a great little touch.@Bryce, try refresh the page and hit play again.
#7
03/30/2009 (7:26 pm)
Woah....that's some incredible stuff. Thanks for the screens :)
#8
03/31/2009 (12:38 am)
Too bad I'm colorblind -- I never saw any "pink" only white and blue-- but I did like the grainy green effect though. Beyond awesome!
#9
Great work man, great work!
03/31/2009 (11:19 am)
Having flown military aircraft for 6 years on night vision goggles, I just wanted to say that the NVG view is pretty damn close to accurate based on the technology available back in the early to mid 90's ;)Great work man, great work!
#10
Looks outstanding. Any ETA on this code ?
I guess T3d will make this unnecessary but since TGEA is gong to be around fora while knowing this technique would be well worth a reasonable price
04/13/2009 (12:07 am)
GeraldLooks outstanding. Any ETA on this code ?
I guess T3d will make this unnecessary but since TGEA is gong to be around fora while knowing this technique would be well worth a reasonable price
#11
01/01/2012 (6:53 pm)
So this is quite beautiful, and I wouldn't mind tinkering around with this. Any chance you'll release the code? ;)
#12
01/01/2012 (7:15 pm)
. 
Torque 3D Owner J.C. Smith