Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, dr_panther), 821 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 5 1 2 3 4 5
A total of 10 (!) Post-Processing Shaders :) #104850
01/02/07 04:44
01/02/07 04:44
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline OP
Senior Expert
PHeMoX  Offline OP
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
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.
Re: A total of 9 (!) Post-Processing Shaders :) [Re: PHeMoX] #104851
01/02/07 07:17
01/02/07 07:17
Joined: Jul 2006
Posts: 503
Australia
A
adoado Offline

User
adoado  Offline

User
A

Joined: Jul 2006
Posts: 503
Australia
Wow these are really good!! Thanks! I'll try them out soon

Nice work!

Adoado


Visit our development blog: http://yellloh.com
Re: A total of 9 (!) Post-Processing Shaders :) [Re: PHeMoX] #104852
01/02/07 07:26
01/02/07 07:26
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Thank you!

Re: A total of 9 (!) Post-Processing Shaders :) [Re: HeelX] #104853
01/02/07 07:30
01/02/07 07:30
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline

Dichotomic
Captain_Kiyaku  Offline

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
is it possible to apply the negative shader only to a sprite or something, so only everything behind that "sprite" is negative?


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: A total of 9 (!) Post-Processing Shaders :) [Re: Captain_Kiyaku] #104854
01/02/07 07:36
01/02/07 07:36
Joined: Jul 2003
Posts: 893
Melbourne, Australia
Matt_Coles Offline

User
Matt_Coles  Offline

User

Joined: Jul 2003
Posts: 893
Melbourne, Australia
very nice, thanks phemox.
Now only if I could jump in time to two weeks when I purchase a6 pro for my uni course

Re: A total of 9 (!) Post-Processing Shaders :) [Re: Captain_Kiyaku] #104855
01/02/07 08:25
01/02/07 08:25
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline OP
Senior Expert
PHeMoX  Offline OP
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Quote:

is it possible to apply the negative shader only to a sprite or something, so only everything behind that "sprite" is negative?




Yes, this is possible (not really on a sprite I think, don't think shaders will work on sprites, but you could make a one-sided model). Infact, it's quite easy to do so, there already is Oliver2s his refraction shader example out there (somewhere) using that method to distort things behind windows.

Anyways the only thing you basically need to change, is change the view entity into a real entity, give it the material and then you should be done already. I think everything else can pretty much be left as is, camera settings included.

Quote:

Now only if I could jump in time to two weeks when I purchase a6 pro for my uni course




I totally know what you mean, one of the main reasons I bought pro was the possibility to make post-processing shaders and realtime mirrors.

When you look at the code I've posted here, mostly it's color calculations, so it's really nothing complicated.

Things become really awesome when you combine stuff, like for example Ichiro's pucker shader thing and my nightvision 2 shader, shouldn't be to hard to figure that out.

Thanks for the comments guys, I hope this is useful,

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: A total of 9 (!) Post-Processing Shaders :) [Re: PHeMoX] #104856
01/02/07 08:28
01/02/07 08:28
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline

Dichotomic
Captain_Kiyaku  Offline

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
ok i will try it out later. thank you for the nice collection ^^.


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: A total of 9 (!) Post-Processing Shaders :) [Re: Captain_Kiyaku] #104857
01/02/07 15:29
01/02/07 15:29
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
awesome collection..thanks Phemox !
One question though..Is it always supposed to be a blur bloom or there
could be a bloom without blur ?

Re: A total of 9 (!) Post-Processing Shaders :) [Re: Captain_Kiyaku] #104858
01/02/07 15:37
01/02/07 15:37
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Quote:

thank you for the nice collection ^^.




Same here!
Nice especially, because theyare short. Guess, short means fast!?

Thanks a lot!

Re: A total of 9 (!) Post-Processing Shaders :) [Re: Pappenheimer] #104859
01/02/07 16:01
01/02/07 16:01
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline OP
Senior Expert
PHeMoX  Offline OP
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Quote:

Quote:

thank you for the nice collection ^^.




Same here!
Nice especially, because theyare short. Guess, short means fast!?

Thanks a lot!




You guys are all welcome and yes as far as I know these effects can't be written any shorter, I've got little to no drop of fps at all, it's fast indeed. (off course it is rendering a scene twice, so expect sóme fps loss, but it's very acceptable.)

Quote:

Is it always supposed to be a blur bloom or there
could be a bloom without blur ?




Well, I called it bloom blur because that's basically what it looks like. The mat_bloom_2 from Ichiro is probably a better example of real bloom, although that one blurs everything a bit too. Bloom is basically multiplying the lighter spots, I achieved that in the bloom blur by multiplying the blur code, so it's not that strange that it's bloom blur hehehe.

Cheers

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Page 1 of 5 1 2 3 4 5

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1