Since I haven't contributed that much lately, here are a few shaders that everyone could have made already, íf they owned the pro version ánd know how to search the web. (I am still a shader noob, trust me)

(Note: I have only changed some values here and there or added things, the real credits actually goes to 'Facewound' developer Garry Newman. His HLSL tutorial is awesome and very simple. No credits needed, free for use.)

I've got the following shaders:

Blur:



Code:

//Diagonal blur:
material mat_blur {
effect = "

sampler2D g_samSrcColor;
float ds;
float xx;
float yy;
float4 Color;
float3 vecSkill41;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {

float4 Color;Color = tex2D( g_samSrcColor, Tex.xy);
Color += tex2D( g_samSrcColor, Tex.xy+0.001);
Color += tex2D( g_samSrcColor, Tex.xy+0.002);
Color += tex2D( g_samSrcColor, Tex.xy+0.003);
Color = Color / 4;
return Color;
}

// Just one pass:
technique PostProcess {
pass p1 {
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}



Bloom blur:


Code:

//Bloom Blur:
material mat_bloomblur {
effect = "

sampler2D g_samSrcColor;
float ds;
float xx;
float yy;
float4 Color;
float3 vecSkill41;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {

float4 Color;Color = tex2D( g_samSrcColor, Tex.xy);
Color += tex2D( g_samSrcColor, Tex.xy+0.001);
Color += tex2D( g_samSrcColor, Tex.xy+0.002);
Color += tex2D( g_samSrcColor, Tex.xy+0.003);
Color = Color / 2;
return Color;
}

// Just one pass:
technique PostProcess {
pass p1 {
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}



Emboss:


Code:

//Emboss Test works:
material mat_emboss {
effect = "

sampler2D g_samSrcColor;
float ds;
float xx;
float yy;
float4 Color;
float3 vecSkill41;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {

float4 Color;
Color.a = 1.0f;
Color.rgb = 0.5f;
Color -= tex2D( g_samSrcColor, Tex.xy-0.001)*2.0f;
Color += tex2D( g_samSrcColor, Tex.xy+0.001)*2.0f;
Color.rgb = (Color.r+Color.g+Color.b)/3.0f;
return Color;
}

// Just one pass:
technique PostProcess {
pass p1 {
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}



Greyscale:


Code:

//Greyscale shader:
material mat_greyscale {
effect = "

sampler2D g_samSrcColor;
float ds;
float xx;
float yy;
float4 Color;
float3 vecSkill41;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {

float4 Color;

Color.a = 1.0f;
Color = tex2D( g_samSrcColor, Tex.xy);
Color.rgb = (Color.r+Color.g+Color.b)/3.0f;
Color = Color *2;
return Color;
}

// Just one pass:
technique PostProcess {
pass p1 {
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}



Sharpen:


Code:

// Sharpen Shader:
material mat_sharpen {
effect = "

sampler2D g_samSrcColor;
float ds;
float xx;
float yy;
float4 Color;
float3 vecSkill41;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {

float4 Color;
Color = tex2D( g_samSrcColor, Tex.xy);
Color -= tex2D( g_samSrcColor, Tex.xy+0.0001)*10.0f;
Color += tex2D( g_samSrcColor, Tex.xy-0.0001)*10.0f;
return Color;
}

// Just one pass:
technique PostProcess {
pass p1 {
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}



Nightvision 1:


Code:

// Nightvision shader:
material mat_nvision {
effect = "

sampler2D g_samSrcColor;
float ds;
float xx;
float yy;
float4 Color;
float3 vecSkill41;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {

float4 Color;
Color = tex2D( g_samSrcColor, Tex.xy);
Color.g = Color.g*2;
return Color;
}

// Just one pass:
technique PostProcess {
pass p1 {
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}



Nightvision 2:


Code:

//Nightvision 2 shader:
material mat_nvision2 {
effect = "

sampler2D g_samSrcColor;
float ds;
float xx;
float yy;
float4 Color;
float3 vecSkill41;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {

float4 Color;
Color = tex2D( g_samSrcColor, Tex.xy);

Color.b = Color.r*2;
Color.g = Color.b*2;

//Color.g = Color.r*2;
//Color.b = Color.g*2;
return Color;
}

// Just one pass:
technique PostProcess {
pass p1 {
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}



Negative:


Code:

//Negative:
material mat_negative {
effect = "

sampler2D g_samSrcColor;
float ds;
float xx;
float yy;
float4 Color;
float3 vecSkill41;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {

float4 Color;Color = 1-tex2D( g_samSrcColor, Tex.xy);
Color.a = 1.0f;
return Color;
}

// Just one pass:
technique PostProcess {
pass p1 {
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}



And last but not least, a 'dizzyness' or 'breathing' shader. A screenshot won't show the effect, it's all about the camera motion.

Breath/dizzyness shader:
Code:

// Head wobble dizzyness shader:
material mat_wobble {
effect = "

sampler2D g_samSrcColor;
float ds;
float xx;
float yy;
float4 Color;
float3 vecSkill41;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {

float4 Color;
Tex.y = Tex.y + (sin(vecSkill41.y)*0.01);
Tex.x = Tex.x + (cos(vecSkill41.z)*0.01);
Color = tex2D( g_samSrcColor, Tex.xy);
return Color;
}

// Just one pass:
technique PostProcess {
pass p1 {
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}



---
The view I've defined;
Code:

view GlowCamera
{
layer = -1;
flags = visible;

}



The code I used to define a screen aligned quad;
Code:

entity glow_quad_view
{
type = <glow.tga>; //= 1024 x 768 32bit
layer = 2; // display above view entities with layer 1
view = camera;// same camera parameters as the default view
// set the x position according to the texture size..
// x = 36; // for 32
// x = 72; // for 64
alpha = 100;
x = 880;//1550;//550; // for 128
y = 0; //center horzontally
z = 0; // and center vertically
scale_x = 1;//1; //.33;
scale_y =1;

}
//


Next up, the starter function. (sorry, pretty messy, but should give you an idea about how I tried to change the code and stuff)
Code:

starter map_glow()
{
var vartime =0.1;
var varrip = 9;
glow_quad_view.ambient=50;
glow_quad_view.transparent=on;
glow_quad_view.visible=on;
glow_quad_view.alpha=10;
glow_quad_view.nofog = 1;
//
Glow_quad_view.skill41 = float(0.05);
// Frequency:
Glow_quad_view.skill42 = float(9.0);
// Ripple offset:
Glow_quad_view.skill43 = float(vartime);//
glow_quad_view.material=mat_emboss; // CHANGE THIS TO SHADER OF PREFERENCE!!
GlowCamera.bmap=bmap_for_entity(glow_quad_view,0);
//
// Amplitude:
//some_variable_related_to_time_to_make_it_ripple);

//
while(1)
{
proc_late();
// if(game_state){glow_quad_view.visible=on;}else{glow_quad_view.visible=off;}
GlowCamera.size_x=screen_size.x;
GlowCamera.size_y=screen_size.y;
vec_set(GlowCamera.x,camera.x);
vec_set(GlowCamera.pan,camera.pan);
//9.0
Glow_quad_view.skill42 = float(varrip);
varrip+=0.5;
Glow_quad_view.skill43 = float(vartime);
//vartime+=0.1;
//if(varrip>1){varrip=1;}
//if(vartime>0.5){vartime=0.1;}
//
wait(1);
}
}



As you may have guessed by now, I used parts of the glow shader code to get things quickly set up;
Code:

function toggle_glow
{
if(GlowCamera.visible)
{
GlowCamera.visible = off;
glow_quad_view.visible = off;
}
else
{
GlowCamera.visible = on;
glow_quad_view.visible = on;
}
}
function toggle_shadow
{
if(GlowCamera.noshadow)
{
GlowCamera.noshadow = off;
}
else
{
GlowCamera.noshadow = on;
}
}

on_1 = toggle_glow;
on_2 = toggle_shadow;



That's all folks!

Tutorial link: Gary Newman's HLSL post-processing tutorial

Cheers

Last edited by PHeMoX; 01/02/07 19:06.