Reputation: 350
I need your help about implementing slow trasition effect in fragment shader. For example I've DOF effect which is controlled by mouse. Changing of x,y position attracts of changing of depth of variable.
depth = linearize(texture(dofTexture,vec2 mouse).x)
How to slow down a changing of depth at instant changes of mouse? Another words, how to smooth of transition between states into fragment shader? Do I need to use exterior uniforms?
Upvotes: 3
Views: 2143
Reputation: 2524
You could use linear interpolation between what you could decide as being "keyframes". You would just require the time past since the last keyframe (between 0 and 1) and the associated texture of it (time and texture would hence be additional uniforms).
Then the color of your fragment would be something like mix(keyframe_color, actual_color, elapsed_time)
(the linear interpolation just being a c = (t - 1) * a + t * b
)
Upvotes: 1