Star filter post process effect

Started by
2 comments, last by Meltac 11 years, 7 months ago
Hi guys

Is it possible to make a post process effect simulating a star filter (as known from real-world cameras) that only requires one single shader pass?

So far I've only found sources using 5 up to 24 passes, but since those topics alltogether are rather outdated I thought there might be some possibility to do this in one pass with Shader Model 5.

I'm talking only HLSL, so please no DirectX API function calls (D3D...) here.

Thank you in advance!
Advertisement
Yeah, but it's less efficient than multi-pass versions.
For a simple 1-pass blur filter of any shape/distrubution, just make a big array of 2D points, then in a loop, add each point to the current pixel's tex-coordinate, and fetch the value at that coord from the input texture. Sum all the fetched values together and divide by the number of samples.

e.g. If you wanted a gaussian blur, then the array should contain points in a gaussian distribution -- but if you want a star blur, the array should contain points in a star-shaped distribution. This is inefficient because you need a LOT of 2D points to get a noise-free result, but a modern PC GPU can handle it.

I'd probably just make a simple separate program to output your points, then copy&paste it's output into your HLSL code as an array. e.g. You could start by randomly plotting 100 points inside a square, and then deleting any that dont fall inside of your star pattern.
If you work in frequency space, you can convolve with arbitrary filter kernels in O(N) time since convolution in frequency space is just a multiplication. But of course means you need to use an FFT to convert to and from frequency space, which is complicated to implement and will have a runtime cost.
Ok, thanks guys. Will give it a try.

This topic is closed to new replies.

Advertisement