tiler_optimized.txt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. =============
  2. Update planes
  3. =============
  4. planetrf = 22* 14+
  5. updatealltileplanes = planetrf * (15 + 15 + 256 * 2)
  6. sum = 11924* 7588+
  7. =============
  8. transform everything else
  9. =============
  10. 100 lights
  11. 1000 other spatials
  12. trfaabb = 30* 27+
  13. lighttrf = 900* 600+
  14. otherspatialstrf = 30000* 27000+
  15. =============
  16. transform them for 2D checks
  17. =============
  18. mat4mulvec4 = 16* 12+
  19. alllights = 3200* 2400+
  20. otherspatial = 128000* 96000+
  21. function create_tiles
  22. end
  23. algorithm cs aabb fr
  24. MAX_POINTS = 8
  25. pointsWorld[MAX_POINTS]
  26. if cs.type is pespective frustum
  27. pointsWorld[...] = get the 5 points
  28. n = 5
  29. else
  30. pointsWorld[...] = get the 8 aabb points
  31. n = 8
  32. end
  33. pointsNdc[MAX_POINTS]
  34. minZ, maxZ
  35. for i in (0, n)
  36. pointsNdc[i] = fr.projectionMat * pointsWorld[i]
  37. pointsNdc[i] /= pointsNdc[i].w
  38. update minZ and maxZ
  39. end
  40. edges = convexHull2D(pointsNdc, n)
  41. depth = log 2 TILES
  42. for edge in edges
  43. do_edge edge -1..1, -1..1 depth
  44. end
  45. end
  46. do_edge edge min max depth
  47. if min and max not inside min max
  48. return
  49. end
  50. if depth == 0
  51. mark visible
  52. endif
  53. center = (min + max) / 2
  54. inside[4] = false
  55. if center left of edge
  56. // right up
  57. p = max
  58. if p is left of edge
  59. inside[0] = true;
  60. end
  61. // center top
  62. p = center.x, max.y
  63. if p is left of edge
  64. inside[0] = true;
  65. inside[1] = true;
  66. end
  67. // left top
  68. p = min.x, max.y
  69. if p is left of edge
  70. inside[1] = true;
  71. end
  72. // blah blah
  73. else
  74. inside[all] = true
  75. end
  76. for all that are inside
  77. do_edge new_min new_max depth - 1
  78. end
  79. end