Simple Realization of motion blur effect

Source: Internet
Author: User

When an object moves fast, the human eye will feel blurred. the same phenomenon exists in movies and photos. the reason for this is that the human eye does not receive information infinitely fast, but captures a picture every very short time. If the moving speed of an object exceeds the speed captured by the human eye, the object will be striped. understanding the effects in the real world will help us to implement them using computers. the ideal method is to determine the moving speed of each pixel between two adjacent frames, and process the data again. this solution is feasible, but a little complicated. another method is to mix the current frame with the previous frame without considering the moving speed of the object. this is just an approximate effect and has been widely used in today's video games. motion Blur screen effects can be achieved in two ways: one is to simulate motion blur in reality, and the other is to reduce the effect of sawtooth in rendering, especially when hardware does not support anti-sawtooth, this is a cheap alternative. Implementation principle:1. first render the scene to a rendertarget1 2. mix rendertarget1 with the rendering result of the previous frame and output it to rendertarget23. output rendertarget2 to the screen and save it to the next frame for mixing. For details, see: Shader Implementation
Two passteapot passes render the scenario to basescenert normally. blurpass is mixed and output to bluredrt. Note that here, bluredrt is used as texture1 to input the result of the previous frame. Therefore, the settings are not cleared during rendering. A proportional value blur_factor is required for interpolation during mixing. Here I set it to 0.5pixelshader code:Sampler2dTexture0;Sampler2dTexture1;FloatBlur_factor;Float4Ps_main (float2 texcoord: texcoord0): Color {Float4Color1 =Tex2d(Texture0, texcoord );Float4Color2 =Tex2d(Texture1, texcoord); // InterpolationReturn Lerp(Color1, color2, blur_factor);} Finally, output the bluredrt to the screen. (We should add a pass here. I am lazy and directly display the bluredrt to the window to see the effect)
Drag an object quickly to see the effect ^ _ ^:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.