Skip to content

Commit

Permalink
feat(draw): make the motion blur amount adjustable
Browse files Browse the repository at this point in the history
  • Loading branch information
yvt committed Jan 16, 2021
1 parent 6b54ce0 commit 4da14fc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Sources/Draw/GLCameraBlurFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ namespace spades {
return acosf(v);
}

GLColorBuffer GLCameraBlurFilter::Filter(GLColorBuffer input, float radialBlur) {
GLColorBuffer GLCameraBlurFilter::Filter(GLColorBuffer input, float intensity,
float radialBlur) {
SPADES_MARK_FUNCTION();

if (radialBlur > 0.f)
Expand Down Expand Up @@ -114,7 +115,7 @@ namespace spades {
}

float movePixels = MyACos(diffMatrix.m[0]);
float shutterTimeScale = .3f;
float shutterTimeScale = intensity;
movePixels = std::max(movePixels, MyACos(diffMatrix.m[5]));
movePixels = std::max(movePixels, MyACos(diffMatrix.m[10]));
movePixels = tanf(movePixels) / tanf(def.fovX * .5f);
Expand Down
2 changes: 1 addition & 1 deletion Sources/Draw/GLCameraBlurFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace spades {

public:
GLCameraBlurFilter(GLRenderer *);
GLColorBuffer Filter(GLColorBuffer, float radialBlur = 0.f);
GLColorBuffer Filter(GLColorBuffer, float intensity, float radialBlur = 0.f);
};
}
}
7 changes: 6 additions & 1 deletion Sources/Draw/GLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,14 @@ namespace spades {
}

if (settings.r_cameraBlur && !sceneDef.denyCameraBlur) {
if (!cameraBlur) {
cameraBlur = new GLCameraBlurFilter(this);
}

GLProfiler::Context p(*profiler, "Camera Blur");
// FIXME: better (correctly constructed) radial blur algorithm
handle = cameraBlur->Filter(handle, sceneDef.radialBlur);
handle = cameraBlur->Filter(
handle, std::min(settings.r_cameraBlur * 0.2f, 1.0f), sceneDef.radialBlur);
}

if (settings.r_bloom) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Draw/GLSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace spades {

TypedItemHandle<bool> r_blitFramebuffer { *this, "r_blitFramebuffer" };
TypedItemHandle<bool> r_bloom { *this, "r_bloom" };
TypedItemHandle<bool> r_cameraBlur { *this, "r_cameraBlur", ItemFlags::Latch };
TypedItemHandle<float> r_cameraBlur { *this, "r_cameraBlur" };
TypedItemHandle<bool> r_colorCorrection { *this, "r_colorCorrection" };
TypedItemHandle<bool> r_debugTiming { *this, "r_debugTiming" };
TypedItemHandle<bool> r_debugTimingOutputScreen { *this, "r_debugTimingOutputScreen" };
Expand Down

0 comments on commit 4da14fc

Please sign in to comment.