Forum

Framedelay shader linear color interpolation

hi all,

I need to interpolate between individual frames of a textureA player. atm I use a framedelayed textureB and a shader which lerps (A, B, 0.85). This works but produces a logarithmic transition on my textureO output.

I tried using conditions like: if B.r > A.r then O.r = B.r + 0.002
This would be linear but the problem is that I never manage to hit the exact value of the incoming texture, and my output starts flickering because each frame the value will be slightly too high or too low. Is there a “iteration” value which would work or is this a precision problem?

test.zip (5.5 KB)

maybe there is a texturefx I overlooked?
Any tips appreciated!

not sure what you up to, but i think that would be more correct:

framedaly tex.zip (7.0 KB)

Hi,

thanks for having a look at it! If I use Lerp and a fixed interpolation value within a texture loop it produces a non linear transition:

lerp(0,1,0.5) = 0.5
lerp(0,0.5,0.5) = 0.25
lerp(0,0.25,0.5) = 0.125

I want them to change like:
1.0 -> 0.75 -> 0.5 -> 0.25 -> 0.0

The nasty if loop would do this, but then I run into a problem when my value slightly over/under shoots the target. frame A.r = 0.1; frame B.r = 0.6; Value +/- within loop = 0.2
So I get: 0.1 -> 0.3 -> 0.5 -> 0.7 -> 0.5 -> 0.7 -> 0.5 …

I have tried tweaking my adding/subtracting value. I guess it’s because precision goes back to 8bit as soon as I output and loop the texture. I could adjust the lerp’s interpolation value during the transition to get a linear transition…

Didn’t get what you get there, but I guess problem that you dealing with feedback and so if you say 0.25 this frame next frame it will be previous frame result + equation you are using 0.25… to make this consistent you should consider frame rate, i think the ratio formula is something 1 / actual frame rate * by your ratio (0.25 in this case)… so then you get some consistent behaviour…

What I mean is that you’re equation is correct during pretty much one frame, and on next frame it would be also correct but not what you’d expect, specially if you’re frame rate is changing. First you have to define something constant… like amount you want to travel per second…

Also the lerp is working pretty much like that:
lerp(x,y,a)

would be:
x * (1 - a) + y * a
So:
lerp(0,0.5,0.5) = 0.25
0* (1 - 0.5) + 0.5 * 0.5 = 0.25

I see your point… seems there is no way around controlling the interpolation value in between the transition of one frame to the next… I will try that. thx!