Real Time Motion Blur with GLSL & MD5 perframe Tangents.

Started by
3 comments, last by sonka 16 years, 5 months ago
Hi! I've seen real time motion blur in work in the Crysis demo, and I decided to (somehow) implement it to my engine. I read the article about it on developer.nvidia.com and downloaded the source, but it uses CG shaders. I cannot really understand how to bind shaders. First, I have to get the velocity vectors for the velocity texture, and it is calculated while the original screen is being rendered. But what is the output? I mean okay, I bind the shader, but how I put the calculated velocity texels to the velocity texture? And the other question is: do I have to do the velocity calculation and the bumpmapping, etc. in one shader? (My english is not too good, so here's a pseudo code for what I meant: ) bindshader(velocityCalculator) bindshader(bumpmapping) /* Two shaders cannot be bound at a time so: first problem */ renderModels/world/etc(); bindshader(0); /* Now this point I should have a texture of the original screen, and a texture of the velocities, shouldn't I? */ bindshader(motionBlur); renderScreenTexture(); bindshader(0); Or do I misunderstood the whole thing? And is it possible to do it with GLSL? By the way, could somebody write just a simple formula to rotate tangent and normal vectors of an MD5 model per frame? The rotating the normal by the joint's orient of the weight doesn't really work. :S Thank you for your help!
Advertisement
Just help me with the motion blur, please! I even don't how to start. I'm using framebuffer objects to render the full screen to a texture (currently with CSAA) and.. so that's it, I don't know where to start. The presentation on the nVidia site doesn't give much information about implementing it. I don't know if it can be done with GLSL, because the fragment and vertex shaders (as I know) cannot be bound alone (I mean not together).
Quote:Original post by sonka
Just help me with the motion blur, please! I even don't how to start. I'm using framebuffer objects to render the full screen to a texture (currently with CSAA) and.. so that's it, I don't know where to start. The presentation on the nVidia site doesn't give much information about implementing it. I don't know if it can be done with GLSL, because the fragment and vertex shaders (as I know) cannot be bound alone (I mean not together).


I'd suggest taking a step back and working on the parts of the algorithm first. Like fully understanding how to write a fragment and vertex shader and how to make use of it in your pipeline when doing multiple passes with different fragment shaders (assuming you haven't done this already). Then work on exactly how you want to compute your per pixel velocities (assuming a 2D screen space blur), then workout on how you want to do your blurring.

Note, there are many ways to do motion blur. Image space post processing is just one method which can be implemented in many many ways. You can also combined this with geometry stretching. For example I use geometry stretching only (since I am compositing alpha blended motion stretched billboards, I don't have to post blur). For example here is one with little motion,



Then another of another scene with some objects rotating around the screen and some moving slowly,



Anyway motion blur is a complex problem. You might want to start by reading Chapter 27 "Motion Blur as a Post-Processing Effect" in GPU Gems 3. It shows a relatively simple method based on view change alone, with some hints on how to expand it to handle the general case of moving objects as well.
_|imothy Farrar :: www.farrarfocus.com/atom
Quote:Original post by TimothyFarrar
Note, there are many ways to do motion blur. Image space post processing is just one method which can be implemented in many many ways. You can also combined this with geometry stretching. For example I use geometry stretching only (since I am compositing alpha blended motion stretched billboards, I don't have to post blur). For example here is one with little motion,



Then another of another scene with some objects rotating around the screen and some moving slowly,



Anyway motion blur is a complex problem. You might want to start by reading Chapter 27 "Motion Blur as a Post-Processing Effect" in GPU Gems 3. It shows a relatively simple method based on view change alone, with some hints on how to expand it to handle the general case of moving objects as well.


/offtopic: I have no idea what those are meant to be, but they are beautiful!

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Thank you for your reply TimothyFarrar, but I finally found an example, and I realized that I misunderstood something: When calculating the velocities, the output is the color of the geometry. I thought the color directly goes to a texture. Since I realized that, I could make an algorithm:
1. bind velocityTexture fbo
2. active velocity shader and block the other shaders
3. render geometry
4. unbind velocityTexture fbo

Now I have the velocities in velocityTexture.

1. bind renderTexture fbo
2. render geometry with original shaders
3. unbind renderTexture fbo

Finally I just have to render the screen it using the motion blur shader.
1. bind motion blur shader
2. uniformtextures renderTexture, velocityTexture
3. unbind motion blur shader

It looks very cool :]

This topic is closed to new replies.

Advertisement