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
Fixed screen twitches. #71
Conversation
Video sample (not mine): http://www.youtube.com/watch?v=ZUohifAbPW0
I haven't tested that, but removing sound code is supposed to fix "screen On Fri, May 17, 2013 at 7:35 AM, bibendovsky notifications@github.comwrote:
|
By removing this code I enforces to use correct calculation of amplitude, like it was done by original (non-OpenAL) sound backend (see idSoundWorldLocal::FindAmplitude in snd_world.cpp). P.S. (For clarity) By "twitches" I mean very short but noticeable shake of screen (see provided video at 00:04). |
And how does that amplitude influence the rendering/camera (resulting in (To be clear: I'm not saying this makes no sense, but I'd like more On Fri, May 17, 2013 at 1:52 PM, bibendovsky notifications@github.comwrote:
|
Isn't it a feature that allows camera shake based on a sound shader played? http://www.iddevnet.com/doom3/sounds.php see "shakes" |
The result amplitude calculating from a "data window" (DW) at specified sound offset. The size of DW is 512 samples. a) For system backend samples for DW fetched by decoding sound data. b) For OpenAL backend samples for DW fetched from precalculated pairs of min/max values at loading time (idSoundSample::Load). A number of theses pairs equals to "sound_size_in_samples / 512" (For example, we have a 1024 samples, so there are 1024 / 512 = 2 pairs). So, for system backend we will have unique values in DW, but for OpenAL all values will be same. |
"Isn't it a feature that allows camera shake based on a sound shader played?" Correct. But I'm talking about abnormal/jerky camera shakes among a normal/smooth one which you can see in video. |
I am a bit confused, is the code defective? Why has it been gutted rather than fixed? |
Because the fixed code already exists. By gutting this code I reroute execution to a correct one. |
Why was it there in the first place! |
I don't know why id Software developers left this code. Maybe they would like to gain some speed by precalculating data. |
An amplitude for a sequence of sound samples calculating by a following formulas (look at bottom of idSoundWorldLocal::FindAmplitude in snd_world.cpp): Example At-first, system backend. Offset 0. Set of samples: {1, 2, 4, 8}. Amin = 1. Amax = 8. d = 7. At-second, OpenAL backend. At sound load time a cache of pairs { Amin, Amax } created. Number of pairs is equal a number of "windows" in sound data rounded to a greater. For our example these windows are: {1, 2, 4, 8} and {16, 32, 64, 128}. And the cache contains only two pairs: {1, 8} and {16, 128}. But how an index for cache entry ( cache[i] ) is calculated? It's just division of offset by a window size: c[i] = round ( offset / Nw ). So for offsets {0, 1, 2} we got indices {0, 0, 0} and for offset 5 - {1}. Now let calculate a differences. Offset 0. Amin = 1. Amax = 8. d = 7; As you can see, d values for system backend are more "smoothed" then in OpenAL one. If we want to fix caching we need for each sound's sample calculate Amin / Amax pair. |
Hi, Sorry for not answering, I was busy and then on vacation.. Thanks! |
Here is a savegame for game/mars_city2 level (noclip is ON). Screen shackes will appear after several seconds after loading the savegame. Also you may fly out of the level to get enormous screen shackes. |
Ok, I just tested it; actually, right after loading mars_city2, both the (intentional) shaking and the twitches can be observed. I pushed your fix (with slightly changed commit message), thanks for the patch and the elaborate explanation! |
Caused by inaccuracies in the precached amplitude data in the OpenAL backend, see dhewm/dhewm3#71 for more details. Video sample (not mine): http://www.youtube.com/watch?v=ZUohifAbPW0 The "twitches" can also be observed right at the beginning of the mars_city2 map.
Video sample (not mine):
http://www.youtube.com/watch?v=ZUohifAbPW0