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 ^ _ ^: