Depth-tested 3D billboard sprite batch. More...
#include <mxvk/include/mxvk/mxvk_sprite3d.hpp>
Public Member Functions | |
| void | cleanup () |
| Destroy all owned Vulkan resources. | |
| void | clearQueue () |
| Discard all queued sprite draws without rendering them. | |
| void | drawSprite (const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &color=glm::vec4(1.0f), float rotationRadians=0.0f) |
| Queue a billboard sprite for rendering. | |
| int | getHeight () const |
| int | getWidth () const |
| void | load (VK_Window *window, const std::string &pngPath, const std::string &vertexShaderPath="", const std::string &fragmentShaderPath="") |
| Load sprite texture and build the 3D billboard pipeline from a PNG file. | |
| void | load (VK_Window *window, SDL_Surface *surface, const std::string &vertexShaderPath="", const std::string &fragmentShaderPath="") |
| Load sprite texture and build the 3D billboard pipeline from an SDL surface. | |
| bool | loaded () const |
| VK_Sprite3D & | operator= (const VK_Sprite3D &)=delete |
| VK_Sprite3D & | operator= (VK_Sprite3D &&)=delete |
| void | render (VkCommandBuffer cmd, uint32_t imageIndex) |
| Record all queued billboard draws into the given command buffer. | |
| void | resize (VK_Window *window) |
| Rebuild swapchain-dependent resources after resize. | |
| void | setAlphaDiscardThreshold (float threshold) |
| Set the alpha threshold used to discard transparent texels. | |
| void | setDepthTestEnabled (bool enabled) |
| Enable or disable depth testing for the 3D sprite pipeline. | |
| void | setDepthWriteEnabled (bool enabled) |
| Enable or disable depth writes for the 3D sprite pipeline. | |
| void | updateCamera (uint32_t imageIndex, const glm::mat4 &view, const glm::mat4 &proj) |
| Upload the current camera matrices for one swapchain image. | |
| VK_Sprite3D ()=default | |
| Construct an empty 3D sprite batch. | |
| VK_Sprite3D (const VK_Sprite3D &)=delete | |
| VK_Sprite3D (VK_Sprite3D &&)=delete | |
| ~VK_Sprite3D () | |
| Destroy owned Vulkan resources. | |
Depth-tested 3D billboard sprite batch.
VK_Sprite3D renders textured quads in world space. Each queued sprite is camera-facing, uses the view/projection matrix supplied with updateCamera(), and participates in the same dynamic-rendering pass as models.
Definition at line 33 of file mxvk_sprite3d.hpp.
|
default |
Construct an empty 3D sprite batch.
| mxvk::VK_Sprite3D::~VK_Sprite3D | ( | ) |
Destroy owned Vulkan resources.
Definition at line 30 of file mxvk_sprite3d.cpp.
|
delete |
|
delete |
| void mxvk::VK_Sprite3D::cleanup | ( | ) |
Destroy all owned Vulkan resources.
Definition at line 191 of file mxvk_sprite3d.cpp.
| void mxvk::VK_Sprite3D::clearQueue | ( | ) |
Discard all queued sprite draws without rendering them.
Definition at line 145 of file mxvk_sprite3d.cpp.
| void mxvk::VK_Sprite3D::drawSprite | ( | const glm::vec3 & | position, |
| const glm::vec2 & | size, | ||
| const glm::vec4 & | color = glm::vec4(1.0f), | ||
| float | rotationRadians = 0.0f ) |
Queue a billboard sprite for rendering.
| position | World-space center position. |
| size | Billboard size in world units. |
| color | Per-sprite tint color. |
| rotationRadians | Rotation around the camera-facing axis. |
Definition at line 101 of file mxvk_sprite3d.cpp.
|
inlinenodiscard |
Definition at line 140 of file mxvk_sprite3d.hpp.
|
inlinenodiscard |
Definition at line 138 of file mxvk_sprite3d.hpp.
| void mxvk::VK_Sprite3D::load | ( | VK_Window * | window, |
| const std::string & | pngPath, | ||
| const std::string & | vertexShaderPath = "", | ||
| const std::string & | fragmentShaderPath = "" ) |
Load sprite texture and build the 3D billboard pipeline from a PNG file.
| window | Active MXVK window. |
| pngPath | Path to the PNG file. |
| vertexShaderPath | Optional custom vertex shader SPIR-V path. |
| fragmentShaderPath | Optional custom fragment shader SPIR-V path. |
Definition at line 34 of file mxvk_sprite3d.cpp.
| void mxvk::VK_Sprite3D::load | ( | VK_Window * | window, |
| SDL_Surface * | surface, | ||
| const std::string & | vertexShaderPath = "", | ||
| const std::string & | fragmentShaderPath = "" ) |
Load sprite texture and build the 3D billboard pipeline from an SDL surface.
| window | Active MXVK window. |
| surface | Source surface pointer. |
| vertexShaderPath | Optional custom vertex shader SPIR-V path. |
| fragmentShaderPath | Optional custom fragment shader SPIR-V path. |
Definition at line 47 of file mxvk_sprite3d.cpp.
|
inlinenodiscard |
true if the sprite texture and pipeline are loaded. Definition at line 136 of file mxvk_sprite3d.hpp.
|
delete |
|
delete |
| void mxvk::VK_Sprite3D::render | ( | VkCommandBuffer | cmd, |
| uint32_t | imageIndex ) |
Record all queued billboard draws into the given command buffer.
| cmd | Active command buffer. |
| imageIndex | Current swapchain image index. |
Definition at line 114 of file mxvk_sprite3d.cpp.
| void mxvk::VK_Sprite3D::resize | ( | VK_Window * | window | ) |
Rebuild swapchain-dependent resources after resize.
| window | Active MXVK window. |
Definition at line 169 of file mxvk_sprite3d.cpp.
|
inline |
Set the alpha threshold used to discard transparent texels.
| threshold | Alpha cutoff value. |
Definition at line 122 of file mxvk_sprite3d.hpp.
| void mxvk::VK_Sprite3D::setDepthTestEnabled | ( | bool | enabled | ) |
Enable or disable depth testing for the 3D sprite pipeline.
| enabled | true to enable depth testing. |
Definition at line 149 of file mxvk_sprite3d.cpp.
| void mxvk::VK_Sprite3D::setDepthWriteEnabled | ( | bool | enabled | ) |
Enable or disable depth writes for the 3D sprite pipeline.
| enabled | true to write depth values. |
Definition at line 159 of file mxvk_sprite3d.cpp.
| void mxvk::VK_Sprite3D::updateCamera | ( | uint32_t | imageIndex, |
| const glm::mat4 & | view, | ||
| const glm::mat4 & | proj ) |
Upload the current camera matrices for one swapchain image.
| imageIndex | Swapchain image index. |
| view | View matrix. |
| proj | Projection matrix. |
Definition at line 90 of file mxvk_sprite3d.cpp.