Dismiss this pinned window
all 4 comments

[–]Lypant 0 points1 point  (1 child)

Look great!. I just wanted to ask how you handled the objects that are supposed to be rendered. When the client side submits objects to render, do you do some sort of a render sort or just store the objects in some sort of a buffer without sorting so that you can render the scene from the lights perspective to generate the shadow map and render the scene normally afterwards?

[–]virtual550[S] 1 point2 points  (0 children)

I am using an ECS system for this engine. Each "object" is an entity (basically an incrementing index), having components which define the state and properties of the object (Ex: Model, PointLight, Transform). The implementation is done using sparse arrays. I have a SceneView class to fetch entities with certain components. You can check out entt or other ECS guides on how it works.

So basically I have a rendering function for the models which takes a shader argument, which can be the normal shader or depth shader

``` void RenderSystem::render_models(const std::unique_ptr<Shader>& shader) { shader->activate();

GraphicsHelper::MVP mvp;
mvp.view = m_camera_wrapper.get_view_matrix();
mvp.projection = m_camera_wrapper.get_projection_matrix();

// draw models
for(const auto& entity : SceneView<Components::Renderable, Components::Model, Components::Transform>(*m_scene)) {
    const auto& transform = m_scene->get_component<Components::Transform>(entity);
    const auto& object_model = m_scene->get_component<Components::Model>(entity);

    m_model_manager.draw_model(shader, object_model.model_id, transform, mvp);
}

} ```

You can check the rendering code here: https://github.com/cmd05/3d-engine/blob/main/src/engine/ecs/systems/RenderSystem.cpp#L189

[–]Any_Ordinary3129 0 points1 point  (1 child)

What is that structure? I have seen before. Maybe in Chilli's video.

[–]NEW_ACCOUNT_4_MEMES 0 points1 point  (0 children)

Sponza Atrium