Implemented improved shadows (still abit whack), trajectory system (untested), and window resize event #352

Merged
Xenosas1337 merged 7 commits from SP3-1-Rendering into main 2023-02-20 14:35:25 +08:00
6 changed files with 44 additions and 2 deletions
Showing only changes of commit 15df08ef67 - Show all commits

View File

@ -12,6 +12,7 @@
#include "Editor/SHEditor.h"
#include "Math/SHRay.h"
#include "Physics/System/SHPhysicsSystem.h"
#include "Graphics/Events/SHGraphicsEvents.h"
namespace SHADE
@ -122,6 +123,13 @@ namespace SHADE
SHComponentManager::CreateComponentSparseSet<SHCameraComponent>();
SHComponentManager::CreateComponentSparseSet<SHCameraArmComponent>();
std::shared_ptr<SHEventReceiverSpec<SHCameraSystem>> thisReceiver
{
std::make_shared<SHEventReceiverSpec<SHCameraSystem>>(this, &SHCameraSystem::ReceiveWindowResizeEvent)
};
ReceiverPtr receiver = std::dynamic_pointer_cast<SHEventReceiver>(thisReceiver);
SHEventManager::SubscribeTo(SH_WINDOW_RESIZE_EVENT, receiver);
}
@ -130,6 +138,16 @@ namespace SHADE
}
SHEventHandle SHCameraSystem::ReceiveWindowResizeEvent(SHEventPtr eventPtr) noexcept
{
auto const& EVENT_DATA = reinterpret_cast<const SHEventSpec<SHWindowResizeEvent>*>(eventPtr.get())->data;
//std::cout << EVENT_DATA->resizeWidth << std::endl;
//std::cout << EVENT_DATA->resizeHeight << std::endl;
return eventPtr->handle;
}
SHCameraComponent* SHCameraSystem::GetEditorCamera(void) noexcept
{
return &editorCamera;

View File

@ -46,6 +46,11 @@ namespace SHADE
};
friend class CameraSystemUpdate;
/*-----------------------------------------------------------------------*/
/* Light functions */
/*-----------------------------------------------------------------------*/
SHEventHandle ReceiveWindowResizeEvent(SHEventPtr eventPtr) noexcept;
SHCameraComponent* GetEditorCamera (void) noexcept;
void GetCameraAxis(SHCameraComponent const& camera, SHVec3& forward, SHVec3& right, SHVec3& up) const noexcept;

View File

@ -25,4 +25,5 @@ constexpr SHEventIdentifier SH_SCENE_EXIT_POST { 16 };
constexpr SHEventIdentifier SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT { 17 };
constexpr SHEventIdentifier SH_BUTTON_CLICK_EVENT { 18 };
constexpr SHEventIdentifier SH_PHYSICS_COLLIDER_DRAW_EVENT { 19 };
constexpr SHEventIdentifier SH_WINDOW_RESIZE_EVENT { 20 };

View File

@ -14,4 +14,13 @@ namespace SHADE
//! Generate a renderer for the light component
bool generateRenderer;
};
struct SHWindowResizeEvent
{
// New width when window resizes
uint32_t resizeWidth;
// New height when window resizes
uint32_t resizeHeight;
};
}

View File

@ -138,8 +138,8 @@ namespace SHADE
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_VS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/Trajectory_VS.glsl", false);
SHAssetManager::CompileAsset("../../Assets/Shaders/Trajectory_FS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/Trajectory_VS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/Trajectory_FS.glsl", false);
// Load Built In Shaders
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
@ -1178,6 +1178,14 @@ namespace SHADE
#ifdef SHEDITOR
cameraSystem->GetEditorCamera()->SetWidth(static_cast<float>(resizeWidth));
cameraSystem->GetEditorCamera()->SetHeight(static_cast<float>(resizeHeight));
// Create new event and broadcast it
SHWindowResizeEvent newEvent;
newEvent.resizeWidth = resizeWidth;
newEvent.resizeHeight = resizeHeight;
SHEventManager::BroadcastEvent<SHWindowResizeEvent>(newEvent, SH_WINDOW_RESIZE_EVENT);
#else
#endif

View File

@ -1,3 +1,4 @@
#include "SHpch.h"
#include "SHParticleSubSustem.h"
namespace SHADE