From ca4bffe34db82dc91286766ac7f3ce67fcc8612a Mon Sep 17 00:00:00 2001 From: auria Date: Wed, 10 Aug 2011 01:46:58 +0000 Subject: [PATCH] Use funto's motion blur effect only when using a zipper, but more visibly so git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9456 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/graphics/camera.cpp | 6 ------ src/graphics/irr_driver.cpp | 2 ++ src/graphics/post_processing.cpp | 15 +++++++++++++-- src/graphics/post_processing.hpp | 6 ++++-- src/karts/controller/player_controller.cpp | 4 ++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp index 98346d64c..9edd5a891 100644 --- a/src/graphics/camera.cpp +++ b/src/graphics/camera.cpp @@ -402,9 +402,6 @@ void Camera::getCameraSettings(float *above_kart, float *cam_angle, */ void Camera::update(float dt) { - // Initially, disable motion blur - irr_driver->getPostProcessing()->setCameraSpeed(0.0f); - // The following settings give a debug camera which shows the track from // high above the kart straight down. if(UserConfigParams::m_camera_debug) @@ -447,9 +444,6 @@ void Camera::update(float dt) m_camera->setTarget(current_target); return; } - - // Apply the motion blur according to the speed of the kart - irr_driver->getPostProcessing()->setCameraSpeed(m_kart->getSpeed()); positionCamera(dt, above_kart, cam_angle, side_way, distance, smoothing); } // update diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 107551bff..7eb194129 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -1373,6 +1373,8 @@ void IrrDriver::update(float dt) m_video_driver->endScene(); + getPostProcessing()->update(dt); + // Enable this next print statement to get render information printed // E.g. number of triangles rendered, culled etc. The stats is only // printed while the race is running and not while the in-game menu diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index 2b2465366..c3bd0b709 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -101,6 +101,15 @@ void PostProcessing::endCapture() irr_driver->getVideoDriver()->setRenderTarget(0, true, true, 0); } +void PostProcessing::update(float dt) +{ + if (m_boost_amount > 0.0f) + { + m_boost_amount -= dt*5.0f; + if (m_boost_amount < 0.0f) m_boost_amount = 0.0f; + } +} + /** Render the post-processed scene */ void PostProcessing::render() { @@ -126,9 +135,11 @@ void PostProcessing::render() } /** Set the boost amount according to the speed of the camera */ -void PostProcessing::setCameraSpeed(float cam_speed) +void PostProcessing::giveBoost() { - m_boost_amount = core::clamp(MOTION_BLUR_FACTOR * (cam_speed - MOTION_BLUR_OFFSET), 0.0f, 1.0f); + m_boost_amount = 5.0f; + //printf("setCameraSpeed(%f)\n", cam_speed); + //m_boost_amount = core::clamp(MOTION_BLUR_FACTOR * (cam_speed - MOTION_BLUR_OFFSET), 0.0f, 1.0f); } /** Implement IShaderConstantsSetCallback. Shader constants setter for post-processing */ diff --git a/src/graphics/post_processing.hpp b/src/graphics/post_processing.hpp index 4ed656d36..dc8e6225f 100644 --- a/src/graphics/post_processing.hpp +++ b/src/graphics/post_processing.hpp @@ -48,14 +48,16 @@ public: void beginCapture(); void endCapture(); + void update(float dt); + /** Render the post-processed scene */ void render(); /** Is the hardware able to use post-processing? */ inline bool isSupported() const {return m_supported;} - /** Set the boost amount according to the speed of the camera */ - void setCameraSpeed(float cam_speed); + /** Use motion blur for a short time */ + void giveBoost(); /** Implement IShaderConstantsSetCallback. Shader constants setter for post-processing */ virtual void OnSetConstants(video::IMaterialRendererServices *services, s32 user_data); diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/player_controller.cpp index ade4d7b62..943e764be 100644 --- a/src/karts/controller/player_controller.cpp +++ b/src/karts/controller/player_controller.cpp @@ -387,6 +387,10 @@ void PlayerController::handleZipper(bool play_sound) { m_wee_sound->play(); } + + // Apply the motion blur according to the speed of the kart + irr_driver->getPostProcessing()->giveBoost(); + } // handleZipper //-----------------------------------------------------------------------------