Scene changes and Bug fixes #336
|
@ -60,7 +60,7 @@ float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV
|
|||
|
||||
if (fragPosLightPOV.z > sampledDepth && fragPosLightPOV.w > 0.0f)
|
||||
{
|
||||
return 0.0f;
|
||||
return 0.7f;
|
||||
}
|
||||
else
|
||||
return 1.0f;
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,10 @@
|
|||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
#extension GL_EXT_nonuniform_qualifier : require
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: ShadowMap_FS
|
||||
ID: 45925790
|
||||
Type: 2
|
|
@ -5,6 +5,7 @@
|
|||
//#define SHEDITOR
|
||||
#ifdef SHEDITOR
|
||||
#include "Editor/SHEditor.h"
|
||||
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
|
||||
//#include "Scenes/SBEditorScene.h"
|
||||
#endif // SHEDITOR
|
||||
|
||||
|
@ -31,7 +32,6 @@
|
|||
#include "Input/SHInputManager.h"
|
||||
#include "Math/Transform/SHTransformSystem.h"
|
||||
#include "Physics/System/SHPhysicsSystem.h"
|
||||
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
|
||||
#include "Scripting/SHScriptEngine.h"
|
||||
#include "UI/SHUISystem.h"
|
||||
#include "Animation/SHAnimationSystem.h"
|
||||
|
@ -74,12 +74,15 @@ namespace Sandbox
|
|||
#endif
|
||||
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, wndData);
|
||||
|
||||
|
||||
SHAssetManager::Load();
|
||||
|
||||
// Create Systems
|
||||
|
||||
SHSystemManager::CreateSystem<SHScriptEngine>();
|
||||
SHSystemManager::CreateSystem<SHTransformSystem>();
|
||||
SHSystemManager::CreateSystem<SHPhysicsSystem>();
|
||||
#ifndef _PUBLISH
|
||||
#ifdef SHEDITOR
|
||||
SHSystemManager::CreateSystem<SHPhysicsDebugDrawSystem>();
|
||||
#endif
|
||||
|
||||
|
@ -122,7 +125,7 @@ namespace Sandbox
|
|||
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsUpdate>();
|
||||
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsPostUpdate>();
|
||||
|
||||
#ifndef _PUBLISH
|
||||
#ifdef SHEDITOR
|
||||
SHSystemManager::RegisterRoutine<SHPhysicsDebugDrawSystem, SHPhysicsDebugDrawSystem::PhysicsDebugDraw>();
|
||||
#endif
|
||||
|
||||
|
@ -155,7 +158,6 @@ namespace Sandbox
|
|||
SHComponentManager::CreateComponentSparseSet<SHAnimatorComponent>();
|
||||
//SHComponentManager::CreateComponentSparseSet<SHCameraComponent>();
|
||||
|
||||
SHAssetManager::Load();
|
||||
//auto font = SHAssetManager::GetData<SHFontAsset>(176667660);
|
||||
|
||||
SHSystemManager::RegisterRoutine<SHAudioSystem, SHAudioSystem::AudioRoutine>();
|
||||
|
|
|
@ -200,7 +200,9 @@ namespace SHADE
|
|||
void SHAudioSystem::ErrorCheck() const
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
std::cerr << "Audio system error: " << FMOD_ErrorString(result) << std::endl;
|
||||
{
|
||||
SHLOG_ERROR( "Audio system error: {}", FMOD_ErrorString(result))
|
||||
}
|
||||
}
|
||||
|
||||
void SHAudioSystem::PlayEventOnce(const char* path, bool isSFX, EntityID eid, bool spatial)
|
||||
|
@ -319,6 +321,15 @@ namespace SHADE
|
|||
if (channel->isPlaying(&isPlaying) == FMOD_OK && isPlaying)
|
||||
channel->stop();
|
||||
}
|
||||
auto [begin, end] = audioClipLibrary.GetDenseAccess();
|
||||
for (auto it = begin; it != end; ++it)
|
||||
{
|
||||
if (it->instance)
|
||||
{
|
||||
it->instance->stop(FMOD_STUDIO_STOP_MODE::FMOD_STUDIO_STOP_IMMEDIATE);
|
||||
it->instance->release();
|
||||
}
|
||||
}
|
||||
masterGroup->stop();
|
||||
}
|
||||
|
||||
|
@ -349,6 +360,10 @@ namespace SHADE
|
|||
audioClipHandle = audioClipLibrary.Create();
|
||||
it->second->createInstance(&audioClipHandle->instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
SHLOG_ERROR("FMOD: Failed to find event path: {}", path)
|
||||
}
|
||||
|
||||
return audioClipHandle;
|
||||
}
|
||||
|
@ -487,10 +502,12 @@ namespace SHADE
|
|||
}
|
||||
void SHAudioSystem::SetBgmVolume(float const bgmvol)
|
||||
{
|
||||
bgmVolume = bgmvol;
|
||||
bgmChannelGroup->setVolume(bgmvol);
|
||||
}
|
||||
void SHAudioSystem::SetSfxVolume(float const sfxvol)
|
||||
{
|
||||
sfxVolume = sfxvol;
|
||||
sfxChannelGroup->setVolume(sfxvol);
|
||||
}
|
||||
void SHAudioSystem::SetMasterVolume(float const mastervol)
|
||||
|
@ -506,15 +523,12 @@ namespace SHADE
|
|||
{
|
||||
channel->setPaused(paused);
|
||||
}
|
||||
for (auto const& event : eventMap)
|
||||
auto [begin, end] = audioClipLibrary.GetDenseAccess();
|
||||
for (auto it = begin; it != end; ++it)
|
||||
{
|
||||
int instanceCount = 0;
|
||||
event.second->getInstanceCount(&instanceCount);
|
||||
std::vector<FMOD::Studio::EventInstance*> instances(instanceCount);
|
||||
event.second->getInstanceList(instances.data(), static_cast<int>(instances.size()), &instanceCount);
|
||||
for (auto const& instance : instances)
|
||||
if (it->instance)
|
||||
{
|
||||
instance->setPaused(pause);
|
||||
it->SetPause(pause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -546,6 +560,7 @@ namespace SHADE
|
|||
bank->loadSampleData();
|
||||
int numOfEvents;
|
||||
bank->getEventCount(&numOfEvents);
|
||||
|
||||
if (numOfEvents > 0)
|
||||
{
|
||||
std::vector<FMOD::Studio::EventDescription*> events(numOfEvents);
|
||||
|
@ -560,11 +575,71 @@ namespace SHADE
|
|||
}
|
||||
}
|
||||
|
||||
float SHAudioSystem::GetVCAVolume(const char* path)
|
||||
{
|
||||
FMOD::Studio::VCA* vca = nullptr;
|
||||
result = fmodStudioSystem->getVCA(path, &vca);
|
||||
float volume = 0.0f;
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
ErrorCheck();
|
||||
return volume;
|
||||
}
|
||||
result = vca->getVolume(&volume);
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
ErrorCheck();
|
||||
return volume;
|
||||
}
|
||||
return volume;
|
||||
}
|
||||
|
||||
void SHAudioSystem::SetVCAVolume(const char* path, float value)
|
||||
{
|
||||
FMOD::Studio::VCA* vca = nullptr;
|
||||
result = fmodStudioSystem->getVCA(path, &vca);
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
ErrorCheck();
|
||||
return;
|
||||
}
|
||||
result = vca->setVolume(std::clamp(value, 0.0f, 1.0f));
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
ErrorCheck();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float SHAudioSystem::GetParameterValue(const char* path)
|
||||
{
|
||||
float value = {};
|
||||
result = fmodStudioSystem->getParameterByName(path, &value);
|
||||
if(result != FMOD_OK)
|
||||
{
|
||||
ErrorCheck();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void SHAudioSystem::SetParameter(const char* path, float value)
|
||||
{
|
||||
result = fmodStudioSystem->setParameterByName(path, value);
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
ErrorCheck();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioClip::Play()
|
||||
{
|
||||
if(!instance)
|
||||
return;
|
||||
instance->start();
|
||||
FMOD_RESULT result = instance->start();
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
|
||||
}
|
||||
}
|
||||
|
||||
//void AudioClip::Play(bool isSfx)
|
||||
|
@ -598,7 +673,11 @@ namespace SHADE
|
|||
{
|
||||
if (!instance)
|
||||
return;
|
||||
instance->stop(fadeOut ? FMOD_STUDIO_STOP_ALLOWFADEOUT : FMOD_STUDIO_STOP_IMMEDIATE);
|
||||
FMOD_RESULT result = instance->stop(fadeOut ? FMOD_STUDIO_STOP_ALLOWFADEOUT : FMOD_STUDIO_STOP_IMMEDIATE);
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
|
||||
}
|
||||
}
|
||||
|
||||
void AudioClip::SetPause(bool pause)
|
||||
|
@ -623,7 +702,11 @@ namespace SHADE
|
|||
{
|
||||
if (!instance)
|
||||
return;
|
||||
instance->setParameterByName(paramName, value);
|
||||
FMOD_RESULT result = instance->setParameterByName(paramName, value);
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
|
||||
}
|
||||
}
|
||||
|
||||
//void AudioClip::SetParameterLabel(const char* paramName, const char* label)
|
||||
|
@ -635,11 +718,31 @@ namespace SHADE
|
|||
|
||||
float AudioClip::GetParameterValue(const char* paramName)
|
||||
{
|
||||
if (!instance)
|
||||
return {};
|
||||
float value{};
|
||||
instance->getParameterByName(paramName, &value);
|
||||
if (!instance)
|
||||
return value;
|
||||
auto result = instance->getParameterByName(paramName, &value);
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
float AudioClip::GetVolume()
|
||||
{
|
||||
float volume{};
|
||||
if(!instance)
|
||||
return volume;
|
||||
instance->getVolume(&volume);
|
||||
return volume;
|
||||
}
|
||||
|
||||
void AudioClip::SetVolume(float volume)
|
||||
{
|
||||
if(!instance)
|
||||
return;
|
||||
instance->setVolume(volume);
|
||||
}
|
||||
|
||||
SHEventHandle SHAudioSystem::onStop(SHEventPtr onStopEvent)
|
||||
|
|
|
@ -35,6 +35,8 @@ namespace SHADE
|
|||
void SetParameter(const char* paramName, float value);
|
||||
//void SetParameterLabel(const char* paramName, const char* label);
|
||||
float GetParameterValue(const char* paramName);
|
||||
float GetVolume();
|
||||
void SetVolume(float volume);
|
||||
friend class SHAudioSystem;
|
||||
private:
|
||||
FMOD::Studio::EventInstance* instance = nullptr;
|
||||
|
@ -85,7 +87,13 @@ namespace SHADE
|
|||
void SetPaused(bool pause);
|
||||
bool GetPaused() const;
|
||||
SHVec3 GetListenerPosition();
|
||||
|
||||
void LoadBank(const char* path);
|
||||
float GetVCAVolume(const char* path);
|
||||
void SetVCAVolume(const char* path, float value);
|
||||
|
||||
float GetParameterValue(const char* path);
|
||||
void SetParameter(const char* path, float value);
|
||||
|
||||
private:
|
||||
FMOD::Studio::System* fmodStudioSystem;
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace SHADE
|
|||
|
||||
if (systemContainer.find(id) == systemContainer.end())
|
||||
{
|
||||
std::cout << "System Manager error: System Version " << version << " does not exit." << std::endl;
|
||||
std::cout << "System Manager error: System Version " << typeid(T).name() << ", " << version << " does not exist." << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ namespace SHADE
|
|||
SHFreetypeInstance::Init();
|
||||
|
||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false);
|
||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/ShadowMap_FS.glsl", false);
|
||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false);
|
||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/SSAOBlur_CS.glsl", false);
|
||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false);
|
||||
|
@ -137,6 +138,7 @@ namespace SHADE
|
|||
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false);
|
||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false);
|
||||
|
||||
|
||||
// Load Built In Shaders
|
||||
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
|
||||
static constexpr AssetID VS_ANIM = 47911992; animtVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_ANIM);
|
||||
|
@ -152,6 +154,7 @@ namespace SHADE
|
|||
static constexpr AssetID RENDER_SC_VS = 48082949; renderToSwapchainVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(RENDER_SC_VS);
|
||||
static constexpr AssetID RENDER_SC_FS = 36869006; renderToSwapchainFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(RENDER_SC_FS);
|
||||
static constexpr AssetID SHADOW_MAP_VS = 44646107; shadowMapVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_VS);
|
||||
static constexpr AssetID SHADOW_MAP_FS = 45925790; shadowMapFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_FS);
|
||||
|
||||
}
|
||||
|
||||
|
@ -583,14 +586,21 @@ namespace SHADE
|
|||
#endif
|
||||
}
|
||||
|
||||
//if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::B))
|
||||
//{
|
||||
// auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
|
||||
static bool shadowAdded = false;
|
||||
|
||||
if (shadowAdded == false/* && SHInputManager::GetKey(SHInputManager::SH_KEYCODE::B)*/)
|
||||
{
|
||||
shadowAdded = true;
|
||||
auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
|
||||
if (lightComps.size() > 2)
|
||||
{
|
||||
lightComps[2].SetEnableShadow(true);
|
||||
}
|
||||
//for (auto& comp : lightComps)
|
||||
//{
|
||||
// comp.SetEnableShadow(true);
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
||||
renderGraph->Begin(frameIndex);
|
||||
auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);
|
||||
|
@ -809,11 +819,11 @@ namespace SHADE
|
|||
tempLibrary.Init(device);
|
||||
tempLibrary.CreateGraphicsPipelines
|
||||
(
|
||||
{ shadowMapVS, {} }, shadowMapNode->GetRenderpass(), newSubpass,
|
||||
{ shadowMapVS, shadowMapFS }, shadowMapNode->GetRenderpass(), newSubpass,
|
||||
SHGraphicsPredefinedData::SystemType::BATCHING,
|
||||
SHGraphicsPredefinedData::GetShadowMapViState(), rasterState
|
||||
);
|
||||
shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, {} });
|
||||
shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, shadowMapFS });
|
||||
}
|
||||
newSubpass->SetCompanionSubpass(companionSubpass, shadowMapPipeline); // set companion subpass and pipeline
|
||||
|
||||
|
|
|
@ -469,6 +469,7 @@ namespace SHADE
|
|||
Handle<SHVkShaderModule> renderToSwapchainVS;
|
||||
Handle<SHVkShaderModule> renderToSwapchainFS;
|
||||
Handle<SHVkShaderModule> shadowMapVS;
|
||||
Handle<SHVkShaderModule> shadowMapFS;
|
||||
|
||||
// Fonts
|
||||
Handle<SHFont> testFont;
|
||||
|
|
|
@ -170,10 +170,7 @@ namespace SHADE
|
|||
SHCollisionListener collisionListener;
|
||||
SHRaycaster raycaster;
|
||||
|
||||
// For the debug drawer to draw rays
|
||||
#ifdef SHEDITOR
|
||||
std::vector<RaycastHit> raycastHits;
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Function Members */
|
||||
|
|
|
@ -261,6 +261,7 @@ namespace SHADE
|
|||
<TargetFramework>net5.0</TargetFramework>\n\
|
||||
<Platforms>x64</Platforms>\n\
|
||||
<Configurations>Release;Debug</Configurations>\n\
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);**/*.shmeta</DefaultItemExcludes>\n\
|
||||
</PropertyGroup>\n\
|
||||
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n\
|
||||
<OutputPath>.\\bin\\Release</OutputPath>\n\
|
||||
|
@ -283,7 +284,6 @@ namespace SHADE
|
|||
<ItemGroup>\n\
|
||||
<None Remove=\".gitignore\" />\n\
|
||||
<None Remove=\".gitmodules\" />\n\
|
||||
<None Remove=\"*.shmeta\" />\n\
|
||||
</ItemGroup>\n\
|
||||
<ItemGroup>\n\
|
||||
<Reference Include=\"SHADE_Managed\">\n";
|
||||
|
|
|
@ -99,6 +99,31 @@ namespace SHADE
|
|||
audioSys->StopAllSounds();
|
||||
}
|
||||
|
||||
float Audio::GetVCAVolume(System::String^ path)
|
||||
{
|
||||
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
|
||||
|
||||
return audioSys->GetVCAVolume(Convert::ToNative(path).data());
|
||||
}
|
||||
|
||||
void Audio::SetVCAVolume(System::String^ path, float volume)
|
||||
{
|
||||
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
|
||||
audioSys->SetVCAVolume(Convert::ToNative(path).data(), volume);
|
||||
}
|
||||
|
||||
float Audio::GetParameterValue(System::String^ path)
|
||||
{
|
||||
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
|
||||
return audioSys->GetParameterValue(Convert::ToNative(path).data());
|
||||
}
|
||||
|
||||
void Audio::SetParameter(System::String^ path, float value)
|
||||
{
|
||||
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
|
||||
audioSys->SetParameter(Convert::ToNative(path).data(), value);
|
||||
}
|
||||
|
||||
AudioClipHandler Audio::CreateAudioClip(System::String^ path)
|
||||
{
|
||||
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
|
||||
|
|
|
@ -101,6 +101,10 @@ namespace SHADE
|
|||
/// </summary>
|
||||
static void StopAllSounds();
|
||||
|
||||
static float GetVCAVolume(System::String^ path);
|
||||
static void SetVCAVolume(System::String^ path, float volume);
|
||||
static float GetParameterValue(System::String^ path);
|
||||
static void SetParameter(System::String^ path, float value);
|
||||
|
||||
//to comment ltr
|
||||
static AudioClipHandler CreateAudioClip(System::String^ path);
|
||||
|
|
|
@ -84,6 +84,14 @@ namespace SHADE
|
|||
return NativeObject->GetParameterValue(Convert::ToNative(paramName).data());
|
||||
}
|
||||
|
||||
float AudioClipHandler::GetVolume()
|
||||
{
|
||||
return NativeObject->GetVolume();
|
||||
}
|
||||
|
||||
void AudioClipHandler::SetVolume(float volume)
|
||||
{
|
||||
NativeObject->SetVolume(volume);
|
||||
}
|
||||
|
||||
}
|
|
@ -72,6 +72,8 @@ namespace SHADE
|
|||
bool IsPaused();
|
||||
void SetParameter(System::String^ paramName, float value);
|
||||
float GetParameterValue(System::String^ paramName);
|
||||
float GetVolume();
|
||||
void SetVolume(float volume);
|
||||
|
||||
protected:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -28,25 +28,32 @@ namespace SHADE
|
|||
/*---------------------------------------------------------------------------------*/
|
||||
bool Application::IsPlaying::get()
|
||||
{
|
||||
#ifdef SHEDITOR
|
||||
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||
if (editor)
|
||||
return editor->editorState == SHEditor::State::PLAY
|
||||
||
|
||||
editor->editorState == SHEditor::State::PAUSE;
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
bool Application::IsPaused::get()
|
||||
{
|
||||
#ifdef SHEDITOR
|
||||
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||
if (editor)
|
||||
return editor->editorState == SHEditor::State::PAUSE;
|
||||
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
bool Application::IsEditor::get()
|
||||
{
|
||||
#ifdef SHEDITOR
|
||||
return SHSystemManager::GetSystem<SHEditor>() != nullptr;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
int Application::WindowWidth::get()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue