• Create Account

# Bilateral Blur - CS Implementation

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

No replies to this topic

### #1~Helgon  Members   -  Reputation: 357

Like
0Likes
Like

Posted 07 December 2012 - 09:32 PM

Hey.

I have here a solution of a gaussian blur - implemented in the compute shader and now i want to implement a bilateral blur (filter) but i don't know where to start

The formula for gaussian blur in 1D is (the implementation is splitted in horizontal and vertical to be more efficient):

The formula for bilateral blur is:

The problem is that i don't know how to apply the values i have from the gaussian blur on the bilateral blur.

The Source of the gaussian blur shader is:

cbuffer cbSettings
{
float gWeights[11] =
{
0.05f, 0.05f, 0.1f, 0.1f, 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.05f, 0.05f,
};
};
cbuffer cbFixed
{
static const int gBlurRadius = 5;
};
Texture2D gInput;
RWTexture2D<float4> gOutput;
#define N 256
groupshared float4 gCache[CacheSize];
{
//
// Fill local thread storage to reduce bandwidth.  To blur
// N pixels, we will need to load N + 2*BlurRadius pixels
// due to the blur radius.
//

{
// Clamp out of bound samples that occur at image borders.
}
{
// Clamp out of bound samples that occur at image borders.
}
// Clamp out of bound samples that occur at image borders.
// Wait for all threads to finish.
GroupMemoryBarrierWithGroupSync();

//
// Now blur each pixel.
//
float4 blurColor = float4(0, 0, 0, 0);

[unroll]
{

}

}
{
//
// Fill local thread storage to reduce bandwidth.  To blur
// N pixels, we will need to load N + 2*BlurRadius pixels
// due to the blur radius.
//

{
// Clamp out of bound samples that occur at image borders.
}
{
// Clamp out of bound samples that occur at image borders.
}

// Clamp out of bound samples that occur at image borders.

// Wait for all threads to finish.
GroupMemoryBarrierWithGroupSync();

//
// Now blur each pixel.
//
float4 blurColor = float4(0, 0, 0, 0);

[unroll]
{

}

}


Even with the comments i feel very hard to follow. I'm totally not sure what values come from which calculus - so i also don't even have a idea how to implement it.

Maybe u can give me a hint whats exactly what or how i can approach the problem because i really don't get it by my own

Regards Helgon

Edit:

Some more questions

1) Almost every implementation of blurs i've found were done in the vertex shader. Is it really worth that "hard work" to do it in the CS? Of course its much quicker but is it such a huge difference? And if yes, why is it not done more often in the CS?

2) And another little question. Is the CS used often in game developing or is it more used by rendering softwares / mathematical applications?

Edited by ~Helgon, 07 December 2012 - 09:41 PM.

from time to time i find time