Skip to content

Commit

Permalink
[ren] mesh_renderer2 and animation_renderer2 documentation pass
Browse files Browse the repository at this point in the history
  • Loading branch information
harrand committed Oct 29, 2023
1 parent 552f130 commit c4d71ab
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/tz/ren/animation2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
{

Expand Down
29 changes: 20 additions & 9 deletions src/tz/ren/animation2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -26,11 +30,18 @@ namespace tz::ren
using animated_objects_handle = tz::handle<object_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<tz::gl::buffer_resource> 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();
Expand Down
20 changes: 20 additions & 0 deletions src/tz/ren/mesh2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* <Mesh>
* - 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`.
*
* <Texture>
* - 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`.
*
* <Object>
* - 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
{
Expand Down

0 comments on commit c4d71ab

Please sign in to comment.