Gaussian Blur

Started by
6 comments, last by Hodgman 13 years, 9 months ago
Ive lernt how to apply a simple vertex/pixel shader to the scene. As in setup the shader device and set the shader ect...

Are there any Gaussian Blur shaders out there that can blur but not at full Opacity. Ive seen blur shaders that completly blur a model. But im trying to create a dreamy kind of effect. So I need the blur to be applied and then the blurred mesh to be semi transparent.
So basicly the rendering would go like:


DrawMesh

SetBlurShader
SetOpactiy to 35%
DrawMesh


Is something like this possible? And how can I set the opacity of the mesh down?

or is my thinking completely wrong and there is a completely differnt method of doing this.

The end product should look like this (photoshoped):
http://img293.imageshack.us/img293/4648/27438825.jpg
Advertisement
Hi,

This effect should be quite easy to achieve. A gaussian blur works by blurring horizontally in the first pass then vertically in the second pass. There are plenty of examples on the net of shaders that do this. To do what you'd want to do you'd have to keep a copy of the original image so instead of drawing the first pass onto the original image draw it onto a seperate image. Then input both the original and the seperate horizontally blurred image to the second pass. Then in the second pass you would blur the blurred image vertically then sample the original unblurred image and use these two values to determine the output.

Something like this for the return:

return (blurredValue * 0.35f) + (originalValue * 0.65f);
Portfolio & Blog:http://scgamedev.tumblr.com/
Wouldnt that still blur the whole image?
The tree in your picture doesn't look blurred - do you have another example, or can you explain specifically what it is in that picture you're trying to achieve?
From that what I see on your picture, Darg's method should be what you want.
i dont understand what darg means with "on first pass" or "on second pass". And I defently dont know anything about output values. All I know is how to load up a shader from a .vsh or .psh and set it active with d3ddevice->setpixelshader(shader)
I'm not sure if I can describe it better, without you knowing more about shaders. To do what I said you'd have to write your own shader, like I said a guassian blur shader is quite simpler and there are plenty of examples around.

Basically there are the two passes, horizontal and vertical. A normal gaussian blur will do the horizontal pass then do the vertical pass on the result of the first pass. If you imagine a set of pixels like this:

00000
00000
00900
00000
00000

The horizontal pass would give you something like this:

00000
00000
23632
00000
00000

Then the vertical pass would give you something like this:

00100
01210
12421
01210
00100

The values are pretty much pulled straight out of my nether regions but it gives you the general idea. The horizontal pass samples the adjacent pixels along the x-axis and the vertical samples pixels along the y-axis (i,j axes if you prefer for image processing).

What you want, if I understand your original post correctly is for the original values to be mostly kept with just a mostly transparent blur so the end result would actually be more like this:

00000
00100
01710
00100
00000

The way I described in my previous post would be the more efficient way of doing this. However if you just want to use one set guassian shader without writing your own then what you could do is something like this:

Render to texture1;
texture2 = texture1;
texture1 = guassian(texture1);
texture1 = copy(texture1, texture2, 0.65f);

Where the copy method would take the two textures and get a weighted average based on the third parameter (0.65f in this case). This would end up with the same result as my previous post but with an added third pass to copy the two textures.

If this isn't what you want to achieve then you'll have to be a bit clearer in exactly what you want.
Portfolio & Blog:http://scgamedev.tumblr.com/
Quote:Original post by Tingle
i dont understand what darg means with "on first pass" or "on second pass". And I defently dont know anything about output values. All I know is how to load up a shader from a .vsh or .psh and set it active with d3ddevice->setpixelshader(shader)
I think you're imagining rendering your object with a "blur shader"? Darg is describing blur as a post-process effect -- you render your object as usual, and then you blur the screen afterward. Implementing a per-object blur would be a bit more complex that this regular approach to "blur shaders".

This topic is closed to new replies.

Advertisement