Skip to content

Commit

Permalink
Implementing render features
Browse files Browse the repository at this point in the history
* started working on implementing proper render features
* lighting and engine UBO render features added
* working on entity base class for OvRendering
* dealing with camera issues
* added OvSandbox applicaton to test rendering changes
  • Loading branch information
adriengivry committed Nov 28, 2023
1 parent fd0834d commit 840edbf
Show file tree
Hide file tree
Showing 63 changed files with 1,909 additions and 963 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* @project: Overload
* @author: Overload Tech.
* @licence: MIT
*/

#pragma once

#include <map>
#include <chrono>

#include <OvRendering/Features/ARenderFeature.h>
#include <OvRendering/Buffers/UniformBuffer.h>
#include <OvRendering/Entities/Camera.h>

namespace OvCore::Rendering
{
/**
* Render feature handling engine buffer (UBO) updates
*/
class EngineBufferRenderFeature : public OvRendering::Features::ARenderFeature
{
public:
/**
* Constructor
* @param p_renderer
*/
EngineBufferRenderFeature(OvRendering::Core::CompositeRenderer& p_renderer);

/**
* Upload view data to the GPU
* @param p_camera
* @param p_windowWidth
* @param p_windowHeight
*/
void UploadViewData(
OvRendering::Entities::Camera& p_camera,
uint16_t p_windowWidth,
uint16_t p_windowHeight
);

/**
* Invoked before drawing, handle uploading entity data to the GPU
* @param p_drawable
*/
virtual void OnBeforeDraw(const OvRendering::Entities::Drawable& p_drawable) override;

/**
* Invoked at the beginning of a frame, bind the engine buffer and update elapsed time
* @param p_outputDesc
*/
virtual void OnBeginFrame(std::optional<OvRendering::Data::RenderOutputDesc>& p_outputDesc) override;

/**
* Invoked at the end of a frame, unbind the engine buffer
*/
virtual void OnEndFrame() override;

private:
std::chrono::high_resolution_clock::time_point m_startTime;
std::unique_ptr<OvRendering::Buffers::UniformBuffer> m_engineBuffer;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "OvCore/ECS/Components/CCamera.h"
#include "OvCore/SceneSystem/Scene.h"

namespace OvCore::ECS
namespace OvCore::Rendering
{
/**
* Extension of the ImmediateRenderer adding support for the scene system
Expand Down Expand Up @@ -48,30 +48,13 @@ namespace OvCore::ECS
* @param p_scene
* @param p_viewportWidth
* @param p_viewportHeight
* @param p_defaultMaterial
* @param p_materialOverride
*/
void RenderScene(
OvCore::SceneSystem::Scene& p_scene,
uint16_t p_viewportWidth,
uint16_t p_viewportHeight,
OvCore::Resources::Material* p_defaultMaterial = nullptr
);

protected:
/**
* Draw the given scene using the given default material (optional) if no material found on an actor
* @param p_scene
* @param p_cameraPosition
* @param p_camera
* @param p_customFrustum
* @param p_defaultMaterial
*/
void RenderScene(
OvCore::SceneSystem::Scene& p_scene,
const OvMaths::FVector3& p_cameraPosition,
const OvRendering::Entities::Camera& p_camera,
const OvRendering::Data::Frustum* p_customFrustum = nullptr,
OvCore::Resources::Material* p_defaultMaterial = nullptr
std::optional<std::reference_wrapper<OvCore::Resources::Material>> p_materialOverride = std::nullopt
);

/**
Expand All @@ -92,44 +75,47 @@ namespace OvCore::ECS
*/
void UpdateLightsInFrustum(OvCore::SceneSystem::Scene& p_scene, const OvRendering::Data::Frustum& p_frustum);

/**
* Returns opaque and transparents drawables from the scene with frustum culling
* @param p_scene
* @param p_cameraPosition
* @param p_frustum
* @param p_defaultMaterial
*/
std::pair<OpaqueDrawables, TransparentDrawables> FindAndSortFrustumCulledDrawables(
const OvCore::SceneSystem::Scene& p_scene,
const OvMaths::FVector3& p_cameraPosition,
const OvRendering::Data::Frustum& p_frustum,
OvCore::Resources::Material* p_defaultMaterial
);

/**
* Returns opaque and transparents drawables from the scene
* @param p_scene
* @param p_cameraPosition
* @param p_defaultMaterial
* @param p_frustum
* @param p_materialOverride
*/
std::pair<OpaqueDrawables, TransparentDrawables> FindAndSortDrawables(
const OvCore::SceneSystem::Scene& p_scene,
const OvMaths::FVector3& p_cameraPosition,
OvCore::Resources::Material* p_defaultMaterial
std::optional<OvRendering::Data::Frustum> p_frustum = std::nullopt,
std::optional<std::reference_wrapper<OvCore::Resources::Material>> p_materialOverride = std::nullopt
);

/**
* Draw the model using the given material (The material will be applied to every submeshes of the the model)
* @param p_model
* @param p_material
* @param p_modelMatrix
* @param p_defaultMaterial (Used if the given material has no shader attached)
* @param p_materialOverride (Used if the given material has no shader attached)
*/
void DrawModelWithSingleMaterial(
OvRendering::Resources::Model& p_model,
OvCore::Resources::Material& p_material,
OvMaths::FMatrix4 const* p_modelMatrix,
OvCore::Resources::Material* p_defaultMaterial = nullptr
std::optional<std::reference_wrapper<OvCore::Resources::Material>> p_materialOverride = std::nullopt
);

private:
/**
* Draw the given scene using the given default material (optional) if no material found on an actor
* @param p_scene
* @param p_camera
* @param p_frustumOverride
* @param p_materialOverride
*/
void RenderScene(
OvCore::SceneSystem::Scene& p_scene,
const OvRendering::Entities::Camera& p_camera,
std::optional<OvRendering::Data::Frustum> p_frustumOverride = std::nullopt,
std::optional<std::reference_wrapper<OvCore::Resources::Material>> p_materialOverride = std::nullopt
);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include "OvCore/ECS/Components/CCamera.h"
#include "OvCore/ECS/Actor.h"

OvCore::ECS::Components::CCamera::CCamera(ECS::Actor& p_owner) : AComponent(p_owner)
OvCore::ECS::Components::CCamera::CCamera(ECS::Actor& p_owner)
: AComponent(p_owner), m_camera(&p_owner.transform.GetFTransform())
{
/* Default clear color for the CCamera (Different from Camera default clear color) */
SetClearColor({ 0.1921569f, 0.3019608f, 0.4745098f });
Expand Down
Loading

0 comments on commit 840edbf

Please sign in to comment.