pouët.net

Go to bottom

Somewhat Realistic Camera Shake Tracks

category: code [glöplog]
 
BB Image

Need a "shakycam" for your demo but the good old sin-cos-mess just doesn't cut it anymore? Today's your lucky day!

Somewhat Realistic Camera Shake Tracks is a public release of the camera shake data and code used in the demo A New World Awaits.

It's basically some animation data with C++ code to load it in and play it back.

Get it at https://peisik.untergrund.net/camera_shakes/
added on the 2021-07-12 13:40:15 by cce cce
Nice :)
standard shadertoy textures coming in 3... 2....
added on the 2021-07-12 21:57:30 by ferris ferris
cce: Nice, but could you maybe also share some info about how these datasets were created in the first place? Are they generated or captured?
added on the 2021-07-12 22:12:37 by kusma kusma
Doh, you already explained that on the webpage, silly me.
added on the 2021-07-12 22:13:34 by kusma kusma
There seems to be a problem with the CSV dumps, where delta_x and delta_y are always the same...?
added on the 2021-07-12 22:52:24 by kusma kusma
Quote:
There seems to be a problem with the CSV dumps, where delta_x and delta_y are always the same...?

Sorry about that. They are fixed now.

Quote:
standard shadertoy textures coming in 3... 2....

What a brilliant idea. If every track was limited to 1024 frames you could pack them all in a neat 1024x4 RGBA texture. Just 8 bits per channel might be enough if encoded as XYM where M is the scale (think RGBM). Roll could be stuffed in the alpha channel and biased so that it could also be linearly interpolated. I'm definitely going to try this at some point.
added on the 2021-07-13 11:38:50 by cce cce
After analyzing the data (just the x and y offsets, but I wouldn't be surprised if roll follows a similar pattern), a few observations can be made:

  • The X and Y offsets seems to be somewhat similar; we rarely see both large x-offsets and large y-offsets. It does happen, but much less often than large X and Y alone.
  • The DCT of the X and y offsets seems to have two signals:
  • One "ambient" that looks like noise modulated with an exponential falloff (exp(-x) style)
  • One spike around a given step frequency. This one seems like shifts a bit back and forth, but not much. It's also obviously missing from the still-standing dump.
  • Plotting the x and y offsets together shows what looks mostly like a brownian motion curve, that constantly gets pulled towards the center.
  • Strangely enough, both the x and y offsets seems to have a bias towards positive values. This seems like it might be just a problem with the relatively small datasets, or maybe an error in the measurements.
  • [/list]

    What does this mean? Well, I suspect that it's possible to generate datasets that are indistinguishable from the real ones, and might allow more parameters. Yay, more sin/cos mess? :D

    But I guess analyzing the roll data needs some work first.
    added on the 2021-07-14 14:51:16 by kusma kusma
    float strength = 20.0; // Michael J. Fox mode
    Thank you for your analysis, kusma. Synthesizing this kind of shake data shouldn't be that hard and I'd love to have a compact formula that looks good. Perhaps just having roughly the correct frequencies and some kind of roll component is real enough.

    That last point about a positive bias is definitely bug. The new version 5 is now centered before processing which looks OK. Crossfade was also kinda broken so that's smoother now too. Note that the CSV files also have the crossfade applied to the final 30 frames which might subtly affect the frequency response.

    ---

    I went and added that RGB texture version of the animation data. You can see in this live demo that it looks pretty OK. I just quantized the data without anything fancy and the absolute errors don't seem that bad:

    Code:max_x_error 0.586130 pixels max_y_error 0.525709 pixels max_roll_error 3.66937529786894e-08 degrees mean_x_error 0.291821 pixels mean_y_error 0.264604 pixels mean_roll_error 7.474555236434156e-09 degrees


    The image tracks/1024.png is easy to decode in GLSL. There's also an "applyShake(dir, shake)" helper function just like in the C++ version. I've noticed that it's fun to boost the roll component to get a more dynamic movement :)
    added on the 2021-07-14 19:04:35 by cce cce

    login

    Go to top