Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (kzhao, AndrewAMD, bigsmack), 824 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
motion blur and DOF #137758
06/24/07 05:03
06/24/07 05:03
Joined: May 2005
Posts: 83
Texas
mocosgames Offline OP
Junior Member
mocosgames  Offline OP
Junior Member

Joined: May 2005
Posts: 83
Texas
I made 2 shaders based one the blur shader in the wiki, motion blur and depth of field. They work with any gamestudio edition that can use shaders. You can use them in anything for free.

http://img106.imageshack.us/my.php?image=pic1gz7.jpg

http://img106.imageshack.us/my.php?image=pic2tk2.jpg

DOF shader Code:
 float4x4 matWorldViewProj;	
float4x4 matWorld;
float4 vecViewPos;

float4 vecSkill41;

texture entSkin1;

sampler basemap = sampler_state { Texture = <entSkin1>; };

void blur1VS( uniform float exten,
in float4 inNormal : NORMAL0,
in float4 inPosition : POSITION0,
in float4 inTexcoord : TEXCOORD0,
out float4 outPosition : POSITION0,
out float4 outTexcoord : TEXCOORD0)
{
float3 PosWorld = mul(inPosition, matWorld);

float focus_distance=10;

float blurriness=0.3;
float depth = (((distance(PosWorld, vecViewPos))*.01)-focus_distance)*blurriness;

depth*=sign(depth)+2;

inPosition.xyz += abs(depth)*inNormal/exten;
outTexcoord = inTexcoord;
outPosition = mul(inPosition, matWorldViewProj);

}

void blur1PS ( uniform float alpha,
in float4 inTexcoord : TEXCOORD0,
out float4 outColor : COLOR0){
outColor = tex2D(basemap, inTexcoord.xy);
outColor.a=alpha;
}


void mainVS( in float4 inNormal : NORMAL0,
in float4 inPosition : POSITION0,
in float4 inTexcoord : TEXCOORD0,
out float4 outPosition : POSITION0,
out float4 outTexcoord : TEXCOORD0)
{
outTexcoord = inTexcoord;
outPosition = mul(inPosition, matWorldViewProj);
}

void mainPS(in float4 inTexcoord : TEXCOORD0, out float4 outColor : COLOR0) { outColor = tex2D(basemap, inTexcoord.xy); outColor.a=1; }

technique t1 {
pass p0 {
ZENABLE = TRUE;
zwriteenable=true;
AlphaBlendEnable = true;
VertexShader = compile vs_1_1 mainVS();
PixelShader = compile ps_2_0 mainPS();
}

pass p1 {
ZENABLE = TRUE;
zwriteenable=true;
AlphaBlendEnable = true;
VertexShader = compile vs_1_1 blur1VS(1.4);
PixelShader = compile ps_2_0 blur1PS(0.5);
}
pass p2 {
ZENABLE = TRUE;
zwriteenable=true;
AlphaBlendEnable = true;
VertexShader = compile vs_1_1 blur1VS(0.9);
PixelShader = compile ps_2_0 blur1PS(0.3);
}
}



motion blur action Code:
 
action motionblur{
my.transparent=on;
my.material=mblur;

var cam_pos[3];
var cam_x_change;
var cam_y_change;
var cam_pan_change;
var cam_tilt_change;
var cam_pan;
var cam_tilt;
while(1){
//have all movement code up here
my.skill41=float(-cam_pan_change*2+cam_y_change);
my.skill42=float(-cam_tilt_change*2);
my.skill43=float(cam_x_change);

cam_pan_change=camera.pan-cam_pan;
cam_tilt_change=camera.tilt-cam_tilt;
vec_add(cam_pos,my.pos);

vec_sub(cam_pos,camera.pos);

vec_rotate(cam_pos,vector(-camera.pan,-camera.tilt,-camera.roll));
cam_x_change=cam_pos.x/vec_dist(my.pos,camera.pos)*300;
cam_y_change=cam_pos.y/vec_dist(my.pos,camera.pos)*300;

cam_pan=camera.pan;
cam_tilt=camera.tilt;
vec_set(cam_pos,camera.pos);
vec_sub(cam_pos,my.pos);
wait(1);
}
}


motion blur shader Code:
 float4x4 matWorldViewProj;	
float4x4 matWorld;
float4 vecViewPos;

float4 vecSkill41;

texture entSkin1;

sampler basemap = sampler_state { Texture = <entSkin1>; };

