-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Frame independent earthquakes #278
base: master
Are you sure you want to change the base?
Conversation
…erval is passed Fixes: Bug #1554
I'll do some more detailed comparisons with the original effect once I have more time but this looks great so far. |
I have looked at it in more detail and your changes and am a bit uncomfortable with changing the effect even at low frame-rates, in particular removing the sine. Here are the quake commands used for the effects - I have left out damage because it doesn't have one set of parameters but randomizes them. Note that the third parameter really is a frequency rather than a period in the original - the parameter was just misnamed:
For the original effect it picks one new value per frame (so let's say every ~33ms for 30 FPS) but limits the random values by a sine wave based on the frequency. This sine has a period of
which is only 63ms for the "slowest" quake (spiderweb with frequency 10) but its still noticeable. It's true that for the giant worm and weapon hit the frequency is high enough that it is just a second (shitty) random but for the spiderweb it does add a bit of periodicity instead of just completely random shaking. Aliasing may also make the sampled value appear at a lower frequency than the original sine, not sure if that is happening here. Your effect on the other hand picks a new random offset with constant maximum at a fixed interval of
You also jump straight to the chosen value (since timeFromLastUpdate doesn't get reset) for one frame and then interpolate from 0 to the chosen random value for the remainder of the interval. Wouldn't it make more sense to keep the original effect but sample it at a fixed rate (e.g. 30 FPS) and then interpolate between two successive random values? Something like this:
This still isn't perfect because for frame-rates close to 30 we have very irregular updates and for frame-rates close to (a multiple of) the sine period the sample of the sine wave will have heavy aliasing to the point that it might look more like a constant. I'm not sure yet how to improve that. |
391b7f7
to
3d8a7e6
Compare
Attempted to replace the calculation with random values (looks about the same) because the old algorithm didn't really work when trying to update only once in a few milliseconds. The update period for intensity of 10 (scripted cobweb earthquake) is at 10ms but new values are chosen at the next function call so it looks fairly close even at 30fps with frame time of ~33ms.
Fixes: Bug #1554
Included are three save files that contain examples of quakes:
Scripted cobweb quake - AFAIK strongest in the game, short period
Giant worm - another scripted quake when the worm moves, weaker, longer period
Ylside bunker - one of the strongest hits from NPCs, long period
Let me know what you think of the look and feel.
saves.zip