diff --git a/src/tz/ren/animation2.cpp b/src/tz/ren/animation2.cpp index c0a3793ddf..47825ef6a3 100644 --- a/src/tz/ren/animation2.cpp +++ b/src/tz/ren/animation2.cpp @@ -17,7 +17,8 @@ namespace tz::ren .custom_fragment_spirv = i.custom_fragment_spirv.empty() ? ImportedShaderSource(animation, fragment) : i.custom_fragment_spirv, .custom_options = i.custom_options, .texture_capacity = i.texture_capacity, - .extra_buffers = this->evaluate_extra_buffers(i) + .extra_buffers = this->evaluate_extra_buffers(i), + .output = i.output }) { diff --git a/src/tz/ren/animation2.hpp b/src/tz/ren/animation2.hpp index 04c3376eb1..1df4145d1c 100644 --- a/src/tz/ren/animation2.hpp +++ b/src/tz/ren/animation2.hpp @@ -6,15 +6,19 @@ namespace tz::ren { - // an extension of mesh_renderer2. - // this supports loading all the meshes and textures at once from a gltf. - // once you load a gltf, you get a gltf_handle. - // you can use a gltf_handle to create a set of objects corresponding to the gltf nodes. - // this set of objects is called an animated object. once you create one, you get a animated_objects_handle. - // animated_objects_handles represent a single animated object, but that may be comprised of many static subobjects (mesh_renderer2 objects) in a hierarchy. - // some of these subobjects have meshes attached which are ultimately drawn, but many of them wont. - // you can spawn multiple animated objects from the same gltf. they will share the same meshes and textures, but their objects will be unique. - // this means you can have separate copies of the same animated model undergoing different points of the animations at once. + /** + * @ingroup tz_ren + * A superset of @ref mesh_renderer2 + * an extension of mesh_renderer2. + * this supports loading all the meshes and textures at once from a gltf. + * once you load a gltf, you get a gltf_handle. + * you can use a gltf_handle to create a set of objects corresponding to the gltf nodes. + * this set of objects is called an animated object. once you create one, you get a animated_objects_handle. + * animated_objects_handles represent a single animated object, but that may be comprised of many static subobjects (mesh_renderer2 objects) in a hierarchy. + * some of these subobjects have meshes attached which are ultimately drawn, but many of them wont. + * you can spawn multiple animated objects from the same gltf. they will share the same meshes and textures, but their objects will be unique. + * this means you can have separate copies of the same animated model undergoing different points of the animations at once. + */ class animation_renderer2 : private mesh_renderer2 { public: @@ -26,11 +30,18 @@ namespace tz::ren using animated_objects_handle = tz::handle; struct info { + /// String representing SPIRV for the vertex shader. If empty, a default vertex shader is used. std::string_view custom_vertex_spirv = {}; + /// String representing SPIRV for the fragment shader. If empty, a default fragment shader is used - displays the textured objects with no lighting effects. std::string_view custom_fragment_spirv = {}; + /// If you want more fine-grained control over the created graphics renderer pass (such as if you want to add a post-process effect), you can add extra options here. tz::gl::renderer_options custom_options = {}; + /// Maximum number of textures. Note that this capacity cannot be expanded - make sure you never exceed this limit. std::size_t texture_capacity = 1024u; + /// A list of extra buffer resources. These buffers will be resident to both the vertex and fragment shader. Resource ID of the first extra buffer will be `3` ascending. std::vector extra_buffers = {}; + /// Optional output. Use this if you want to render into a specific render target. If this is nullptr, it will render directly into the window instead. + tz::gl::ioutput* output = nullptr; }; animation_renderer2(info i); animation_renderer2(); diff --git a/src/tz/ren/mesh2.hpp b/src/tz/ren/mesh2.hpp index 341b4c89f8..f5173a6e57 100644 --- a/src/tz/ren/mesh2.hpp +++ b/src/tz/ren/mesh2.hpp @@ -432,6 +432,26 @@ namespace tz::ren /** * @ingroup tz_ren * A lightweight 3D mesh renderer. If you'd like to render animated models, you're looking for @ref animation_renderer2. + * + * Mesh Renderers are comprised of three major components: + * + * - Represents a triangulated set of indices and vertices. These are necessary to give shape to drawn geometry. + * - First you must fill in the data of a `mesh_renderer2::mesh`, and then add it using `mesh_renderer2::add_mesh`. Keep ahold of the returned `mesh_handle`. + * + * + * - Represents an image that is sampled when drawing a mesh. + * - First you must fill the data of a `tz::io::image`, in the format `tz::gl::image_format::RGBA32`, and then add it using `mesh_renderer2::add_texture`. Keep ahold of the returned `texture_handle`. + * + * + * - Represents a "thing" that is drawn in the 3D world. + * - Objects can have zero or more child objects. That is - objects are expressed as a graph, you can have as many root nodes as you like, and each object can have as many children as you like. + * - At its core, objects are comprised of: + * - A local transform (its position, rotation and scale with respect to its parent) + * - (Optional) A mesh (when you draw the object, what geometry should be drawn as its location?). + * - If you don't want the object to be drawn, and just to exist as a node within the hierarchy, you can set the mesh to null. + * - A list of bound textures. These textures will be sampled from when drawing the object's associated mesh. + * - The list should have a size less-than-or-equal to the value `tz::ren::impl::object_data::max_bound_textures`. Any excess texture locators will be ignored. + * - To add a new object to the 3D world, invoke `mesh_renderer2::add_object`. Keep ahold of the returned `object_handle`. */ class mesh_renderer2 : public impl::render_pass {