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 Car Insurance Quotes Online on 16 de janeiro de 2017 - 5:57 pm

    How do you build a blog or a blog webpage?

  2. #2 by http://guenstigerkreditonline.net/kredit-azubi-geld-falten.html on 16 de janeiro de 2017 - 7:06 pm

    Kudos! What a neat way of thinking about it.

  3. #3 by Best Selling Vibrator on 16 de janeiro de 2017 - 9:04 pm

    very couple of web-sites that come about to be detailed beneath, from our point of view are undoubtedly well worth checking out

  4. #4 by kredit ausland ohne pruefung beispiel on 16 de janeiro de 2017 - 9:14 pm

    Shoot, who would have thought that it was that easy?

  5. #5 by hausbau kredit erfahrungen on 16 de janeiro de 2017 - 9:21 pm

    With havin so much content do you ever run into any problems of plagorism or copyright infringement? My blog has a lot of unique content I’ve either created myself or outsourced but it looks like a lot of it is popping it up all over the internet without my permission. Do you know any solutions to help protect against content from being stolen? I’d really appreciate it.

  6. #6 by http://privaterkreditvergleich.top/autokredit-cc-bank-mega.html on 16 de janeiro de 2017 - 9:29 pm

    You’ve managed a first class post

  7. #7 by sofortkredit arbeitslos reise ägypten on 16 de janeiro de 2017 - 10:21 pm

    Intelligence and simplicity – easy to understand how you think.

  8. #8 by guenstig gebrauchtwagen kredit rechner on 16 de janeiro de 2017 - 11:20 pm

    That’s a cunning answer to a challenging question

  9. #9 by Free Legal Advice on 17 de janeiro de 2017 - 12:21 am

    As I website possessor I believe the content matter here is rattling excellent , appreciate it for your efforts. You should keep it up forever! Good Luck.

  10. #10 by anal beginner on 17 de janeiro de 2017 - 12:35 am

    just beneath, are various totally not connected sites to ours, having said that, they’re certainly really worth going over

  11. #11 by ロレックス 偽物 ダイヤ eps on 17 de janeiro de 2017 - 12:38 am

    ルイヴィトンコピー長財布
    日本国内最高級のルイヴィトン財布コピー通販専門店です!
    卸売各種ルイヴィトン財布スーパーコピー,ルイヴィトン、グッチ、
    当サイト販売した偽物ルイヴィトンなので 正規品と同等品質提供した激安で完璧な品質のをご承諾します!
    ルイヴィトンコピー長財布
    ★信用良い、品質良い、価格激安
    ★弊社の全てのグッチ財布コピーは品質保証と到着保障があります。
    ロレックス 偽物 ダイヤ eps http://kopii.net/products/p1/1/3/index.htm

  12. #12 by ロレックス オーバーホール 割引 on 17 de janeiro de 2017 - 12:38 am

    N品ブランドスーパーコピー通販専門店
    ルイヴィトン、シャネル、グッチ、
    ロレックス、バレンシアガ、エルメス、
    コーチ、ブラダ、クロエ大激売中
    ブランド腕時計、バッグ、財布、小物専売店

    ◆主要取扱商品 バッグ、財布、腕時計、ベルト!
    ◆全国送料一律無料
    ◆信用第一、良い品質、低価格は 私達の勝ち残りの切り札です。
    ◆当社の商品は絶対の自信が御座います。
    おすすめ人気ブランド腕時計, 最高等級時計大量入荷!
    ◆N品質シリアル付きも有り 付属品完備!
    ◆新品種類がそろっています。 品質がよい、価格が低い、実物写真!

    営業時間:年中無休
    ホームページ上でのご注文は24時間受け付けております
    ロレックス オーバーホール 割引 http://kopi356.com/category-67-b0.html

  13. #13 by ロレックス 偽物 時計 修理 on 17 de janeiro de 2017 - 12:38 am

    スーパーコピーブランドN級品専門店
    史上最も激安ブランドスーパーコピー-即日 配送可,100%入荷。
    当店は正規品と同等品質は品質3年保証でご注文から5 日でお届け致します。
    レディースとメンズ激安通販専門店!品質と本物は同様です。
    全て新品、高い品質、激安 、送料は無料です( 日本全国)すべての商品は品質2年無料保証です。
    ブランドコピー時計:
    ロレックス 偽物 時計 修理 http://bagshop78.com/brandcopy-m-172.html

  14. #14 by http://kostenloserkreditvergleich.net/kredit-nehmen-als-azubi.html on 17 de janeiro de 2017 - 12:53 am

    copy past yapamıyorum yafs niye ÅŸettin ki dermiÅŸim ben ne kadar çok yengecim demek(gerçi söylemiÅŸtindi ama ) acıyı kötülüğü hayatta unutmam.Fırsatını bırak asla olmicak olsa bile intikam hayalleri kuruyorm nasıllllllllllllll 😀

  15. #15 by android games for pc on 17 de janeiro de 2017 - 2:01 am

    F*ckin’ remarkable issues here. I am very happy to look your article. Thank you so much and i am taking a look ahead to contact you. Will you kindly drop me a e-mail?

  16. #16 by http://besterkreditvergleich.net/erfahrung-kredit-trotz-24.html on 17 de janeiro de 2017 - 2:44 am

    I’m impressed by your writing. Are you a professional or just very knowledgeable?

  17. #17 by Rapidash Pokemon on 17 de janeiro de 2017 - 3:25 am

    I loved as much as you’ll receive carried out right here. The sketch is attractive, your authored subject matter stylish. nonetheless, you command get got an nervousness over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this hike.

  18. #18 by kredit aufnehmen erfahrungen on 17 de janeiro de 2017 - 3:44 am

    I fought about getting some Church's Chicken tonight but decide on Panera's instead as for the soap… if it don't make my legs ashy like Ashy Larry, I might have to get a few bars

  19. #19 by Drowzee News on 17 de janeiro de 2017 - 3:59 am

    you’re really a good webmaster. The website loading speed is incredible. It seems that you’re doing any unique trick. In addition, The contents are masterpiece. you have done a great job on this topic!

  20. #20 by http://kostenloserkreditvergleich.net/kredit-negativ-eintrag-checken.html on 17 de janeiro de 2017 - 4:43 am

    Francisco • 2 de Agosto de 2010 às 11:52Eu também estou como o Fernando, devo ser dos subscritores mais antigos e nunca apareci sequer nos 10 primeiros!Não tenho sorte nenhuma nesta coisa de sorteios e afins…

1 210 211 212
(não será publicado)