Full screen FX
by Frank Bignone · in Torque Game Engine Advanced · 07/22/2007 (3:56 am) · 58 replies
Here are two examples of a simple framework I have added to the canvas GUI in order to have full screen shaders. The first example is a rendering in sepia tones:

The second one is a special rendering effect which highlights the screen around the mouse pointer (like a flash light effect).

The framework allows the following:
- vertex effect (like flag, image deformation...) based on time (time is passed to shaders)
- effect linked to mouse position
- 16 floating user-defined values
- 2 user-defined textures (used for examples if rendering of old-movie style effects)
This is an under development ressource that when ready, I will post here if people are interested.

The second one is a special rendering effect which highlights the screen around the mouse pointer (like a flash light effect).

The framework allows the following:
- vertex effect (like flag, image deformation...) based on time (time is passed to shaders)
- effect linked to mouse position
- 16 floating user-defined values
- 2 user-defined textures (used for examples if rendering of old-movie style effects)
This is an under development ressource that when ready, I will post here if people are interested.
About the author
Real programmers don't waste time recompiling; they patch the binary files... ... Real programmers don't waste time patching binary files; they patch memory.
#22
Would it be possible to use this mechanism to do blurring or double-vision effects, or is it more intended for in-scene vertex/fragment mutation?
09/03/2007 (1:00 pm)
This looks excellent; thank you for your contribution!Would it be possible to use this mechanism to do blurring or double-vision effects, or is it more intended for in-scene vertex/fragment mutation?
#23
09/03/2007 (6:20 pm)
@SimOps: blurring effect is possible as long as it is a full-scene blurring effect you are trying to perform. If you want to do a movement blurring effect, then you will need to modify a little bit the code. Concerning the double-vision effect, i do not know what it is? If you have an example screenshot, please post it so I can advise you.
#24
I would be extremely greatful to you :). I've been trying to get a dof shader in for quite a while.
@ Frank
This is a fantastic resource!
09/06/2007 (7:59 pm)
@ Matt I would be extremely greatful to you :). I've been trying to get a dof shader in for quite a while.
@ Frank
This is a fantastic resource!
#25
hotSpotV
The effect is pretty primitive, but with some work it has potential.
09/06/2007 (8:09 pm)
HotSpotP#define IN_HLSL
#include "../shdrConsts.h"
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
struct v2f
{
float4 hpos : POSITION;
float2 texCoord : TEXCOORD0;
};
struct Fragout
{
float4 col : COLOR0;
};
float3 mousePos : register(PC_MOUSE_POS);
float3 params : register(PC_CANVAS_P1);
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Fragout main( v2f IN,
uniform sampler2D diffuseMap : register(S0)
)
{
Fragout OUT;
float sampleDist0 = 0.02;
float focus = 0.66;
float range = 0.60;
float2 samples[12] = {
-0.126212, -0.105805,
-0.840144, -0.073580,
-0.395914, 0.457137,
-0.503345, 0.920716,
0.962340, -0.194983,
0.473434, -0.480026,
0.519456, 0.767022,
0.185461, -0.893124,
0.507431, 0.064425,
0.896420, 0.412458,
-0.321940, -0.932615,
-0.791559, -0.597705,
};
float4 diffuseColor = tex2D(diffuseMap, IN.texCoord);
float dist = distance(IN.texCoord.xy, mousePos.xy);
float fade = clamp((dist - params.x) * params.y, 0, 1);
float4 BlurColor = tex2D(diffuseMap, IN.texCoord);
for (int i = 0; i < 12; i++){
BlurColor += tex2D(diffuseMap, IN.texCoord + sampleDist0 * samples[i]);
}
BlurColor /= 11;
OUT.col = lerp(diffuseColor, BlurColor, fade);
return OUT;
}hotSpotV
#define IN_HLSL
#include "../shdrConsts.h"
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
struct VertData
{
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
};
struct v2f
{
float4 hpos : POSITION;
float2 outTexCoord : TEXCOORD0;
};
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
v2f main( VertData IN,
uniform float4x4 modelview : register(VC_WORLD_PROJ)
)
{
v2f OUT;
OUT.hpos = mul(modelview, IN.position);
OUT.outTexCoord = IN.texCoord;
return OUT;
}The effect is pretty primitive, but with some work it has potential.
#26
This is my first attempt at 2 passes:

