Code Snippet: Radial Blur shader

This short code snipped will show how to make a simple radial blur as a post effect pass. The effect is cool and the code is preeeetty simple.

If you are in XNA, you can use it in spritebatch (make a shader with a pixel shader only, set it and call the classic spritebatch to draw the image) or you can use in DirectX, Opengl (minor changes)

sampler TextureSampler : register(s0);

float2 Center = { 0.5, 0.5 }; ///center of the screen (could be any place)
float BlurStart = 1.0f; /// blur offset
float BlurWidth = -0.1; ///how big it should be
int nsamples = 10;

float4 PS_RadialBlur(float2 UV	: TEXCOORD0 ) : COLOR
    UV -= Center;
    float4 c = 0;
    for(int i=0; i <nsamples; i++) {
    	float scale = BlurStart + BlurWidth*(i/(float) (nsamples-1));
    	c += tex2D(TextureSampler, UV * scale + Center );
   	c /= nsamples;
    return c;

Experiment changing the nsamples parameter. You can also put it as a uniform variable and force the compiler to unroll the for loop =P

Enjoy !


  1. #1 by Aire Serv Winnipeg on 22 de outubro de 2016 - 8:38 pm

    Great line up. We will be linking to this great article on our site. Keep up the good writing.

  2. #2 by anal sex on 22 de outubro de 2016 - 8:50 pm

    Here is a good Weblog You may Obtain Exciting that we Encourage You

  3. #3 by huk online evb nummer on 22 de outubro de 2016 - 9:45 pm

    Today, the world is witnessing just another example of how dictators prevail over peoples wish. USE OF FORCE. How degrading one could be if he had to beat up old women to remain in power. What type of a mindset would allow this? Today I am ashamed to be called im a Maldivian and a Muslim.

  4. #4 by on 22 de outubro de 2016 - 10:52 pm

    Nice post. I was checking constantly this blog and I’m impressed! Very useful info particularly the last part I care for such info a lot. I was looking for this particular info for a very long time. Thank you and good luck.

  5. #5 by kündigungsfrist kreditkarte sparkasse on 22 de outubro de 2016 - 11:52 pm

    This is a very useful article. Readers may be interested in our data-based article on writing abstracts (Hartley, J. & Betts, L., 2009, Common weakenesses in traditional abstracts in the social sciences, Journal of the American Society for Information Science and Technology, 60, 10, 210-2018) where we analyse 100 abstracts in social science journals, point out weakenesses, and provide (yet another) checklist for writing abstracts

  6. #6 by erfahrungen mit online krediten on 23 de outubro de 2016 - 12:38 am

    Thanks, Kathryn! You’re right, it does show when a book comes from the heart. I hope you enjoy this one. Pam, thanks again for your kind words on the previous version. Adding the ghost was fun. It was one of those revisions where you think, “This fits so well…why didn’t I think of it from the very beginning?”Cheers,Doreen

  7. #7 by on 23 de outubro de 2016 - 12:53 am

    If only there were more clever people like you!

  8. #8 by on 23 de outubro de 2016 - 1:08 am

    Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a bit, but other than that, this is excellent blog. A fantastic read. I will certainly be back.

  9. #9 byückseite.html on 23 de outubro de 2016 - 3:50 am

    What a pleasure to find someone who identifies the issues so clearly

  10. #10 by Cami Emanuele on 23 de outubro de 2016 - 5:14 am

    christmas shopping

  11. #11 by Colton Janoff on 23 de outubro de 2016 - 5:14 am

    prix cialis 20 mg

  12. #12 by Labouring Jobs Birmingham on 23 de outubro de 2016 - 5:57 am

    Perfect work you have done, this site is really cool with fantastic info .

  13. #13 by auto insurance quotes on 23 de outubro de 2016 - 6:27 am

    I just got done with Hunted,the fith book in the House of Night series. It was pretty good. It’s a vampire series.But I’m waiting for City of Glass by Cassandra Clare and Stargazer by Claudia Gray to come out the 24th.Ink Exchange was a really good book. Melissa Marr is an excellent writer. Lauren

  14. #14 by günstigste versicherung kurzzeitkennzeichen on 23 de outubro de 2016 - 8:07 am

    Wow! Great to find a post with such a clear message!

  15. #15 by parking przy lotnisku gdańsk on 23 de outubro de 2016 - 8:07 am

    fantastic post, very informative. I wonder why the opposite specialists of this sector don’t realize this. You must continue your writing. I am sure, you’ve a great readers’ base already!

  16. #16 by navigate to this web-site on 23 de outubro de 2016 - 8:07 am

    Wow! This could be one particular of the most beneficial blogs We ave ever arrive across on this subject. Actually Great. I am also an expert in this topic therefore I can understand your hard work.

  17. #17 by on 23 de outubro de 2016 - 9:34 am

    LE – you don’t have to maintain the proper functioning of the office printer or phone system – but if you did you might struggle with that too. The trick of software sellers is to pretend that we can use their products without any knowledge or experience.Just farm out the role to someone else is my advice.

  18. #18 by dogs on 23 de outubro de 2016 - 9:36 am

    I found your blog site on google and test a few of your early posts. Proceed to maintain up the superb operate. I just further up your RSS feed to my MSN Information Reader. In search of forward to studying more from you in a while!…

1 134 135 136
(não será publicado)