Jump to content

  • Log In with Google      Sign In   
  • Create Account


Star filter post process effect


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.

  • You cannot reply to this topic
3 replies to this topic

#1 Meltac   Members   -  Reputation: 376

Like
0Likes
Like

Posted 31 August 2012 - 03:19 AM

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!

Edited by Meltac, 31 August 2012 - 03:20 AM.


Sponsor:

#2 Hodgman   Moderators   -  Reputation: 29747

Like
1Likes
Like

Posted 31 August 2012 - 04:24 AM

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.

#3 MJP   Moderators   -  Reputation: 11038

Like
1Likes
Like

Posted 31 August 2012 - 12:38 PM

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.

#4 Meltac   Members   -  Reputation: 376

Like
0Likes
Like

Posted 31 August 2012 - 01:45 PM

Ok, thanks guys. Will give it a try.




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.



PARTNERS