$darkmode
Back-to-front sorting for transparent geometry. More...
Go to the source code of this file.
Data Structures | |
| struct | SphereSortEntry |
| Lightweight proxy for sorting data without moving large structs. More... | |
| struct | SphereSorter |
| Reusable memory context for sorting operations. More... | |
Functions | |
| void | sphere_sorter_init (SphereSorter *sorter, int initial_capacity) |
| Allocates internal buffers for the sorter. More... | |
| void | sphere_sorter_cleanup (SphereSorter *sorter) |
| Destroys the sorter context. More... | |
| GLuint | sphere_sorter_sort_gpu (SphereSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos) |
| Sorts the array of instances Back-to-Front (descending depth) on GPU. More... | |
| GLuint | sphere_sorter_sort_cpu (SphereSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos) |
| Sorts the array of instances Back-to-Front (descending depth) on CPU. More... | |
| GLuint | sphere_sorter_sort_cpu_radix (SphereSorter *sorter, const SphereInstance *instances, int count, const vec3 camera_pos) |
| Sorts the array of instances Back-to-Front (descending depth) using Radix Sort. More... | |
Back-to-front sorting for transparent geometry.
This module provides an efficient sorting mechanism for sphere instances, which is required for correct alpha blending of billboarded spheres.
| void sphere_sorter_cleanup | ( | SphereSorter * | sorter | ) |
Destroys the sorter context.
| sorter | Pointer to the struct. |
| void sphere_sorter_init | ( | SphereSorter * | sorter, |
| int | initial_capacity | ||
| ) |
Allocates internal buffers for the sorter.
| sorter | Pointer to the struct. |
| initial_capacity | Expected number of instances. |
| GLuint sphere_sorter_sort_cpu | ( | SphereSorter * | sorter, |
| const SphereInstance * | instances, | ||
| int | count, | ||
| const vec3 | camera_pos | ||
| ) |
Sorts the array of instances Back-to-Front (descending depth) on CPU.
Uses qsort on the host and uploads the result to the SSBO.
| sorter | Memory context. |
| instances | Array of instances (will be copied and sorted internally). |
| count | Active element count. |
| camera_pos | World-space viewer position. |
| GLuint sphere_sorter_sort_cpu_radix | ( | SphereSorter * | sorter, |
| const SphereInstance * | instances, | ||
| int | count, | ||
| const vec3 | camera_pos | ||
| ) |
Sorts the array of instances Back-to-Front (descending depth) using Radix Sort.
| sorter | Memory context. |
| instances | Array of instances. |
| count | Active element count. |
| camera_pos | World-space viewer position (for depth). |
| GLuint sphere_sorter_sort_gpu | ( | SphereSorter * | sorter, |
| const SphereInstance * | instances, | ||
| int | count, | ||
| const vec3 | camera_pos | ||
| ) |
Sorts the array of instances Back-to-Front (descending depth) on GPU.
Uploads instances to an SSBO, sorts them using a compute shader, and prepares them for rendering.
| sorter | Memory context. |
| instances | Pointer to the array of instances to upload. |
| count | Active element count. |
| camera_pos | World-space viewer position. |