Hi all,
I have a few questions on how to sort my renderbucket (in my renderqueue).
Below you can find an example of the current content in my opaqua render bucket.
The struct that I use per renderable is this:
typedef struct Q_RENDERABLE // renderable level; for filling render buckets
{
int MatGroup;
int Material;
int Mesh;
int Instance;
int Id;
bool Visible;
float DistToCamSqr;
} Q_RENDERABLE;
My questions:
- what would you advice on another way of sorting, I know fully based it on materialgroup (shader), mesh, instance etc., to reduce state changes, texture changes, shader changes etc. All works pretty good, but I don't do anything yet with distance to camera (front to back might be useful for early-z, but how to combine both sorting options?)
- say I insert or add renderables (for new entities), how can I easily sort them based on one of the variables, with std::sort or something?
(I have a std::vector<int> where I can simply store the indices of the renderables in a specific order)
- could I maybe create some sort of key based on the 7 variables and sort that?
Any help is appreciated.
An example of the bucket, current sorting:
ID matgrp matl mesh inst distsqr
0 0 0 7 44 2679.06
1 0 0 7 44 1928.28
2 0 0 7 44 1523.69
0 0 0 8 45 2678.64
1 0 0 8 45 1526.07
2 0 0 8 45 1961.64
0 0 1 1 30 863.876
5 0 1 1 30 641.774
1 0 2 1 28 297.844
3 0 2 1 28 302.922
7 0 2 1 28 298.979
1 0 2 1 30 715.996
3 0 2 1 30 681.976
7 0 2 1 30 710.025
2 0 3 1 28 324.312
2 0 3 1 30 784.915
0 0 9 13 14 26.7233
0 0 9 13 15 50.9233
0 0 9 13 16 26.5313
0 0 9 13 17 50.7313
1 0 10 13 14 31.211
1 0 10 13 15 56.941
1 0 10 13 16 31.019
1 0 10 13 17 56.749
2 0 11 13 14 26.546
2 0 11 13 15 50.746
2 0 11 13 16 27.884
2 0 11 13 17 52.084
3 0 12 13 14 23.4845
3 0 12 13 15 46.1545
3 0 12 13 16 23.2925
3 0 12 13 17 45.9625
4 0 13 13 14 28.1495
4 0 13 13 15 52.3495
4 0 13 13 16 26.4275
4 0 13 13 17 50.6275
0 0 19 17 10 632.05
0 0 24 21 3 244.611
1 0 24 21 3 241.486
2 0 25 21 3 257.666
0 1 14 14 1 0
0 1 14 14 12 24.6981
1 1 15 14 1 0
1 1 15 14 12 25.8981
2 1 16 14 1 0
2 1 16 14 12 25.8144
0 1 21 19 5 279.369
1 1 21 19 5 251.263
2 1 21 19 5 274.758
3 1 21 19 5 220.368
4 1 21 19 5 219.088
5 1 21 19 5 240.494
6 1 21 19 5 327.245
7 1 21 19 5 325.97
8 1 21 19 5 347.619
9 1 21 19 5 242.705
10 1 21 19 5 349.88
11 1 21 19 5 313.179
12 1 21 19 5 237.035
13 1 21 19 5 371.248
14 1 21 19 5 357.944
15 1 21 19 5 316.496
16 1 21 19 5 274.828
17 1 21 19 5 248.869
18 1 21 19 5 266.779
19 1 21 19 5 210.195
20 1 21 19 5 281.241
21 1 21 19 5 289.241
22 1 21 19 5 296.312
23 1 21 19 5 286.909
24 1 21 19 5 301.771
25 1 21 19 5 299.007
0 1 21 19 6 399.231
1 1 21 19 6 431.338
2 1 21 19 6 352.877
3 1 21 19 6 406.877
4 1 21 19 6 413.153
5 1 21 19 6 339.316
6 1 21 19 6 472.361
7 1 21 19 6 478.642
8 1 21 19 6 405.05
9 1 21 19 6 333.87
10 1 21 19 6 399.653
11 1 21 19 6 423.048
12 1 21 19 6 371.141
13 1 21 19 6 439.107
14 1 21 19 6 478.828
15 1 21 19 6 424.459
16 1 21 19 6 348.235
17 1 21 19 6 434.9
18 1 21 19 6 391.29
19 1 21 19 6 361.184
20 1 21 19 6 401.6
21 1 21 19 6 408.107
22 1 21 19 6 413.031
23 1 21 19 6 401.844
24 1 21 19 6 415.278
25 1 21 19 6 414.707
8 1 35 25 54 319.827
4 2 4 1 28 307.071
6 2 4 1 28 307.903
4 2 4 1 30 692.514
6 2 4 1 30 691.557
0 2 7 4 18 731.78
3 2 7 4 18 648.601
4 2 7 4 18 977.865
5 2 7 4 18 852.965
2 2 7 4 24 807.783
4 2 7 4 24 1048.26
5 2 7 4 24 1195.96
1 2 27 22 2 25.9537
0 3 6 3 39 458.656
0 3 6 3 40 505.257
0 3 6 3 41 541.335
0 3 8 9 46 660.565
0 3 8 10 47 698.492
0 3 8 11 48 160.596
0 3 8 12 49 131.051
0 3 17 15 0 0
1 3 17 15 0 0
2 3 17 15 0 0
0 3 17 15 13 50.8262
1 3 17 15 13 48.7949
2 3 17 15 13 51.9707
0 3 22 20 4 804.828
1 3 23 20 4 879.321
0 3 26 22 2 25.941
0 3 30 25 54 323.753
1 3 30 25 54 323.794
2 3 30 25 54 321.517
3 3 31 25 54 328
4 3 32 25 54 322.811
5 3 32 25 54 323.494
6 3 33 25 54 321.439
10 3 33 25 54 321.502
7 3 34 25 54 320.425
9 3 36 25 54 320.352