1
Graphics / PostFX motion blur code snippets/tutorial
« on: June 04, 2010, 04:56:40 pm »
Hmmm motion blur occurs only in debug build. In release, the blur effect is not visible at all. However, if I temporarily hard code the sfx file by multiplying the blurred texture component with 1, the effect is seen albeit with full opacity. Any ideas? Maybe I'm clearing and copying the image in the wrong orders? Frame rate related?
Code: [Select]
sf::PostFX Effect;
if (!Effect.LoadFromFile("blur.sfx"))
return EXIT_SUCCESS;
// Setup the effect parameters
Effect.SetTexture("framebuffer", NULL);
// image for postfx motion blur blending
sf::Image image;
// Start game loop
while (App.IsOpened())
{
// Game logic, moving stuff
...
// First clear screen
App.Clear();
// Draw postfx motion blur first
App.Draw(Effect);
// Draw game stuff
...
// Copy window contents as image, set the texture and apply blurriness
image.CopyScreen(App);
Effect.SetTexture("blurred", &image);
// Draw hud overlays
...
// Finally display window contents on screen
App.Display();
}
blur.sfx
texture framebuffer
texture blurred
effect
{
vec4 c0 = framebuffer(_in);
_out = (c0 * 0.5f) + (blurred(_in) * 0.5f);
}