Is there a REAL Blur shader?

Posted By: indiGLOW

Is there a REAL Blur shader? - 03/23/05 00:36

I ask this bcz hunting around within the hallowed walls of this forum the only Blur shader reference I could find was actually not a shader and just a camera alpha trick.

I tried this method and the results can be seen, HERE this ref posted started out as something completely different, but at the end are some screens of the blur effect implemented according to camera alpha trick.

Now it looks good, but objects are clearly transparent and show objects behind them bcz of the camera alpha. I tried overlaying different views to see if I could compensate for this, but now I realise that simply setting the alpha on the view allows the view behind (nothing) to show, and when there is nothing you get trails...so although on the outset it appears to create the effect, it is next to useless in terms of using in a title...

So I am looking for some kind of shader that I could apply to create a blur effect, much like the one seen in N4Speed. I hope you guys can shed some light on this for me...
Posted By: ello

Re: Is there a REAL Blur shader? - 03/23/05 04:44

mister mister... better search another time. there are many blur shaders here. look out blur, bloom and this stuff..

however. here you have a pixelshader for a radial (speedymotion) blur:

Code:
 
float4 noiseps2(
float2 texCoord: TEXCOORD0,
uniform float cf1,
uniform float cf2,
uniform float cf3,
uniform float alpha
) : COLOR
{
float4 base=tex2D(basemap,texCoord);
float4 result=float4(0,0,0,0);
for(float i=0;i<5;i++)
{
result+=tex2D(basemap,texCoord-texCoord*(i/100)-i/200);
}
return (result+1-base)/(7+2*sin(vecTime.w/2300));
}



the basemap contains the rendered view.

you can change the value (i used 5) for the float i loop. depends how fast you want it. you can add different passes with different offsets to create more blur.

look out for "poisson" in context with blur. but i think that stuff already is somewhere here.

also check out my page - there must be some usefull ressources for you.

good luck:)
Posted By: indiGLOW

Re: Is there a REAL Blur shader? - 03/23/05 19:43

Ok Ello, I stand corrected! I expanded my search dates and found more posts that mention blur shaders etc, but the only one that I felt had anything conclusive was infact the one that you posted, with some screens of the work you have clearly already done in this field! - So it seems the person I need to speak to and brain that i need to rape, is yours! lol

Considering I have already been speaking to you on PM this post is now rather redundant, but it did give me reason to actually explore and download some content from your site, which I am still looking at and trying to get as much info as possible. So not a complete waste of a post, although a little egg on my face with the searching. In all honesty what i did find, excluding your post, was not a lot of use to me, and seemed to be mostly people asking how to do it...

Maybe with a little help from you I could get the effect I am looking for and then share it here for everyone. Thanks for the help so far Ello, as always your help and guidance is appreciated.

oh and I just realised I didn't say "I have no idea how to use that code you posted, being a real shader noob", sry
Posted By: ello

Re: Is there a REAL Blur shader? - 03/23/05 19:46

and btw: matt posted his 24tap blur filter just in my last thread about using result of pixelshaders. you'll find that whithout me giving you the link. i am sure about that:)

give it a shot.
Posted By: indiGLOW

Re: Is there a REAL Blur shader? - 03/23/05 23:41

Well if I found the correct thread that you imply, it seems unconclusive, I simply dont understand where the code here & there are meant to go, how to use them. I struggle enough when I see a complete shader and have had mixed results applying them... certainly couldnt write one......

I guess these shader things are just out of my depth and I am sure most other people here maybe just look at the code you example, and know how to use it, unfortunatly I am not among those people

Thanks for your help anyway
Posted By: ello

Re: Is there a REAL Blur shader? - 03/24/05 00:21

well, since matt used the same name ("basemap") you can just copy and paste it (replace old pixelshader) to your current fx-file.. look here:
Code:
 
float4x4 matWorldViewProj;
float4 vecTime;

struct VS_OUTPUT
{
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
};

VS_OUTPUT mainVS(float4 Pos: POSITION, float2 iTPos : TEXCOORD0)
{
VS_OUTPUT Out;
// Clean up inaccuracies
Pos.xy = sign(Pos.xy);
Out.Pos = float4(Pos.xy, 0, 1);
Out.texCoord = float2(Pos.x,-Pos.y)*0.5-0.5;
return Out;
}

texture entSkin1;

sampler basemap = sampler_state
{
Texture = (entSkin1);
ADDRESSU = WRAP;
ADDRESSV = WRAP;
ADDRESSW = WRAP;
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};