uhm..as shown, it doesn't seem to work right yet lol, but then again I think it might my how I'm setting up the shaders.
09/07/2007 (5:48 pm)
Brilliant! I was thinking of something like that, but I wonder if we can do a multipass effect, this would allow for a much more advanced effect. So heres what I'm going to try to do with the lack of C++ programming I have. This is my first attempt at 2 passes:

uhm..as shown, it doesn't seem to work right yet lol, but then again I think it might my how I'm setting up the shaders.
#27
When I tried to use Matt's modified hotspot shaders above I get the following error:
Any ideas why that would be?
09/25/2007 (7:06 am)
Hi all,When I tried to use Matt's modified hotspot shaders above I get the following error:
error X4500: shader too complex. Try reducing number of texture loads used
Any ideas why that would be?
#28
Most likely you try to create an effect not working on that old hardware.
Either Shader 1.1 hardware (pre Radeon 9550 or GeForce FX5200) or your shader simply does not meet the shader model requirements or your cards requirements.
ATI have been seriously caped until X1300 and upwards (some would even say until the HD series) and were always 1-2 generations behind NVidia shader capability wise.
09/25/2007 (7:34 am)
What card do you have.Most likely you try to create an effect not working on that old hardware.
Either Shader 1.1 hardware (pre Radeon 9550 or GeForce FX5200) or your shader simply does not meet the shader model requirements or your cards requirements.
ATI have been seriously caped until X1300 and upwards (some would even say until the HD series) and were always 1-2 generations behind NVidia shader capability wise.
#29
09/25/2007 (7:37 am)
I wouldn't think it's the gfx card - it's a nVidia 7900GTX - but I am open to suggestions...
#30
09/25/2007 (8:50 am)
This mod is great, only gripe would be that it also shades your GUI menus.
#31
09/25/2007 (11:18 am)
Ah - I'd overwritten the dofxwave() function to point to the new pixel and vertex shader files but left the shader version at 1.4. Changed that to 2.0 and I no longer get the error. Nothing happens when I run the shader but I'll have a fiddle and see what I can find.
#32
09/26/2007 (3:26 am)
For information, I'm currently changing the codebase in order to have the possibility of screen fx shader to any GUI independently. In two words, it means you can have the main canvas with a wave fx, and the 3D rendering with a sepia tone. Current tests seems ok, but i want to try it on a broader scale and make it easy to upgrade (add some relevant information to shader: control object speed...).
#33
Spot shader activated on the 3D rendering GUI.

Spot shader on 3D + wave shader on all canvas.
09/26/2007 (3:43 am)
As an example, here is two shots with different fx shaders.Spot shader activated on the 3D rendering GUI.

Spot shader on 3D + wave shader on all canvas.
#34
09/26/2007 (5:05 am)
That looks great Frank, nice work.
#35
10/31/2007 (12:22 pm)
Hey Frank, Any progress on the screenFX shader for GUI's? BTW...This is a GREAT learning resource!
#36
11/02/2007 (4:56 pm)
It's up and running but in my current codebase of Pelorea: Tactical War. I did not yet merge with latest TGEA release. So until the merge, I cannot publish it as a resource.
#37
07/14/2008 (10:05 am)
How about a motion blur?
#39
08/10/2008 (2:45 pm)
I've written my own FX system for TGEA 1.7. Basically you just need to allocate a renderable texture and link it to a render target. The DRL system is a good example of this. Anyone interested in implementing fullscreen effects should definitely look at the DRL and glow buffers. They'll teach you how to allocate, push, and pop your render targets, along with managing them.
#40
- different fullscreen effect for all GUI (you can control for each GUI which effects to apply)
- update of the GUIControl to have a 'hiding' gui features
- update of the GUIControl to support the tooltip
08/11/2008 (8:26 am)
I'm posting an update of this resource for TGEA 1.7.1 with few nice additions:- different fullscreen effect for all GUI (you can control for each GUI which effects to apply)
- update of the GUIControl to have a 'hiding' gui features
- update of the GUIControl to support the tooltip
Torque Owner Matt Vitelli