From 1a26b0ac70a616a85f5a0e5fec69c50c4cabb037 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Wed, 23 Nov 2022 09:57:55 +0800 Subject: [PATCH 1/5] When no GPU is detected, a proper exception describing it is now thrown instead of failing silently --- .../src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 03ca0b3d..bd1d60cd 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -61,8 +61,13 @@ namespace SHADE SHVkInstance::Init(true, false, true); #endif - // Get Physical Device and Construct Logical Device + // Get Physical Device physicalDevice = SHVkInstance::CreatePhysicalDevice(SH_PHYSICAL_DEVICE_TYPE::BEST); + if (!physicalDevice->GetVkPhysicalDevice()) + { + throw std::runtime_error("[Graphics System] No supported Vulkan 1.3 compatible GPU was detected!"); + } + // Construct Logical Device device = SHVkInstance::CreateLogicalDevice({ SHQueueParams(SH_Q_FAM::GRAPHICS, SH_QUEUE_SELECT::DEDICATED), SHQueueParams(SH_Q_FAM::TRANSFER, SH_QUEUE_SELECT::DEDICATED) }, physicalDevice); // Construct surface From 67db7448564f71c6acedcd31dc20cdabc3029159 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Wed, 23 Nov 2022 10:08:48 +0800 Subject: [PATCH 2/5] Uninitialized List<> will no longer cause crashes with the script inspector --- Assets/Scripts/RaccoonShowcase.cs | 1 + SHADE_Managed/src/Editor/Editor.cxx | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Assets/Scripts/RaccoonShowcase.cs b/Assets/Scripts/RaccoonShowcase.cs index 1da191fd..424a8a3e 100644 --- a/Assets/Scripts/RaccoonShowcase.cs +++ b/Assets/Scripts/RaccoonShowcase.cs @@ -23,6 +23,7 @@ public class RaccoonShowcase : Script [Range(-5, 5)] public List intList = new List(new int[] { 2, 8, 2, 6, 8, 0, 1 }); public List enumList = new List(new Light.Type[] { Light.Type.Point, Light.Type.Directional, Light.Type.Ambient }); + public List nullList; public FontAsset fontAsset; public MeshAsset mesh; public MaterialAsset matAsset; diff --git a/SHADE_Managed/src/Editor/Editor.cxx b/SHADE_Managed/src/Editor/Editor.cxx index 29e3da36..80c73d4f 100644 --- a/SHADE_Managed/src/Editor/Editor.cxx +++ b/SHADE_Managed/src/Editor/Editor.cxx @@ -189,6 +189,12 @@ namespace SHADE System::Type^ listType = field->FieldType->GenericTypeArguments[0]; RangeAttribute^ rangeAttrib = hasAttribute(field); System::Collections::IList^ iList = safe_cast(field->GetValue(object)); + if (iList == nullptr) + { + // Create if the list does not exist + iList = safe_cast(System::Activator::CreateInstance(field->FieldType)); + field->SetValue(object, iList); + } if (SHEditorUI::CollapsingHeader(Convert::ToNative(field->Name), &isHovered)) { From 0edd2f24e35c45c4f49c431c9e737f8a50da8711 Mon Sep 17 00:00:00 2001 From: Xiao Qi Date: Wed, 23 Nov 2022 13:02:33 +0800 Subject: [PATCH 3/5] Added VS and FS shaders to tile singular textures Added shader stage flag bit for vertex shaders --- Assets/Shaders/TestCube_Tile_FS.glsl | 48 ++++++++++++ Assets/Shaders/TestCube_Tile_FS.shshaderb | Bin 0 -> 2185 bytes .../Shaders/TestCube_Tile_FS.shshaderb.shmeta | 3 + Assets/Shaders/TestCube_Tile_VS.glsl | 74 ++++++++++++++++++ Assets/Shaders/TestCube_Tile_VS.shshaderb | Bin 0 -> 4205 bytes .../Shaders/TestCube_Tile_VS.shshaderb.shmeta | 3 + .../GlobalData/SHGraphicsGlobalData.cpp | 2 +- 7 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 Assets/Shaders/TestCube_Tile_FS.glsl create mode 100644 Assets/Shaders/TestCube_Tile_FS.shshaderb create mode 100644 Assets/Shaders/TestCube_Tile_FS.shshaderb.shmeta create mode 100644 Assets/Shaders/TestCube_Tile_VS.glsl create mode 100644 Assets/Shaders/TestCube_Tile_VS.shshaderb create mode 100644 Assets/Shaders/TestCube_Tile_VS.shshaderb.shmeta diff --git a/Assets/Shaders/TestCube_Tile_FS.glsl b/Assets/Shaders/TestCube_Tile_FS.glsl new file mode 100644 index 00000000..84403a7c --- /dev/null +++ b/Assets/Shaders/TestCube_Tile_FS.glsl @@ -0,0 +1,48 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable +#extension GL_EXT_nonuniform_qualifier : require + +struct MatPropData +{ + vec2 tileMult; + uint textureIndex; +}; + +layout(location = 0) in struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + +} In; + +// material stuff +layout(location = 3) flat in struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; +} In2; + +layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) +layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials +{ + MatPropData data[]; +} MatProp; + +layout(location = 0) out vec4 position; +layout(location = 1) out uint outEntityID; +layout(location = 2) out uint lightLayerIndices; +layout(location = 3) out vec4 normals; +layout(location = 4) out vec4 albedo; + +void main() +{ + position = In.vertPos; + normals = In.normal; + albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); + + outEntityID = In2.eid; + lightLayerIndices = In2.lightLayerIndex; +} \ No newline at end of file diff --git a/Assets/Shaders/TestCube_Tile_FS.shshaderb b/Assets/Shaders/TestCube_Tile_FS.shshaderb new file mode 100644 index 0000000000000000000000000000000000000000..c7444c7d62831fed446340965286f26e5e41220e GIT binary patch literal 2185 zcmY+FTXPge6vrF(LJYSc0wNM8#5)==21F67LXlciwG=61sc%!mP7_)uGwV!mioE%u z)ED3URK8f{|JO4uLsy+W*FKkjpQ&B>ZOMc)IJthxm=k8%oHY+xleu6{%3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Q1vv8L+xdMxRdJpC~2cLwZzvq!% z5og_EW03xBxOF%6X5G%Nb$L$rj2U$nT!C4KSk$YZF=FNpKV`A14`XFM{jB8<+`aVK zL$vrbn!56%_;|J!9g(2d+)reCoa*G2``p6mseR7+hP_|0J^esmFeM zknAApOgyVpUudBvxYoN4XqP15%nuu(`K&!K*##B8EuK(-EBapcM z>b@;8d)0!Ugp%a;S^du-nQIzSe+RCwH5jix1Bp$c&%(9Yv;9Q+-o&PmeOKz{c@OTn z#LT1Kt}*QwYq{#dcybBdI@GiR^E z{mAC<%|s5rJK~Y!X=HQw&di~%k9Oz$Ip_$a-5dwt&qLy&zliL-|3!@UV~{@L=Cn6r z;r|-4nEG+}8<4a6A@MEvn~<0*u(y!KypO<6)tGm)K!>K`Z$rlGuiZEBCwaA3@b zK1Mc=c*J~yEH1h3jrkPJ81qETXUO7`D`FNngYWut$Xd*;uQTF%5%=8sd;y86Tl-hg zmymaoK&((r|1L^N_Fa5+KZUs5w_8~`H2iZ95H%>pXi2D{f z;`|0h+$yqh_QW{-#A4>IAxE6&n?}ze@#x`qH74$|2J<-wp8xwA^Si5W)YL_e+|3@W zfg9tpCjG=Bu7@0P%^vi@V=v?M6N|V(Bd*zlAL_X1fqr7~UD-tTyRsXKS-*}f9{LUB z7ohmA+(gz#Jm%sS@(Cz<|0A-PE3luC#q42VKi8P`#kb=ZWaIVMeiHh#eowz5yT3kh UkGGLGpdFCCQP=N3b~*|D4~}t61^@s6 literal 0 HcmV?d00001 diff --git a/Assets/Shaders/TestCube_Tile_VS.shshaderb.shmeta b/Assets/Shaders/TestCube_Tile_VS.shshaderb.shmeta new file mode 100644 index 00000000..0603263f --- /dev/null +++ b/Assets/Shaders/TestCube_Tile_VS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: TestCube_Tile_VS +ID: 44231040 +Type: 2 diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.cpp index d0fbaf2c..87234a6b 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.cpp @@ -90,7 +90,7 @@ namespace SHADE SHVkDescriptorSetLayout::Binding materialDataBinding { .Type = vk::DescriptorType::eStorageBufferDynamic, - .Stage = vk::ShaderStageFlagBits::eFragment, + .Stage = vk::ShaderStageFlagBits::eFragment | vk::ShaderStageFlagBits::eVertex, .BindPoint = SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, .DescriptorCount = 1, }; From 8ad46afc22446ba6671be28aedf0a0f4733816ce Mon Sep 17 00:00:00 2001 From: Xiao Qi Date: Wed, 23 Nov 2022 13:06:50 +0800 Subject: [PATCH 4/5] Removed spaces from UI Test scene to stop regenerating of asset meta --- Assets/Scenes/{UI Test.shade => UI_Test.shade} | 0 Assets/Scenes/{UI Test.shade.shmeta => UI_Test.shade.shmeta} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename Assets/Scenes/{UI Test.shade => UI_Test.shade} (100%) rename Assets/Scenes/{UI Test.shade.shmeta => UI_Test.shade.shmeta} (60%) diff --git a/Assets/Scenes/UI Test.shade b/Assets/Scenes/UI_Test.shade similarity index 100% rename from Assets/Scenes/UI Test.shade rename to Assets/Scenes/UI_Test.shade diff --git a/Assets/Scenes/UI Test.shade.shmeta b/Assets/Scenes/UI_Test.shade.shmeta similarity index 60% rename from Assets/Scenes/UI Test.shade.shmeta rename to Assets/Scenes/UI_Test.shade.shmeta index cf38916e..8b8d6f22 100644 --- a/Assets/Scenes/UI Test.shade.shmeta +++ b/Assets/Scenes/UI_Test.shade.shmeta @@ -1,3 +1,3 @@ -Name: UI Test +Name: UI_Test ID: 87707373 Type: 5 From 1402139369b9d553b2ddc102816ea9f03c1525d8 Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Wed, 23 Nov 2022 13:30:28 +0800 Subject: [PATCH 5/5] Fixed bug where colliders were not properly added with editor enabled --- .../src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp | 6 ++---- SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp | 7 +++++++ .../src/Physics/System/SHPhysicsSystemRoutines.cpp | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp index bd68de82..7c111a2d 100644 --- a/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp +++ b/SHADE_Engine/src/Physics/PhysicsObject/SHPhysicsObjectManager.cpp @@ -250,9 +250,7 @@ namespace SHADE } // A static rigid body is implicitly created on creation of a physics object. - // We only need to sync rigid bodies here in the event it is non-static. - - physicsObject->SyncRigidBody(*componentGroup.rigidBodyComponent); + // Nothing is needed here. } void SHPhysicsObjectManager::addCollider(const QueueCommand&, SHPhysicsObject* physicsObject, const PhysicsComponentGroup& componentGroup) @@ -269,7 +267,7 @@ namespace SHADE //for (int i = 0; i < NUM_SHAPES; ++i) // physicsObject->AddCollisionShape(i); - //physicsObject->SyncColliders(*componentGroup.colliderComponent); + physicsObject->SyncColliders(*componentGroup.colliderComponent); } void SHPhysicsObjectManager::removeRigidBody(const QueueCommand&, SHPhysicsObject* physicsObject, const PhysicsComponentGroup& componentGroup) diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp index 89be2614..2df5c496 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystem.cpp @@ -411,7 +411,14 @@ namespace SHADE objectManager.AddRigidBody(EID); if (SHComponentManager::HasComponent(EID)) + { objectManager.AddCollider(EID); + + auto* COLLIDER = SHComponentManager::GetComponent(EID); + for (size_t i = 0; i < COLLIDER->GetCollisionShapes().size(); ++i) + objectManager.AddCollisionShape(EID, i); + } + }; //////////////////////////////// diff --git a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp index 24bd2f81..1d070f00 100644 --- a/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp +++ b/SHADE_Engine/src/Physics/System/SHPhysicsSystemRoutines.cpp @@ -255,6 +255,8 @@ namespace SHADE // Sync transforms & physics components transforms if (transformComponent && transformComponent->HasChanged()) { + physicsObject.GetRigidBody()->setIsSleeping(false); + preUpdateSyncTransform ( physicsObject