float4 mainPS(float2 Tex: TEXCOORD0) : COLOR {

float4 Color=0;
float4 darken={0.025,0.025,0.025,1};

float2 tap1 = {Tex.x+0.008,Tex.y-0.008};
float2 tap2 = {Tex.x-0.008,Tex.y+0.008};
float2 tap3 = {Tex.x+0.008,Tex.y+0.008};
float2 tap4 = {Tex.x-0.008,Tex.y-0.008};

float2 tap5 = {Tex.x+0.008,Tex.y};
float2 tap6 = {Tex.x-0.008,Tex.y};
float2 tap7 = {Tex.x,Tex.y+0.008};
float2 tap8 = {Tex.x,Tex.y-0.008};

float2 tap9 = {Tex.x+0.016,Tex.y-0.016};
float2 tap10 = {Tex.x-0.016,Tex.y+0.016};
float2 tap11 = {Tex.x+0.016,Tex.y+0.016};
float2 tap12 = {Tex.x-0.016,Tex.y-0.016};

float2 tap13 = {Tex.x+0.016,Tex.y};
float2 tap14 = {Tex.x-0.016,Tex.y};
float2 tap15 = {Tex.x,Tex.y+0.016};
float2 tap16 = {Tex.x,Tex.y-0.016};

float2 tap17 = {Tex.x+0.032,Tex.y-0.032};
float2 tap18 = {Tex.x-0.032,Tex.y+0.032};
float2 tap19 = {Tex.x+0.032,Tex.y+0.032};
float2 tap20 = {Tex.x-0.032,Tex.y-0.032};

float2 tap21 = {Tex.x+0.032,Tex.y};
float2 tap22 = {Tex.x-0.032,Tex.y};
float2 tap23 = {Tex.x,Tex.y+0.032};
float2 tap24 = {Tex.x,Tex.y-0.032};

Color = tex2D( basemap, Tex.xy);

Color += tex2D( basemap, tap1);
Color += tex2D( basemap, tap2);
Color += tex2D( basemap, tap3);
Color += tex2D( basemap, tap4);

Color += tex2D( basemap, tap5);
Color += tex2D( basemap, tap6);
Color += tex2D( basemap, tap7);
Color += tex2D( basemap, tap8);

Color += tex2D( basemap, tap9);
Color += tex2D( basemap, tap10);
Color += tex2D( basemap, tap11);
Color += tex2D( basemap, tap12);

Color += tex2D( basemap, tap13);
Color += tex2D( basemap, tap14);
Color += tex2D( basemap, tap15);
Color += tex2D( basemap, tap16);

Color += tex2D( basemap, tap17);
Color += tex2D( basemap, tap18);
Color += tex2D( basemap, tap19);
Color += tex2D( basemap, tap20);

Color += tex2D( basemap, tap21);
Color += tex2D( basemap, tap22);
Color += tex2D( basemap, tap23);
Color += tex2D( basemap, tap24);

return ((Color)*darken)*0.5;

}
technique simpleBlur
{
pass noiseps2
{
ZENABLE = TRUE;
CullMode=0;
VertexShader = compile vs_2_0 mainVS();
PixelShader = compile ps_2_0 mainPS();
}
}



all you need to do is to include this fx-file into a material:
Code:

material mat_blur {
effect="howdidyounameyourfxfile.fx";
}


and apply this to a quad.mdl for example

and if you dont have a gforce5700 then you should probably get the blur you want
Posted By: Christoph_B

Re: Is there a REAL Blur shader? - 03/24/05 02:11

In Antwort auf:

and if you dont have a gforce5700 then you should probably get the blur you want





that's the sentence i dislike most in your post *having 5700*
Posted By: indiGLOW

Re: Is there a REAL Blur shader? - 03/24/05 03:10

Ok Ello I will do as you say and report back, according to info I have read it looks like my 9800Pro should support pixelshader 2, so if its used (and I would have no idea if it is) it should work...

Many thanks Ello
Posted By: indiGLOW

Re: Is there a REAL Blur shader? - 03/24/05 03:39

Ok with all that done, and assigned to one model in the scene, I just get a black screen now, game does not appear to play.

I am running Dx9.0c with the latest Ati Radeon 9800Pro 128Mb catalyst drivers, according to spec these shaders should run... well as I understand it, any ideas?
Posted By: ello

Re: Is there a REAL Blur shader? - 03/24/05 04:52

hmm, if you render a view to then models entSkin1 using bmap_for_entity(mdl,1) and apply the given shader to your model it should all work. if its black there is no texture ..
try the shader on any model and see if it blurs the skin..

dunno what is going on there
Posted By: indiGLOW

Re: Is there a REAL Blur shader? - 03/25/05 03:40

As i said in my mail, im gonna isolate it and test some more. probably me being a noob
Posted By: Grimber

Re: Is there a REAL Blur shader? - 04/01/05 09:11

here is a simple motion bluring I did in a test ( was testing something else, just ended up with the bluring by mistake)

no shaders or placing entities in front of a view or render to view/rendering to bmap used.



it was simply done with 2 views. each camera side by side about 20 quants apart. ( i used a simple model )

vec_for_vertex(temp,me,378);
vec_set(camera.x,temp.x);
camera.pan = player.pan;// right camera
vec_for_vertex(temp,me,408);
vec_set(camera2.x,temp.x);
camera2.pan = player.pan;// left camera

sort of like binocular vision that's unfocused ( human sight is binocular but we focus on a distant object normaly)

with camera2 set to transparent and alpha = 50;
you can get a bit more blur if you turn each cameras pan by .1 ish values such as

vec_for_vertex(temp,me,378);
vec_set(camera.x,temp.x);
camera.pan = player.pan +.1;
vec_for_vertex(temp,me,408);
vec_set(camera2.x,temp.x);
camera2.pan = player.pan-.1;

or you could set a focal vecter far out in front of both cameras and have both cameras turn to face it after adjustign for player.pan first.

this should make items at vector distance in focus and items that get realy close or far away blurry.

FPS you could do continual traces for setting focal point.
Posted By: indiGLOW

Re: Is there a REAL Blur shader? - 04/04/05 19:23

I have experimented with overlaying views, as well as applying a view to the skin of a model in front of the camera... So far the results are not what I am looking for, and mainly appear as a blurry ghost view... not really the effect that I was hoping for.

After some fiddling about with the above shader code and no results I took a step back and just tried to get some shaders to run, now thats working, I hope to revisit the above suggestions and try to get some better results.

I will post my findings as and when. Thanks for all the help guys.
© 2023 lite-C Forums