Motion Blur?
- Ioxa
- Topic Author
Please Log in or Create an account to join the conversation.
- crosire
I had the idea to provide access to previous frames in the future (not only the current one), so to calculate the difference between the two images, which then maybe could be used as a velocity replacement to create motion blur. But those are only ideas, I don't know if that would work out.
Please Log in or Create an account to join the conversation.
- Ioxa
- Topic Author
Please Log in or Create an account to join the conversation.
- crosire
Anybody remembering the motion blur in Need for Speed Most Wanted?
This one is actually very very simple to implement (it doesn't exactly look great, but oh well). It's a simple radial blur post-processing effect, nothing more.
Here's a radial blur implementation taken from here (note that it's a static effect of course, but still can look nice on screenshots or in motion):
static const float2 BLUR_CENTER = float2(0.5, 0.5); // center of the blur
static const float BLUR_START = 1.0f; // blur offset
static const float BLUR_WIDTH = -0.05; // blur size
static const int BLUR_SAMPLES = 10; // number of samples, more = higher quality, but bigger performance hit
texture colorTex : COLOR;
sampler colorSampler { Texture = colorTex; };
float4 RadialBlur(float4 pos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
texcoord -= BLUR_CENTER;
float4 color = float4(0, 0, 0, 0);
for (int i = 0; i < BLUR_SAMPLES; i++)
{
color += tex2D(colorSampler, texcoord * (BLUR_START + BLUR_WIDTH * (i / (float)(BLUR_SAMPLES - 1))) + BLUR_CENTER);
}
color /= BLUR_SAMPLES;
return color;
}
void VS(in uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD)
{
texcoord.x = (id == 2) ? 2.0 : 0.0;
texcoord.y = (id == 1) ? 2.0 : 0.0;
pos = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
technique RadialBlurTechnique < enabled = true; >
{
pass
{
VertexShader = VS;
PixelShader = RadialBlur;
}
}
Please Log in or Create an account to join the conversation.
- Paperboy
crosire wrote: While it's impossible to achieve "real" motion blur (which only affects moving objects) even with access to previous frames (I don't see a way to calculate pixel velocity just from color data, so what I said before doesn't make sense), there is another way, besides blending multiple frames together (no real motion blur either, though some people title this "motion blur" too).
Anybody remembering the motion blur in Need for Speed Most Wanted?
This one is actually very very simple to implement (it doesn't exactly look great, but oh well). It's a simple radial blur post-processing effect, nothing more.
Here's a radial blur implementation taken from here (note that it's a static effect of course, but still can look nice on screenshots or in motion):static const float2 BLUR_CENTER = float2(0.5, 0.5); // center of the blur static const float BLUR_START = 1.0f; // blur offset static const float BLUR_WIDTH = -0.05; // blur size static const int BLUR_SAMPLES = 10; // number of samples, more = higher quality, but bigger performance hit texture colorTex : COLOR; sampler colorSampler { Texture = colorTex; }; float4 RadialBlur(float4 pos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target { texcoord -= BLUR_CENTER; float4 color = float4(0, 0, 0, 0); for (int i = 0; i < BLUR_SAMPLES; i++) { color += tex2D(colorSampler, texcoord * (BLUR_START + BLUR_WIDTH * (i / (float)(BLUR_SAMPLES - 1))) + BLUR_CENTER); } color /= BLUR_SAMPLES; return color; }Warning: Spoiler!Some extra code which combined with the above creates a finished effect you can load into ReShade:void VS(in uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD) { texcoord.x = (id == 2) ? 2.0 : 0.0; texcoord.y = (id == 1) ? 2.0 : 0.0; pos = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0); } technique RadialBlurTechnique < enabled = true; > { pass { VertexShader = VS; PixelShader = RadialBlur; } }
How is the motion blur in ENB achieved, then? The old version detected camera rotation and velocity and applied a fullscreen directional or radial blur. The new version is depth buffer affected, and blurs things more the closer they are to the camera. It was gorgeous.
Please Log in or Create an account to join the conversation.
- Ganossa
Please Log in or Create an account to join the conversation.