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.
#2
07/22/2007 (6:05 am)
Nice work so far. Interested as well :)
#3
07/22/2007 (10:25 am)
This is very interesting specially the mouse pointer light. What is this sephia rendering I've never heard of this before, if I may ask.
#5
07/22/2007 (1:02 pm)
Very nice!
#6
07/23/2007 (1:02 pm)
Super cool stuff! Please keep posting your progress.
#7
08/07/2007 (9:23 am)
This seems extremely spiffy. Does this work with the custom materials system or something else?
#8
The shaders can use also some parameters passed directly to him, like:
08/07/2007 (5:43 pm)
Basically you define your own shader, for example:new ShaderData( HotSpotFxShader )
{
DXVertexShaderFile = "shaders/canvasfx/hotSpotV.hlsl";
DXPixelShaderFile = "shaders/canvasfx/hotSpotP.hlsl";
pixVersion = 2.0;
};and then you activate it through some console commands:function doFxSpot()
{
canvas.setCanvasFxVars($spotFxVars[0] SPC $spotFxVars[1] SPC $spotFxVars[2] SPC $spotFxVars[3]);
canvas.setCanvasFx(HotSpotFxShader);
canvas.startCanvasFx();
}The first command setCanvasFxVars is to pass some parameters to your shaders. You can also setup up to two textures that can be used for effect, plus set-up a number generator if you have some special effect requiring ramp number generator.canvas.setCanvasFxGen(-1,1,1000);
canvas.setCanvasFxMaps("shaders/canvasfx/noise.dds", "shaders/canvasfx/Random3D.dds");The shaders can use also some parameters passed directly to him, like:
// CanvasFX vertex shader constants #define VC_CANVAS_P1 4 // Parameter 1 #define VC_CANVAS_P2 5 // Parameter 2 #define VC_CANVAS_P3 6 // Parameter 3 #define VC_CANVAS_P4 7 // Parameter 4 #define VC_SIMTIME 8 // Simulation time (1st linear, 2nd cos, 3rd sin) #define VC_GENTIME 9 // Generated time (1st linear, 2nd cos, 3rd sin) #define VC_MOUSE_POS 10 // Mouse position (absolute pixel) // Enf of CanvasFx constants // CanvasFX pixel shader constants #define PC_CANVAS_P1 0 // Parameter 1 #define PC_CANVAS_P2 1 // Parameter 2 #define PC_CANVAS_P3 2 // Parameter 3 #define PC_CANVAS_P4 3 // Parameter 4 #define PC_SIMTIME 4 // Simulation time (1st linear, 2nd cos, 3rd sin) #define PC_GENTIME 5 // Generated time (1st linear, 2nd cos, 3rd sin) #define PC_MOUSE_POS 6 // Mouse position (relative 0..1) // Enf of CanvasFx constants
#10
08/26/2007 (1:57 am)
Looks like my resource is late to be accepted... so it is still not available in the resource pages.
#11
08/26/2007 (10:19 am)
Frank, I'm a bit unclear about a few things. For one, you don't state where to put the definitions. I assumed you'd put them outside the if and else statements, so I was able to compile it. However, when I run it in-game I can't compile the shaders, as it says I'm missing those definitions.
#12
Still waiting for this resource to be approved...
08/26/2007 (10:52 pm)
Definitions are in the file shdrConsts.h that you can find inside example/shaders.Still waiting for this resource to be approved...
#13
08/27/2007 (6:24 am)
Right, but you didn't say where to put them in that file. Inside the IN_HLSL code block, inside the else statement, or outside all together. I assumed it was outside of both statements. Correct me if I'm wrong. I was unable to get the shaders to compile ingame, though I was using 1.02 and I may have incorrectly placed the definitions.
#14
08/27/2007 (6:54 am)
@Matt: the file provided inside the archive (from the resource) should have all definitions already set-up. If you can compile a TGEA executable, you should be able to compile your shaders in-game too. If you have issue, please send me an email with your error message or shaders and I will try to help you.
#15
You've left something out from your original code, I think. Try this in a stock build and see if it works.
08/27/2007 (8:58 pm)
C:\Program Files\GarageGames\TGEA_SDK\example\shaders\canvasfx\sepiaP.hlsl(19): error X3000: syntax error: unexpected integer constant C:\Program Files\GarageGames\TGEA_SDK\example\shaders\canvasfx\hotSpotP.hlsl(19): error X3000: syntax error: unexpected integer constant C:\Program Files\GarageGames\TGEA_SDK\example\shaders\canvasfx\waveV.hlsl(19): error X3000: syntax error: unexpected integer constant GFXD3DShader::initVertShader - unable to compile shader!
You've left something out from your original code, I think. Try this in a stock build and see if it works.
#16
08/28/2007 (2:25 am)
In fact I merged my code with a brand new install of TGEA 1.0.2. But after looking at the archive file, the file shdrConsts.h (inside example/shaders) is missing !!! I will update the resource with this file now. The file shdrConsts.h should look like this after uncompressing the archive:#ifdef IN_HLSL
// CanvasFX vertex shader constants
#define VC_CANVAS_P1 C4 // Parameter 1
#define VC_CANVAS_P2 C5 // Parameter 2
#define VC_CANVAS_P3 C6 // Parameter 3
#define VC_CANVAS_P4 C7 // Parameter 4
#define VC_SIMTIME C8 // Simulation time
#define VC_GENTIME C9 // Generated time
#define VC_MOUSE_POS C10 // Mouse position (absolute pixel)
// Enf of CanvasFx constants
#define VC_WORLD_PROJ C0
#define VC_TEX_TRANS1 C4
#define VC_ACCUM_TIME C8
#define VC_LIGHT_TRANS C8
#define VC_OBJ_TRANS C12
#define VC_CUBE_TRANS C16
#define VC_CUBE_EYE_POS C19 // in cubemap space
#define VC_EYE_POS C20 // in object space
#define VC_MAT_SPECPOWER C21
#define VC_FOGDATA C22
#define VC_LIGHT_POS1 C23
#define VC_LIGHT_DIR1 C24
#define VC_LIGHT_DIFFUSE1 C25
#define VC_LIGHT_SPEC1 C26
#define VC_LIGHT_POS2 C27
//#define VC_LIGHT_DIR2 C28
//#define VC_LIGHT_DIFFUSE2 C29
//#define VC_LIGHT_SPEC2 C30
#define VC_LIGHT_TRANS2 C31
//#define VC_LIGHT_POS4 C35
//#define VC_LIGHT_DIR4 C36
//#define VC_LIGHT_DIFFUSE4 C37
//#define VC_LIGHT_SPEC4 C38
#define VC_DETAIL_SCALE C40
// CanvasFX pixel shader constants
#define PC_CANVAS_P1 C0 // Parameter 1
#define PC_CANVAS_P2 C1 // Parameter 2
#define PC_CANVAS_P3 C2 // Parameter 3
#define PC_CANVAS_P4 C3 // Parameter 4
#define PC_SIMTIME C4 // Simulation time
#define PC_GENTIME C5 // Generated time
#define PC_MOUSE_POS C6 // Mouse position (relative 0..1)
// Enf of CanvasFx constants
#define PC_MAT_SPECCOLOR C0
#define PC_MAT_SPECPOWER C1
#define PC_DIFF_COLOR C2
#define PC_AMBIENT_COLOR C3
#define PC_ACCUM_TIME C4
#define PC_DIFF_COLOR2 C5
#define PC_USERDEF1 C6
#define PC_USERDEF2 C7
#define PC_USERDEF3 C8
// Mirror of above. Couldn't be cleaner because HLSL doesn't support function macros
#else
// CanvasFX vertex shader constants
#define VC_CANVAS_P1 4 // Parameter 1
#define VC_CANVAS_P2 5 // Parameter 2
#define VC_CANVAS_P3 6 // Parameter 3
#define VC_CANVAS_P4 7 // Parameter 4
#define VC_SIMTIME 8 // Simulation time
#define VC_GENTIME 9 // Generated time
#define VC_MOUSE_POS 10 // Mouse position (absolute pixel)
// Enf of CanvasFx constants
#define VC_WORLD_PROJ 0
#define VC_TEX_TRANS1 4
#define VC_ACCUM_TIME 8
#define VC_LIGHT_TRANS 8
#define VC_OBJ_TRANS 12
#define VC_CUBE_TRANS 16
#define VC_CUBE_EYE_POS 19 // in cubemap space
#define VC_EYE_POS 20 // in object space
#define VC_MAT_SPECPOWER 21
#define VC_FOGDATA 22
#define VC_LIGHT_POS1 23
#define VC_LIGHT_DIR1 24
#define VC_LIGHT_DIFFUSE1 25
#define VC_LIGHT_SPEC1 26
#define VC_LIGHT_POS2 27
//#define VC_LIGHT_DIR2 28
//#define VC_LIGHT_DIFFUSE2 29
//#define VC_LIGHT_SPEC2 30
#define VC_LIGHT_TRANS2 31
//#define VC_LIGHT_POS4 35
//#define VC_LIGHT_DIR4 36
//#define VC_LIGHT_DIFFUSE4 37
//#define VC_LIGHT_SPEC4 38
#define VC_DETAIL_SCALE 40
// CanvasFX pixel shader constants
#define PC_CANVAS_P1 0 // Parameter 1
#define PC_CANVAS_P2 1 // Parameter 2
#define PC_CANVAS_P3 2 // Parameter 3
#define PC_CANVAS_P4 3 // Parameter 4
#define PC_SIMTIME 4 // Simulation time
#define PC_GENTIME 5 // Generated time
#define PC_MOUSE_POS 6 // Mouse position (relative 0..1)
// Enf of CanvasFx constants
#define PC_MAT_SPECCOLOR 0
#define PC_MAT_SPECPOWER 1
#define PC_DIFF_COLOR 2
#define PC_AMBIENT_COLOR 3
#define PC_ACCUM_TIME 4
#define PC_DIFF_COLOR2 5
#define PC_USERDEF1 6
#define PC_USERDEF2 7
#define PC_USERDEF3 8
#endif
#17
08/28/2007 (9:19 pm)
Thanks Frank. This is a really cool resource.
#18
If you try some fancy shaders, please post a screenshot ;)
08/29/2007 (7:13 am)
You're welcome but the resource is not yet approved :).If you try some fancy shaders, please post a screenshot ;)
#19
08/29/2007 (12:23 pm)
Approved =)
#20
08/29/2007 (7:20 pm)
Really great resource works like a charm :). Hmm time for me to try and figure out how to put together a multipass Depth of field shader.
Torque Owner Alienforce
DLN