Skip to content

Commit

Permalink
Fake motion blur + some post-process tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
kraifpatrik committed Apr 19, 2024
1 parent 032a779 commit 9af91af
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
18 changes: 14 additions & 4 deletions objects/OMain/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,32 @@ renderer.add(global.terrain); // Call terrain's `render` automatically
// Add post-processing effects
//
postProcessor = new BBMOD_PostProcessor();
// Note: This is a small bias and it's going to cause fireflies!
postProcessor.add_effect(new BBMOD_LightBloomEffect(new BBMOD_Vec3(-0.2)));
renderer.PostProcessor = postProcessor;

directionalBlur = new BBMOD_DirectionalBlurEffect();
postProcessor.add_effect(directionalBlur);

radialBlur = new BBMOD_RadialBlurEffect();
postProcessor.add_effect(radialBlur);

postProcessor.add_effect(new BBMOD_ExposureEffect());
postProcessor.add_effect(new BBMOD_GammaCorrectEffect());
postProcessor.add_effect(new BBMOD_LightBloomEffect(new BBMOD_Vec3(-1)));
postProcessor.add_effect(new BBMOD_ReinhardTonemapEffect());
postProcessor.add_effect(new BBMOD_GammaCorrectEffect());
postProcessor.add_effect(new BBMOD_LensFlaresEffect());
postProcessor.add_effect(new BBMOD_ColorGradingEffect(sprite_get_texture(SprColorGrading, 0)));
postProcessor.add_effect(new BBMOD_LumaSharpenEffect(2));
postProcessor.add_effect(new BBMOD_FilmGrainEffect(0.05));
postProcessor.add_effect(new BBMOD_ChromaticAberrationEffect(4));
postProcessor.add_effect(new BBMOD_VignetteEffect(1));
postProcessor.add_effect(new BBMOD_FXAAEffect());
renderer.PostProcessor = postProcessor;

////////////////////////////////////////////////////////////////////////////////
//
// Create camera
//
z = 0;
zprevious = z;
camera = new BBMOD_Camera();
camera.Exposure = 2;
camera.FollowObject = self;
Expand Down Expand Up @@ -150,6 +159,7 @@ physicsWorld.align_terrain(global.terrain, terrainCollider);
// Create jeep
//
steering = 0;
velocity = new BBMOD_Vec3();
wheelInContact = array_create(4, false);

//
Expand Down
21 changes: 21 additions & 0 deletions objects/OMain/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ jeepLight2.Direction.Set(_lightDir.X, _lightDir.Y, _lightDir.Z).NormalizeSelf();
jeepLensFlare2.Position = jeepLight2.Position.Clone();
jeepLensFlare2.Direction = jeepLight2.Direction.Clone();

// Remember previous position
xprevious = x;
yprevious = y;
zprevious = z;

// Move this object to the jeep's position
x = _matrix[12];
y = _matrix[13];
Expand Down Expand Up @@ -112,3 +117,19 @@ if (camera.Position.Z < _cameraHeight)
// target after we call its update method.
camera.update_matrices();
}

////////////////////////////////////////////////////////////////////////////////
//
// Update blur strength
//
if (global.gameSpeed > 0)
{
velocity.Set(x - xprevious, y - yprevious, z - zprevious);
}

var _cam = camera.get_forward();
var _strength = clamp(velocity.Length() / 10, 0, 1);
var _absDot = abs(_cam.Dot(velocity.Normalize()));

directionalBlur.Vector.Set((1 - _absDot) * _strength * 64, 0);
radialBlur.Strength = _absDot * _strength;

0 comments on commit 9af91af

Please # to comment.