-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathCHANGES
9370 lines (5341 loc) · 310 KB
/
CHANGES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Friday, June 17, 2016
---------------------
Upgrade to premake5
Some problem with 'find' in clean. Already solved in my other premakes.
Brought across clean hack from yojimbo
Some problems including freetype headers... wtf
Verified that cube demos run now.
Disabled font tool.
Generate a cubes dataset for Mark B. Reynolds (uncompressed, non-quantized...)
Done! Sending off!
Update copyright and licence to The Network Protocol Company, Inc. BSD 3-Clause.
Do some more work to build warning free. Get it done.
Convert back to release and make sure it works. For tests I need to convert from 'CORE_ASSERT' to 'check' macro
Bug. I fucked up the stencil shadows with a change I made to fix warnings... fix it!
Just an accidental deletion of a line. Fixed now.
Port to windows.
Hoooooly shit this is so much work.
After much pain, got everything basically *compiling*
Network test passes.
Protocol test fails and hangs on reliable messages.
WTF... the actual protocol is here is broken. I need to fix this up. What a fucking disgrace.
Soak protocol seems to be working fine though...
No it seems to be hanging, at least for long periods while receiving chunks. Not sure why.
The tests being so fragmented into separate source files is incredibly obnoxious under Visual Studio.
Next step is to get a version of ODE that is pre-built for Windows (64bit)
Definitely will want to pre-package this as building ODE is a bit of a pain in the ass under windows.
Got this working. Good.
Monday, Sept 7th, 2015
----------------------
Record videos for state synchronization article:
1. State synchronization uncompressed (basic stuff) <--- should already look pretty much perfect
2. Video showing popping due to not quantizing state in remote view
^---------- will need to construct a large stack of objects to see the popping
^---------- may need to drop to lower precision to emphasize the popping
3. Video showing quantize on both sides <--- should look perfect again.
4. Video showing smoothing too slow with with large jumps
5. Video showing better smoothing with large jumps (adaptive according to distance)
Convert videos to web formats (need to dig up commands from CHANGES file)
Finish writing and restructuring state synchronization article. Wow that was a lot of work.
Sunday, Sept 6th, 2015
----------------------
Final pass over state synchronization ready for publish.
Tell patreon supporters what I'm up to.
Fix various bugs in state synchronization demo.
Sketch out state sync demo functions to support uncompressed and compressed
Templatize jitter buffer, needs to support both compressed and uncompressed state updates.
Convert all the other bits that need uncompressed state updates.
Implement uncompressed state sync mode.
Hook up compressed state sync mode (not quantized)
Hook up quantized state sync mode (quantize both sides)
Fixed at rest handling. Current setup is "good enough". Move on.
Split apart smoothing and adaptive smoothing modes
Implement packet loss mode (you should see pops when input changes occur with packet loss)
Add a display at the bottom of the screen "SYNC DISABLED" in red, so the user can clearly see
what is going on, that synchronization is disabled immediately, and when it is removed.
Otherwise the videos would be a bit hard too follow.
NOTE: If you disable sync and blow cubes around, you can watch as the grey cubes touched take a while to update
This is a good example of lazy updates of grey cubes that would benefit from "comitting" at rest state w. reliability.
Tuesday Morning, April 7th, 2015
--------------------------------
Removed C++ bullshit from shader loading code.
Fixed min/max
Saturday Evening, March 14th, 2015
----------------------------------
Export data set for Ryg to crunch on. Don't give him the result to aim for though.
While he's working on it, calculate the best result on this data set using my existing encoding in bits.
When he starts reporting back compression bits then I hold the cards and can tell him "not even close".
This way I can be assured he will actually push the compression as far as possible vs. stopping as
soon as he goes past 5% (he will, he's pragmatic...)
Saturday, March 14th, 2015
--------------------------
Published snasphots and interpolation article.
Implement javascript to pause video when it is not currently visible
Polish pass the snapshot compression article.
Work up the snapshot compression article conclusion. It's currently weak. Should be firm!
Work out what videos need to be converted for the snapshot compression.
1. orientation compression only
2. compressed linear velocity
3. without linear velocity
Get those videos named such that they fit in with the rest and convert them to mp4 and webm
Upload those videos to the media library
curl those videos down to my linode.
Move those videos to the correct folder for the article locally.
Verify all videos are up.
Publish article.
Publicize article on twitter.
Monday Afternoon, March 2nd
---------------------------
Relative index
Absolute index
Relative position
Relative orientation
Final pass over slides.
Upload final slides to google drive:
Slide link is: https://drive.google.com/open?id=0BwUw_ra2ndJTdnV0M3VmaWJOTVU&authuser=0
Monday Morning, March 2nd
-------------------------
Re-record "perfectly good" state sync end result at 4096 position
Passed over all slides and prepped slide notes.
Sketch out difficult slides, what I still need to do:
Absolute index
-- diagram to show what the skip bits looks like, eg. 900 bits (125.5bytes) just to say "no cubes have changed"
-- diagram to show num changed cubes, changed index, cube data, etc.
-- something to show that in the header you can choose between two encodings (one bit)
-- since each index is 10 bits, cross-over point is about 90 cubes. more than 90 cubes changed, better off using skip bits.
Relative index
-- list of numbers, converted to +1, +5, +2, +10, etc.
-- information about the encoding I'm using. variable encoding, avg. 5.5 bits per-index (almost half off)
-- you could probably optimize this encoding over the data set but this seemed pretty good.
Relative position
-- delta baseline data x,y,z,base_x,base_y,base_z
-- optimize for two level encoding. small bit per-component, otherwise large bits
-- if any of the components don't fit into the large encoding, fall back to absolute position
-- ruby script to run a greedy search over different small/large bit encodings and sort according to least bits
-- results: show a table of results, winner x% reduction
-- best result: x bits per relative position, that's just 8.5 bits per-component. Pretty good.
Relative orientation
-- harder. different representations to choose from
-- axis/angle (4 values)
-- axis multiplied by angle (3 values)
-- relative quaternion (conjugate(base_orientation) * orientation)
-- smallest three representation directly
-- best result: 70% of uncompressed size (relative quaternion)
-- second best result: 81.3% of uncompressed size (delta smallest three)
Sunday Morning, March 1st, 2015
-------------------------------
Finish state synchronization slides:
Priority accumulator diagram sequence
Reliability system diagram: ack, ack_bits
Saturday Evening, February 28th, 2015
-------------------------------------
Fill in detail for bound and quantize linear velocity
Fill in detail for bound and quantize position
Added diagram for linear interpolation vs. hermite interpolation with velocity
Added diagram for error reduction (smoothing)
Saturday Lunch, February 28th, 2015
-----------------------------------
Pass over slides and work out what videos need to be recorded again
1. Single cube video needs to be a bit shorter (done)
2. Cube blow video should start out with blow and have smoother motion (done)
3. Katamari roll video introduction is too long. Don't need the big spin and spray off bit (done)
3.5 - UDP @ 25% packet loss video needs to be shorter. Just show blow and katamari roll (done)
6. Video with linear velocity not sent, before position compression (done)
Lockstep demo needs a fix so the cubes don't show up until first packet.
Fixed. Added note because this is incompatible with delta.
4. Video showing 60 snapshots per-second uncompressed is too long. It just needs to show cube blow.
5. Video showing orientation compression only (pretty big win -- short, blow only)
7. Video with at rest flag, skip katamari bit.
8. End result video for delta compression is long winded. shorten, but do show both blow and katamari
9. Short state synchronization video (looking perfect @ 250kbps). just blow? maybe a small katamari.
Need the math and cool bits for the smallest three. this is a big win!
Find site that converts latex -> images (hires)
Put formulas and working out into the slides.
Added basic delta encoding diagrams
Saturday Morning, February 28th, 2015
-------------------------------------
Diagram pass for deterministic lockstep
Polish pass the input/ack articles.
Diagram pass over snapshot interpolation.
Setup the intro slide into the bandwidth optimization.
Restructure slides for state synchronization. Was moving way too slow in practice
Cut down some deterministic lockstep slides because the behavior was obvious
and it felt drawn out going through 5 cycles of redundant inputs.
Monday Evening, February 22nd, 2015
-----------------------------------
Take the existing slides and bring their structure back into a tree diagram
Should see exactly what is being talked about -- identify the technical sections
see "SLIDES" text file.
Saturday Morning, February 21st, 2015
-------------------------------------
Tuned the simulation to work better in the sync demo.
Basically, push apart collisions in a softer way, add some bounce for push out as well (penetration resolution)
Adds softness but also a nice springiness.
Added config "soften_simulation" to enable this. Turned on for sync demo only.
Turned on for singleplayer cubes demo as well. I like it.
Re-recorded katamari demo for physics simulation section.
Re-record the cube video
Re-record the cubes roll video
Re-record the cubes blow video
Friday Evening, February 20th, 2015
-----------------------------------
Make list of all diagrams
1. Concept of deterministic lockstep, eg. start at same
initial state, apply same inputs -> same result.
2. Send all unacked packets to right side, ack packets come back,
3. Packet structure of input packet sent (sequence, ack, inputs)
4. Diagram showing encoding relative, one bit, input not changed.
5. Diagram showing linear interpolation position artifacts
6. Diagram showing linear artifacts for katamari ball (shortest path)
7. Diagram showing how packets come in, interpolation buffer, delayed and then interpolation
8. Diagram showing how to handle packet loss by interpolating to the next snapshot
9. Diagram of cubes struct (from old)
10. Diagram showing smallest three compression --> show uncompressed bits to compressed (x%)
11. Bound and quantize linear velocity --> diagram showing uncompressed to compressed (x%)
12. At rest flag --> diagram showing two cases, at rest, not at rest. (bits)
13. Compressed position, bound and quantize. --> diagram showing reduction (x%)
14. Delta compression, acks flow of packets.
15. Buffering of snapshots on send and receive for delta encoding.
16. Diagram of packet structure with not changed flag
17. Diagram of packet structure with index.
18. Diagram showing header with one bit selecting encoding.
19. Diagram showing relative index compression, eg. two level encoding with bits, fallback to absolute
20. Perhaps some statistics, tables or something to back up the analysis
21. Relative position. tables or something. two level encoding, draw it.
22. Relative orientation. diagram of two level encoding per-smallest three component delta, fallback to absolute
23. Diagram showing packet structure sent across with state updates, and updates being applied to sim
24. State update struct
25. Priority accumulator diagram
26. Algorithm in diagram, add priority, sort, pick top n.
27. Packing as many in packet as will fit, skip past if not fit, small ones at end.
28. Take n sent ones and clear to zero, need to bubble up from zero.
29. Diagram showing snap position, calculate new error offset (same concept for orientation)
30. Reliability system diagrams for header, sequence, ack, ack bits
31. Diagram of delta encoding for state sync (bits)
32. Diagram showing per-state update bit packing for delta
Friday Morning, February 20th, 2015
-----------------------------------
Finish sketching out conclusion slides (pros/cons, relative rankings for bandwidth, latency...)
Make a list of videos that need to be recorded for state synchronization
1. Video showing input desync on packet loss
2. Video showing jitter before quantize
3. Video showing jitter fixed after quantize, but then after a lost input -> jitter on right (cascading failure)
4. Video showing smoothing, looking good, and then recovering nicely from long second hitches and staying smooth.
Record the videos and insert into slides
Early Friday Morning (2-3AM)
----------------------------
Sketched out state synchronization slides
Fleshed out more slide/diagrams for deterministic lockstep
Thursday Evening, February 19th, 2015
-------------------------------------
Sketched out keynote slides from outline:
0. Introduction
- what we are trying to do: network simulation from left -> right
- what we are not talking about: topology: client/server, vs. p2p. anti-cheat. lag hiding (too much detail. derails...)
- three main synchronization techniques: 1. deterministic lockstep, 2. snapshots and interpolation, 3. state synchronization
- will also cover bandwidth compression techniques in detail using snapshots as a case study.
- conclusion: pros and cons of each technique. how to select the right technique for your simulation
- (this talk is at an advanced level. not introductory at all. the content of this talk is the state of the art at this point in time)
1. The example simulation being networked (cube sim)
- rigid body simulation.
- one player controlled cube
- 900 small cubes the player can interact with
- all objects are gameplay effecting (not cosmetic)
- different modes of interaction to demonstrate difficult networking cases, eg. coupled interactions between objects.
- in general: rigid body simulation is non-linear and difficult to predict/extrapolate
- standard networking techniques (extrapolation, dead reckoning) break down.
- different techniques are required.
2. Deterministic lockstep
- bandwidth required is independent of the # of object in the world.
- requires absolute determinism down to the bits. this is hard (summarize difficulty, but don't bog down)
- virtually impossible to guarantee across different OS, different compiler or machine arch.
- possible, with work, across intel/AMD, same compiler, same OS.
- requires same framerate on both sides
- send only inputs. *must* wait for input n before simulating frame n.
- even though all inputs must be reliable, don't use TCP. show result of implantation over TCP @ 1%, 2%, 5% @ 250ms.
- use UDP and redundantly send un-acked inputs each each packet
- compression scheme for inputs => bandwidth result (50kbps @ 60 packets per-second, mostly packet header)
- video of it it working at 25% packet loss and 250ms latency = perfect.
3. Snapshots and interpolation
- don't run the simulation on the right side
- instead send only visual state and interpolate between snapshots for render
- snapshots are the state of the entire world. eg. 900 position/orientation quat pairs + interacting (red) bool
- snapshot packet is very large (big number). don't worry for now, we'll compress this shortly.
- send across: strobing @ 10 pps. not very good.
- buffer snapshots and delay them so that 2 consecutive packets can be lost without hitching
- at 10 packets per-second, 350ms of additional delay required to handle 5% packet loss, +/- 2 frames of jitter @ 60fps (typical)
- interpolate linear. OK but some artifacts
- improve position interpolation by sending linear velocity. hermite interpolation
- orientation interpolation with slerp good enough. nlerp has artifacts at 10pps (non-uniform angular speed = discontinuities).
- end result: video @ 5% packet loss with snapshot. basically perfect. contrast with strobing. It's quite amazing we can get such a good result at such a low send rate + hermite interpolation.
4. Bandwidth optimization case study: compressing snapshots
- additional delay (350) @ 10pps is very large. too much.
- would like to send snapshots more rapidly but bandwidth is off the charts
- compress absolute quaternion: smallest 3
- bound and compress linear velocity.
- at rest optimization
- why are we sending velocity at all? linear interpolation good enough at higher send rates.
- bound position and quantize
- as far as we can go with absolute compression
- delta compression
- changed bits
- absolute indices, cross over point
- relative index compression (measure bits required and fall back to changed bits)
- relative position: two level encoding with optimization, fallback to absolute position
- relative orientation: trickier. much larger % of quaternion space covered in delta vs. position. harder gains
- delta axis/angle, delta relative quaternion large w, delta smallest 3 (90% delta base have same largest component)
- conclusion: video showing several orders of magnitude improvement. 18mbps down to 256kbps on average.
5. State synchronization
- run simulation on both sides.
- send input and n state updates per-packet
- use priority accumulator
- fit as many cubes in packet as possible, given bandwidth target (may be dynamic)
- quantize sim on both sides to avoid misprediction on right side
- higher precision required for position/orientation due to quantization
- snap state and use position/orientation error reduction for smoothing (local space)
- good enough at this point: additional extra things that can be done to get even more efficient (delta, at rest optimization and so on)
6. Conclusion
- pros and cons of each technique.
- how to decide which technique is appropriate for your simulation
- Q&A
Tuesday Morning, February 17th, 2015
------------------------------------
Finish the advanced section at the end of the state synchronization article.
Monday Morning, February 16th, 2015
-----------------------------------
Pass over and clean up the introduction. Was getting a bit bloviating...
Polish pass over the introduction.
Cut the networking 101 article. Weak. Not part of the talk. breaks flow.
Now the article series perfectly matches the flow of the talk.
Sunday Afternoon and Evening, February 15th, 2015
-------------------------------------------------
Cleaned up introduction to network physics series to conform to the talk content.
Deleted additional article outlines that I will not have time to write.
Articles should now map very, very well (perfectly) to talk content.
Added conclusion page at end of networked physics article series. Empty for now.
Will be used to summarize pros and cons of each technique, conclude the talk.
It's essential for the GDC talk, and this article series must perfectly match
that so *done*.
Wrote the first draft of the bulk of the state synchronization article.
Hit all the main implementation points, worked out what videos should be recorded.
Sketched out conclusion article. It's going to need another pass but it's decent.
Sunday Morning, February 15th, 2015
-----------------------------------
Implement code to reduce the position error over time.
Implement code to reduce the orientation error over time (slerp towards identity)
Make sure neither case have issues with denormals, esp. position.
There appears to be some jittering on the right side in mode 5.
Only appears after a while in the katamari cube
What is going on?!
(I suspect the input frame is getting out of sync somehow?)
Either way, this is good. There needs to be something to do apply smoothing to.
When a state update is applied, recalculate the position error.
Relcalulate the orientation error.
Verify that in smoothing mode the smoothing is working properly (katamari ball)
Tune it so it looks as good as possible.
Position error smoothing is now working.
Orientation smoothing is now working.
Tuned smoothing to look as good as possible. Orientation smoothing factor needs to be slower than position.
There is still jitter on the right side.
Suspect orientation smoothing is not working properly.
Orientation error was not actually being applied, so no smoothing.
Fixed.
Now make sure the math is correct.
Need 15 bits per-quaternion a,b,c to get the required orientation precision.
Implemented two level tightness. It's definitely visually better.
Wednesday Evening, February 11th, 2015
--------------------------------------
I was sending relative orientation with 10 bits [0,1023] precision for deltas.
It should actually be encoded at 9 bits total [0,511] with 255 midpoint.
This means I was encoding at twice the precision, and that relative orientation
is likely to beat the smallest three delta now.
Wow! I'm at 72% of absolute smallest three size!!!
num relative quaternion samples: 189625
absolute smallest three: 5499125 bits
compression 4-7: 3998144 (72.7)
compression 5-7: 4040001 (73.5)
compression 3-7: 4091706 (74.4)
compression 4-6: 4114374 (74.8)
compression 5-6: 4120000 (74.9)
compression 3-6: 4179849 (76.0)
The snapshot compression article needs to be updated with this. This is a big improvement!
Wednesday Morning, February 11th, 2015
--------------------------------------
Fix the * and *= operators between quat4f.
Re-evaluate the relative quaternion statistics for delta encoding.
It may be a lot better know. Previous statistics were completely thrown off by
incorrect quaternion multiply!!!
Seems to still be in the same ballpark: 90% of original size at best.
My guess is that the smallest 3 is still the best, although it may
be possible to get close to it, or even maybe beat it with a smart
two-level encoding for the relative quaternion deltas.
Nope. Relative encoding is promising. It should be explored. Do it!
Explored it. The encoding is just slightly worse than the smallest 3 delta encode.
eg. 81.6% best, vs. 80.8% best for smallest three delta.
Very interesting!
I wonder if axis-angle delta would provide wins over both of these?
It probably would. Conclusion for compression article still stands, although
a slightly adjustment needs to be made for the relative quaternion encoding.
Monday Morning, February 9th, 2015
----------------------------------
Implement error reduction for position (smoothing)
Implement error reduction for orientation (smoothing)
Added position and orientation error arrays.
Need a way to add the position/orientation error to the real state before render.
Should be passed into render config because it needs to be per-view/sim.
Added RenderConfigPerView struct, inside position/orientation error pointers initially nullptr.
Make sure it position/orientation error is passed in to right simulation in mode 5 (smoothing) and is cleared to identity for now.
Something crazy is going on -- multiplying the orientation by quat identity
is resulting in a quat which is forced to identity.
Maybe something is wrong with the * operator? Maybe it is a result of deriving from vec4f?
Appears to be so because the goddamn quaternion * operator is just not defined.
This explain why the relative quaternion was having problems during compression.
Should probably return to that and try to understand if it can be made to work once this is fixed.
Sunday Morning, February 8th, 2015
----------------------------------
Extend precision.
CubeStateHighPrecision
increase the position resolution until the quantize stops having artifacts
eg. 1024, 2048 per-meter...
increase the orientation bits to 10, is it noticeable? It's probably for the best.
Seems that 1024 position and 10 bit orientation is sufficient.
New modes: without quantization, with quantize, with smoothing
Noticed that there is still quantize jitter on the katamari...
Tried increasing the position precision. Nope.
Tried separating linear/angular velocity precision and increasing. Nope.
Added 64 bit compressed quaternion so I could increase orientation precision about 20 bits.
Fixed it.
Now reduce the precision for each back to the breaking point and then back up one
Seems that 12 bits precision for orientation and 2048 for position/velocity does the trick.
Saturday Evening, February 7th, 2015
------------------------------------
Would be very nice to have a button that when held disables packets getting through.
^--- X KEY
Done. It's not super great because the popping hides a lot of the corrections.
It seems that we do need additional precision
Definitely for position. Probably also for orientation.
Removing the quantize removes the jitter and popping on the left side,
but on the right it still exists.
To get it working properly it is necessary to synchronize at high(er) precision
and do the quantize on both sides.
It is probably a good idea to have a mode without the quantize as demonstration
Saturday Morning, February 7th, 2015
------------------------------------
Implement jitter buffer
Store the packet pointer and delete it? Or copy the data?
The data is pretty small. Just copy. Safer.
Hacked up StateJitterBuffer copied from interpolation buffer.
Work out what needs to be done to implement delay jitter buffer.
Add code so the sim doesn't run on the right until the first packet comes in.
(Use the stopped flag)
Check the jitter buffer if a state update is available for current time
Working. State updates are coming through.
Once the state update is pushed to sim, remove it so it is not pushed repeatedly.
Set remote input to input in packet
Sim is not deterministic on right. It should be!
Work out why it's not (probably time related) and make it so.
Seems to be deterministic until input kicks in.
I believe it's because it is starting sim too early, so frame # is off.
Fix should be to only start sim when the first frame should be available to sim.
Yes. That fixed it!
Lock in input only as first mode. This is important to make sure it is deterministic.
Next, add some packet loss and show it desyncing (2nd mode)
3rd mode synchronize state.
4th mode, implement smoothing?
Implement "ApplyStateUpdate" function to push to sim.
INPUT_AND_STATE mode should be working now (staying in sync)
It seems that linear/angvel in state is zero. Inverted at rest flag?
It was inverted but now the velocity is totally fucked up.
Incorrect velocity state on send?!
Just a cut&paste bug on quantized cube state w. velocity load function.
Fixed!
Apply snapshot to sim is not pushing to sim but to view. This is incorrect. Fix it!
Might need more precision now. It wasn't really quantizing the sim before.
Don't need more precision, but the linear/ang velocity threshold for at rest needs to be increased,
because some cubes are remaining active now.
Increased to 0.5m sec threshold.
Rename "stateful" or "state" to "sync". Much better.
Actually implement serialize measure before cube packet write, so cubes
perfectly fit into the allowed # of bytes and we hit requested bandwidth
exactly.
Hacked the code to loosely output 256kbps (equivalent to snapshot)
Friday Afternoon, February 6th, 2015
------------------------------------
Implement priority bubble up, pull, push.
Need to first get priority for all cubes this frame.
This is a simple function that fills an array of floats:
1. if red the cube has high priority
2. if player cube extreme high priority
3. otherwise default priority (1.0)
Once this priority float is created (array float), then pass over existing struct
{ float accum, int index } and add delta Time * priority to accum.
Copy this struct and sort highest accum to smallest.
Need a new struct for potential cubes to send: SendCubeInfo { int index; bool send; }
Take the n most important cube indices and put them in an array for potentially
being included in a packet.
Fake out a function that in the future will serialize measure these cubes and mark
which ones actually should be sent. Right now just mark all to be sent.
Construct state packet containing n most important cubes to be sent.
Send packet from left to right containing most important n cube state
that should be sent (according to measure)
When this packet arrives print to make sure it's being received.
Make sure send sequence is being sent.
Friday Morning, February 6th, 2015
----------------------------------
Sketched out cube data with index for packet.
Implement packet serialize fn. with per-cube index and serialize of position, orientation, lin/ang velocity.
Implemented at rest flag.
Each frame before simulate pull all state from simulation, quantize it, clamp position, linear velocity, angular velocity.
This quantized state is where the cube state that fills the packet with n most important comes from.
Implemented code to clamp the quantized state for position, linear/ang velocity bounds.
Implement code to push the quantized snapshot back to the simulation
Determine if precision needs to be higher with quantize.
Hopefully not, but if it does some structural changes need to be made.
Precision seems fine.
Thursday Evening, February 5th, 2015
------------------------------------
Need to move on to stateful synchronization implementation.
Add demo framework: "pm stateful".
Get sim running on both sides
Need a place to store remote input.
Setup right simulation to run from remote input, even though it is currently always cleared.
Fuck it just include Snapshot.h from state demo.
Extend quantized cube state to include linear/angular velocity.
QuantizedCubeStateWithVelocity struct.
Thursday Lunch, February 5th, 2015
----------------------------------
Convert videos to web format and upload
webm command line is:
parallel 'ffmpeg -loglevel quiet -i {} -c:v libvpx -b:v 2M -c:a libvorbis -vf scale=1000:500 {.}.webm' ::: *.mov
mp4 command line is:
parallel 'ffmpeg -loglevel quiet -i {} -vf scale=1000:500 {.}.mp4' ::: *.mov
Upload videos to gafferongames wordpress.
Migrate videos across to linode.
Hook videos up into the article.
Test in safari.
Test in firefox.
Thursday Morning, February 5th, 2015
------------------------------------
Make a list of videos that need to be created.
Fix shadows so I can record a video of the key points, eg. with huge bandwidth,
post delta encode (changed), at the end with everything on.
It may not have been GLFW because might be the OS upgrade.
Trying the latest GLFW source anyway...
It's still broken! What the fuck?!
Fix it!
It was fucking GLM! Fixed by converting shadow projection matrix to vectorial instead (matching non-shadow render)
Record videos at high resolution:
1. video of cubes blowing and katamari roll at maximum bandwidth -- 17.37 megabits per-second
2. video showing variable bandwidth with "at rest flag" as you move around doing stuff
3. video of compressed position @ 4.3 megabits
4. video of delta encoding with changed flag
5. video of reduced steady state: roll the cube off to the side and have it completely stationary
6. video showing the end result @ 60 packets per-second
Wednesday Morning, February 4th, 2015
-------------------------------------
Fix issue with simulator not giving correct amount of bandwidth.
Should also handle different send rates now too, but it may oscillate a bit
Clean up first draft.
Go through the article and insert placeholder text for diagrams and videos to be created
Adjust bandwidth estimates to include packet headers where they don't currently.
Monday Evening, February 2nd, 2015
----------------------------------
position not changed 5% -- orientation not changed 5%
dependent but opposite, so 10% gets a big win. eg. position and orientation in just 2 bits
but... 90% of "changed" cubes have 2 bits added to their state for no reason
is it a win? do the math!
in order to win, we need to save more bits from 10% of cubes than we lose from 90%
So for 1000 cubes, 50 have position not changed, 50 have orientation not changed. 900 have both changed.
900 * 2 = 1800 bits overhead.
50 * ( 26 - 2 ) = 1200 bits saved on orientation
50 * ( 26 - 2 ) = 1200 bits saved on position