mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-26 18:22:33 +08:00
make motion blur's blur radius consistent across different framerates
This commit is contained in:
@ -14,6 +14,7 @@ varying vec2 texcoord;
|
|||||||
uniform vec2 texelSize;
|
uniform vec2 texelSize;
|
||||||
uniform float frameTimeCounter;
|
uniform float frameTimeCounter;
|
||||||
uniform int frameCounter;
|
uniform int frameCounter;
|
||||||
|
uniform float frameTime;
|
||||||
uniform float viewHeight;
|
uniform float viewHeight;
|
||||||
uniform float viewWidth;
|
uniform float viewWidth;
|
||||||
uniform float aspectRatio;
|
uniform float aspectRatio;
|
||||||
@ -91,7 +92,10 @@ vec3 doMotionBlur(vec2 texcoord, float depth, float noise, bool hand){
|
|||||||
vec2 velocity = texcoord - previousPosition.xy;
|
vec2 velocity = texcoord - previousPosition.xy;
|
||||||
|
|
||||||
// thank you Capt Tatsu for letting me use these
|
// thank you Capt Tatsu for letting me use these
|
||||||
velocity = (velocity / (1.0 + length(velocity)) ) * 0.05 * blurMult * MOTION_BLUR_STRENGTH;
|
velocity /= 1.0 + length(velocity); // ensure the blurring stays sane where UV is beyond 1.0 or -1.0
|
||||||
|
velocity /= 1.0 + frameTime*1000.0; // ensure the blur radius stays roughly the same no matter the framerate
|
||||||
|
velocity *= blurMult * MOTION_BLUR_STRENGTH; // remove hand blur and add user control
|
||||||
|
|
||||||
texcoord = texcoord - velocity*(samples*0.5 + noise);
|
texcoord = texcoord - velocity*(samples*0.5 + noise);
|
||||||
|
|
||||||
vec2 screenEdges = 2.0/vec2(viewWidth, viewHeight);
|
vec2 screenEdges = 2.0/vec2(viewWidth, viewHeight);
|
||||||
|
Reference in New Issue
Block a user