RenderOperation.txt 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. Since DrawHelper needs to queue render commands together with scene objects (in order for transparency to work okay), I will need to implement the RenderOperation approach I thought about earlier.
  2. Rename current RenderOperation to SubMeshData
  3. Real render operations contains SubMeshData + layer (can be filtered per-camera) + queue (each mesh has a queue and another queue by camera) + Pass
  4. (Remove Camera->rendersSceneObjects and replace it with layer)
  5. (Make sure to set up preset queues, like opaque, transparent, etc)
  6. Then I can hook up GUIManager, OverlayManager and DrawHelper with a callback that is used by Renderer to retrieve their operations
  7. Attempt to move all sorting (including by render target) out of forward renderer and into an overridable sorter class
  8. - Create a hash list with key(containing type, queue, layer, etc.) used for sorting
  9. Add "materialGroup" to material. It can be used for sorting similar materials together, instead of using some automatic way of determining it.
  10. Issues with my render operation system:
  11. Sorting by depth is impossible because I don't provide any position info with my RenderOperation
  12. For each frame I will need to calculate world bounds and world position. I cannot do it each time I retrieve a RenderOperation so it should be cached somewhere and reused throughout the frame.
  13. - Unity keeps it with Renderable
  14. - What happens when the Mesh resource is updated?
  15. - How do I do it for non-renerables though?
  16. ---------------------
  17. RenderOpSorter:
  18. - (Before we send RenderOps to the sorter we first filter them by camera)
  19. - Accepts parameters whether to sort back-to-front, front-to-back or ignore depth (depth ignored with skybox and overlay)
  20. - Another parameter is whether to sort by pass (transparent ops can't be sorted by pass)
  21. - Then we sort:
  22. - If back to front
  23. - We sort by depth and that's it. We could also sort by material by that only makes sense if two elements have exact same depth which will almost never happen
  24. - If front to back
  25. - Sort by material first. We call materialSimilarity() method which returns lesser value depending how similar two materials are. We do a pass over all unsorted materials and if similarity is below some threshold we add it to the current bucket. If there are no more similar materials we create a new bucket.
  26. - Within bucket we sort by similarity as well (as the elements are added)
  27. - Then finally we sort the buckets by depth front to back
  28. - No depth
  29. - Same as front to back, without the depth sort
  30. - Sorter should operate directly on provided render op array