void blur1VS( uniform float exten,
in float4 inNormal : NORMAL0,
in float4 inPosition : POSITION0,
in float4 inTexcoord : TEXCOORD0,
out float4 outPosition : POSITION0,
out float4 outTexcoord : TEXCOORD0)
{
float3 PosWorld = mul(inPosition, matWorld);

float focus_distance=10;

float blurriness=0.3;
float depth = (((distance(PosWorld, vecViewPos))*.01)-focus_distance)*blurriness;

depth*=sign(depth)+2;

inPosition.xyz += abs(depth)*inNormal/exten;
outTexcoord = inTexcoord;
outPosition = mul(inPosition, matWorldViewProj);

}

void blur1PS ( uniform float alpha,
in float4 inTexcoord : TEXCOORD0,
out float4 outColor : COLOR0){
outColor = tex2D(basemap, inTexcoord.xy);
outColor.a=alpha;
}


void mainVS( in float4 inNormal : NORMAL0,
in float4 inPosition : POSITION0,
in float4 inTexcoord : TEXCOORD0,
out float4 outPosition : POSITION0,
out float4 outTexcoord : TEXCOORD0)
{
outTexcoord = inTexcoord;
outPosition = mul(inPosition, matWorldViewProj);
}

void mainPS(in float4 inTexcoord : TEXCOORD0, out float4 outColor : COLOR0) { outColor = tex2D(basemap, inTexcoord.xy); outColor.a=1; }

technique t1 {
pass p0 {
ZENABLE = TRUE;
zwriteenable=true;
AlphaBlendEnable = true;
VertexShader = compile vs_1_1 mainVS();
PixelShader = compile ps_2_0 mainPS();
}

pass p1 {
ZENABLE = TRUE;
zwriteenable=true;
AlphaBlendEnable = true;
VertexShader = compile vs_1_1 blur1VS(1.4);
PixelShader = compile ps_2_0 blur1PS(0.5);
}
pass p2 {
ZENABLE = TRUE;
zwriteenable=true;
AlphaBlendEnable = true;
VertexShader = compile vs_1_1 blur1VS(0.9);
PixelShader = compile ps_2_0 blur1PS(0.3);
}
}



Re: motion blur and DOF [Re: mocosgames] #137759
06/24/07 06:37
06/24/07 06:37
Joined: Apr 2005
Posts: 2,332
Germany, BaWü
aztec Offline

Expert
aztec  Offline

Expert

Joined: Apr 2005
Posts: 2,332
Germany, BaWü
wow thank you a lot


Visit:
schwenkschuster-design.de
Re: motion blur and DOF [Re: aztec] #137760
06/24/07 09:22
06/24/07 09:22
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Nice contribution !!
Great too see the wiki shaders are still in use
Btw, could you host the scripts and make them available for download ?? I ask this for practical reasons because copy and pasting the code can turn out quite annoying sometimes

Thxn in progress

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: motion blur and DOF [Re: frazzle] #137761
06/24/07 10:22
06/24/07 10:22
Joined: Apr 2005
Posts: 2,332
Germany, BaWü
aztec Offline

Expert
aztec  Offline

Expert

Joined: Apr 2005
Posts: 2,332
Germany, BaWü
Quote:


Btw, could you host the scripts and make them available for download ?? I ask this for practical reasons because copy and pasting the code can turn out quite annoying sometimes





thats true


Visit:
schwenkschuster-design.de
Re: motion blur and DOF [Re: mocosgames] #137762
06/24/07 10:26
06/24/07 10:26
Joined: Oct 2006
Posts: 91
G
Ghost Offline
Junior Member
Ghost  Offline
Junior Member
G

Joined: Oct 2006
Posts: 91
Very cool contribution, thanks.

Re: motion blur and DOF [Re: Ghost] #137763
06/24/07 13:36
06/24/07 13:36
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
very nice, you even made the DOF where anyone can modify it, thank you so much


- aka Manslayer101
Re: motion blur and DOF [Re: mpdeveloper_B] #137764
06/24/07 18:18
06/24/07 18:18
Joined: May 2005
Posts: 83
Texas
mocosgames Offline OP
Junior Member
mocosgames  Offline OP
Junior Member

Joined: May 2005
Posts: 83
Texas
Heres a link where you can download it: http://putstuff.putfile.com/90581/8860779
That folder also contains the underwater shader I made.

Re: motion blur and DOF [Re: mocosgames] #137765
06/24/07 21:17
06/24/07 21:17
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Thank you, Brandon!
I'm going to try your underwater shader...

Re: motion blur and DOF [Re: mocosgames] #137766
06/24/07 21:43
06/24/07 21:43
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Quote:

Heres a link where you can download it: http://putstuff.putfile.com/90581/8860779
That folder also contains the underwater shader I made.




Thank you, very appriciated

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB

Moderated by  adoado, checkbutton, mk_1, Perro 

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