diff --git a/Assets/TD_Checker_Base_Color.dds b/Assets/TD_Checker_Base_Color.dds new file mode 100644 index 00000000..9dcbfeee Binary files /dev/null and b/Assets/TD_Checker_Base_Color.dds differ diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index e01e2489..c9506a8e 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -81,6 +81,7 @@ namespace Sandbox SHADE::SHAssetManager::LoadDataTemp("../../Assets/racoon.fbx"); SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonBag_Color_Ver4.dds"); SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.dds"); + SHADE::SHAssetManager::LoadDataTemp("../../Assets/TD_Checker_Base_Color.dds"); //TODO: REMOVE AFTER PRESENTATION // Set up graphics system and windows diff --git a/SHADE_Application/src/Scenes/SBTestScene.cpp b/SHADE_Application/src/Scenes/SBTestScene.cpp index c90d660b..6ac6cd3d 100644 --- a/SHADE_Application/src/Scenes/SBTestScene.cpp +++ b/SHADE_Application/src/Scenes/SBTestScene.cpp @@ -68,11 +68,11 @@ namespace Sandbox auto matInst = graphicsSystem->AddOrGetBaseMaterialInstance(); // Create Stress Test Objects - static const SHVec3 TEST_OBJ_SCALE = { 0.2f, 0.2f, 0.2f }; - constexpr int NUM_ROWS = 1; - constexpr int NUM_COLS = 1; - static const SHVec3 TEST_OBJ_SPACING = { 1.0f, 1.0f, 1.0f }; - static const SHVec3 TEST_OBJ_START_POS = { - (NUM_COLS / 2 * TEST_OBJ_SPACING.x ), 0.0f, 0.0f }; + static const SHVec3 TEST_OBJ_SCALE = { 0.05f, 0.05f, 0.05f }; + constexpr int NUM_ROWS = 2; + constexpr int NUM_COLS = 2; + static const SHVec3 TEST_OBJ_SPACING = { 20.0f, 20.0f, 20.0f }; + static const SHVec3 TEST_OBJ_START_POS = { - (NUM_COLS / 2 * TEST_OBJ_SPACING.x ) + 15.0f, 0.0f, -2.0f }; //for (int z = 0; z < NUM_ROWS; ++z) //for (int x = 0; x < NUM_COLS; ++x) //{ @@ -85,26 +85,28 @@ namespace Sandbox // // Set initial positions // transform.SetWorldPosition(TEST_OBJ_START_POS + SHVec3{ x * TEST_OBJ_SPACING.x, 0.0f, z * TEST_OBJ_SPACING.z }); - // //transform.SetLocalScale(TEST_OBJ_SCALE); + // transform.SetWorldRotation(3.14159265f * 1.5f, -3.14159265f / 2.0f, 0.0f); + // transform.SetLocalScale(TEST_OBJ_SCALE); // stressTestObjects.emplace_back(entity); //} - auto entity = SHEntityManager::CreateEntity(); - auto& renderable = *SHComponentManager::GetComponent_s(entity); - auto& transform = *SHComponentManager::GetComponent_s(entity); + auto entity = SHEntityManager::CreateEntity(); + auto& renderable = *SHComponentManager::GetComponent_s(entity); + auto& transform = *SHComponentManager::GetComponent_s(entity); - renderable.Mesh = handles.front(); - renderable.SetMaterial(matInst); + renderable.Mesh = handles.front(); + renderable.SetMaterial(matInst); - //transform.SetLocalScale(TEST_OBJ_SCALE); + transform.SetWorldPosition({0.0f, 0.0f, -1.0f}); + transform.SetLocalScale(TEST_OBJ_SCALE); - stressTestObjects.emplace_back(entity); + stressTestObjects.emplace_back(entity); // Create blank entity with a script - testObj = SHADE::SHEntityManager::CreateEntity(); - SHADE::SHScriptEngine* scriptEngine = static_cast(SHADE::SHSystemManager::GetSystem()); - scriptEngine->AddScript(testObj, "TestScript"); + //testObj = SHADE::SHEntityManager::CreateEntity(); + //SHADE::SHScriptEngine* scriptEngine = static_cast(SHADE::SHSystemManager::GetSystem()); + //scriptEngine->AddScript(testObj, "TestScript"); } void SBTestScene::Update(float dt) @@ -115,16 +117,17 @@ namespace Sandbox transform.SetLocalRotation(rotation, 0.0f, 0.0f); rotation += dt * 10.0f;*/ - /*static float rotation = 0.0f; + static float rotation = 0.0f; - auto& transform = *SHADE::SHComponentManager::GetComponent_s(stressTestObjects[0]); + auto& transform = *SHADE::SHComponentManager::GetComponent_s(stressTestObjects[0]); - transform.SetWorldPosition({rotation, 0.0f, 0.0f}); - rotation += dt * 10.0f;*/ + transform.SetWorldRotation(0.0f, 0.0f + rotation, 0.0f); + rotation += dt * 0.2f; // Destroy entity if space is pressed if (GetKeyState(VK_SPACE) & 0x8000) { + rotation = 0.0f; SHADE::SHScriptEngine* scriptEngine = static_cast(SHADE::SHSystemManager::GetSystem()); scriptEngine->RemoveAllScripts(testObj); } @@ -132,6 +135,7 @@ namespace Sandbox void SBTestScene::Render() { + } void SBTestScene::Unload() diff --git a/SHADE_Engine/src/Editor/SHEditor.cpp b/SHADE_Engine/src/Editor/SHEditor.cpp index 34ebe6a6..17f7d720 100644 --- a/SHADE_Engine/src/Editor/SHEditor.cpp +++ b/SHADE_Engine/src/Editor/SHEditor.cpp @@ -292,7 +292,7 @@ namespace SHADE imguiCommandBuffer->EndRecording(); gfxSystem->GetQueue()->SubmitCommandBuffer({ imguiCommandBuffer }, {}, {}, vk::PipelineStageFlagBits::eNone, {}); - ImGui_ImplVulkan_DestroyFontUploadObjects(); + //ImGui_ImplVulkan_DestroyFontUploadObjects(); renderGraph->GetNode("ImGui Node")->GetSubpass("ImGui Draw")->AddExteriorDrawCalls([](Handle& cmd) { ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmd->GetVkCommandBuffer()); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHCamera.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHCamera.cpp index 4a1117c3..2abdfa86 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHCamera.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHCamera.cpp @@ -23,22 +23,40 @@ namespace SHADE { SHVec3 view = target - pos; view = SHVec3::Normalise(view); SHVec3 right = SHVec3::Cross(view, up); right = SHVec3::Normalise(right); - const SHVec3 UP = SHVec3::Cross(right, view); + const SHVec3 UP = SHVec3::Cross(view, right); + //viewMatrix = SHMatrix::Identity; + //viewMatrix(0, 0) = UP[0]; + //viewMatrix(1, 0) = UP[1]; + //viewMatrix(2, 0) = UP[2]; + //viewMatrix(0, 1) = right[0]; + //viewMatrix(1, 1) = right[1]; + //viewMatrix(2, 1) = right[2]; + //viewMatrix(0, 2) = view[0]; + //viewMatrix(1, 2) = view[1]; + //viewMatrix(2, 2) = view[2]; + //viewMatrix(3, 0) = -UP.Dot(pos); + //viewMatrix(3, 1) = -right.Dot(pos); + //viewMatrix(3, 2) = -view.Dot(pos); + viewMatrix = SHMatrix::Identity; - viewMatrix(0, 0) = UP[0]; - viewMatrix(1, 0) = UP[1]; - viewMatrix(2, 0) = UP[2]; - viewMatrix(0, 1) = right[0]; - viewMatrix(1, 1) = right[1]; - viewMatrix(2, 1) = right[2]; - viewMatrix(0, 2) = view[0]; - viewMatrix(1, 2) = view[1]; - viewMatrix(2, 2) = view[2]; - viewMatrix(3, 0) = -UP.Dot(pos); - viewMatrix(3, 1) = -right.Dot(pos); - viewMatrix(3, 2) = -view.Dot(pos); - + viewMatrix(0, 0) = right[0]; + viewMatrix(0, 1) = right[1]; + viewMatrix(0, 2) = right[2]; + + viewMatrix(1, 0) = UP[0]; + viewMatrix(1, 1) = UP[1]; + viewMatrix(1, 2) = UP[2]; + + viewMatrix(2, 0) = view[0]; + viewMatrix(2, 1) = view[1]; + viewMatrix(2, 2) = view[2]; + + viewMatrix(0, 3) = -right.Dot(pos); + viewMatrix(1, 3) = -UP.Dot(pos); + viewMatrix(2, 3) = -view.Dot(pos); + + isDirty = true; } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index df80222a..3d1a49a0 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -119,7 +119,7 @@ namespace SHADE screenCamera->SetOrthographic(static_cast(windowDims.first), static_cast(windowDims.second), 0.01f, 100.0f); worldCamera = resourceManager.Create(); //worldCamera->SetLookAt(SHVec3(1.0f, 0.0f, -1.0f), SHVec3(0.0f, 0.0f, 2.0f), SHVec3(0.0f, 1.0f, 0.0f)); - worldCamera->SetLookAt(SHVec3(0.0f, 5.0f, -1.0f), SHVec3(0.0f, 0.0f, 2.0f), SHVec3(0.0f, 1.0f, 0.0f)); + worldCamera->SetLookAt(SHVec3(0.0f, 0.0f, 0.0f), SHVec3(0.0f, 0.0f, -2.0f), SHVec3(0.0f, 1.0f, 0.0f)); worldCamera->SetPerspective(90.0f, static_cast(windowDims.first), static_cast(windowDims.second), 0.0f, 100.0f); // Create Default Viewport @@ -136,17 +136,19 @@ namespace SHADE // Initialize world render graph worldRenderGraph->Init(device, swapchain, globalData); + worldRenderGraph->AddResource("Depth Buffer", SH_ATT_DESC_TYPE::DEPTH_STENCIL, windowDims.first, windowDims.second, swapchain->GetDepthFormat()); //worldRenderGraph->AddResource("Position", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat); //worldRenderGraph->AddResource("Normals", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat); //worldRenderGraph->AddResource("Composite", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eR16G16B16A16Sfloat); - worldRenderGraph->AddResource("Scene", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eB8G8R8A8Unorm); + //worldRenderGraph->AddResource("Scene", SH_ATT_DESC_TYPE::COLOR, windowDims.first, windowDims.second, vk::Format::eB8G8R8A8Unorm); worldRenderGraph->AddResource("Present", SH_ATT_DESC_TYPE::COLOR_PRESENT, windowDims.first, windowDims.second); - auto node = worldRenderGraph->AddNode("G-Buffer", { /*"Composite", "Position", */"Present" }, {}); // no predecessors + auto node = worldRenderGraph->AddNode("G-Buffer", { /*"Composite", "Position", */"Depth Buffer", "Present" }, {}); // no predecessors //First subpass to write to G-Buffer auto gBufferWriteSubpass = node->AddSubpass("G-Buffer Write"); //gBufferWriteSubpass->AddColorOutput("Scene"); gBufferWriteSubpass->AddColorOutput("Present"); + gBufferWriteSubpass->AddDepthOutput ("Depth Buffer", SH_ATT_DESC_TYPE::DEPTH_STENCIL); //writeSubpass->AddColorOutput("Normals"); // //Second subpass to read from G-Buffer diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp index db75af6a..709e15d2 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp @@ -226,33 +226,63 @@ namespace SHADE vk::Format SHTextureLibrary::ddsLoaderToVkFormat(tinyddsloader::DDSFile::DXGIFormat format, bool isLinear) { - switch (format) - { - case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm_SRGB: - return isLinear ? vk::Format::eBc1RgbaUnormBlock : vk::Format::eBc1RgbaSrgbBlock; - case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm_SRGB: - return isLinear ? vk::Format::eBc2UnormBlock : vk::Format::eBc2SrgbBlock; - case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm_SRGB: - return isLinear ? vk::Format::eBc3UnormBlock : vk::Format::eBc3SrgbBlock; - case tinyddsloader::DDSFile::DXGIFormat::BC5_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::BC5_SNorm: - return isLinear ? vk::Format::eBc5UnormBlock : vk::Format::eBc5SnormBlock; - case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm_SRGB: - return isLinear ? vk::Format::eR8G8B8A8Unorm : vk::Format::eR8G8B8A8Srgb; - case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_SNorm: - return vk::Format::eR8G8B8A8Snorm; - case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm_SRGB: - return isLinear ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8A8Srgb; - case tinyddsloader::DDSFile::DXGIFormat::B8G8R8X8_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::B8G8R8X8_UNorm_SRGB: - return isLinear ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8Srgb; - default: - throw std::runtime_error("Unsupported DDS format."); - } + switch (format) + { + case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm: + return vk::Format::eBc1RgbaUnormBlock; + case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm_SRGB: + return vk::Format::eBc1RgbaSrgbBlock; + case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm: + case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm_SRGB: + return isLinear ? vk::Format::eBc2UnormBlock : vk::Format::eBc2SrgbBlock; + case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm: + case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm_SRGB: + return isLinear ? vk::Format::eBc3UnormBlock : vk::Format::eBc3SrgbBlock; + case tinyddsloader::DDSFile::DXGIFormat::BC5_UNorm: + case tinyddsloader::DDSFile::DXGIFormat::BC5_SNorm: + return isLinear ? vk::Format::eBc5UnormBlock : vk::Format::eBc5SnormBlock; + case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm: + case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm_SRGB: + return isLinear ? vk::Format::eR8G8B8A8Unorm : vk::Format::eR8G8B8A8Srgb; + case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_SNorm: + return vk::Format::eR8G8B8A8Snorm; + case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm: + case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm_SRGB: + return isLinear ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8A8Srgb; + case tinyddsloader::DDSFile::DXGIFormat::B8G8R8X8_UNorm: + case tinyddsloader::DDSFile::DXGIFormat::B8G8R8X8_UNorm_SRGB: + return isLinear ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8Srgb; + default: + throw std::runtime_error("Unsupported DDS format."); + } + + //switch (format) + //{ + //case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm: + //case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm_SRGB: + // return (isLinear) ? vk::Format::eR8G8B8A8Unorm : vk::Format::eR8G8B8A8Srgb; + // + + //case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm: + //case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm_SRGB: + // return (isLinear) ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8A8Srgb; + // + + //case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm: + //case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm_SRGB: + // return (isLinear) ? vk::Format::eBc1RgbaUnormBlock : vk::Format::eBc1RgbaSrgbBlock; + + //case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm: + //case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm_SRGB: + // return (isLinear) ? vk::Format::eBc2UnormBlock : vk::Format::eBc2SrgbBlock; + + //case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm: + //case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm_SRGB: + // return (isLinear) ? vk::Format::eBc3UnormBlock : vk::Format::eBc3SrgbBlock; + + //case tinyddsloader::DDSFile::DXGIFormat::BC5_UNorm: + // return (isLinear) ? vk::Format::eBc5UnormBlock : vk::Format::eBc5SnormBlock; + // + //} } } diff --git a/TempShaderFolder/TestCubeFs.glsl b/TempShaderFolder/TestCubeFs.glsl index 7d49eda4..a8d0df3c 100644 --- a/TempShaderFolder/TestCubeFs.glsl +++ b/TempShaderFolder/TestCubeFs.glsl @@ -1,13 +1,14 @@ #version 450 #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable +#extension GL_EXT_nonuniform_qualifier : require layout(location = 0) in struct { //mat3 BTN; vec4 vertColor; //vec3 localSpacePosition; - //vec2 uv; + vec2 uv; //vec3 localLightPosition; //vec3 localEyePosition; @@ -31,42 +32,11 @@ layout(location = 0) out vec4 outColor; //layout(binding = 3) uniform sampler2D glossinessMap; //layout(binding = 4) uniform sampler2D samplerRoughnessMap; +layout (set = 0, binding = 1) uniform sampler2D textures[]; + void main() { - //vec3 normal; - - //// Get the tangent space normal from normal map. It is a BC5 texture and therefore only use red and green - //normal.xy = (texture (normalMap, In.uv).gr * 2.0f) - 1.0f; - - //// z value is derived (TODO: Find out what this does) - //normal.z = sqrt(1.0f - dot(normal.xy, normal.xy)); - - //// Transform the normal from tangent space to local space - //normal = In.BTN * normal; - - //// Get the vector from fragment to light - //vec3 localLightDir = normalize(In.localLightPosition - In.localSpacePosition); - - //// get the value of dot between normal from texture and frag to light - //float diffuse = max(0, dot(normal, localLightDir)); - - //// sample the diffuse texture - //vec4 diffuseColor = texture (diffuseMap, In.uv) * In.vertColor; - - //vec3 eyeDirection = normalize(In.localSpacePosition - In.localEyePosition); - - //const float shininess = mix(1, 100, 1 - texture (samplerRoughnessMap, In.uv).r); - - //float specular = pow(max(0, dot(normal, normalize(localLightDir - eyeDirection))), shininess); - - //outColor.rgb = testPushConstant.ambientColor.rgb * diffuseColor.rgb * texture (aoMap, In.uv).rgb; - - //outColor.rgb += testPushConstant.lightColor.rgb * (specular.rrr * 0.4 + diffuse.rrr * diffuseColor.rgb); - - //const float gamma = testPushConstant.eyePosition.w; - //outColor.rgb = pow(outColor.rgb, vec3(1.0f / gamma)); - //outColor.a = diffuseColor.a; - - - outColor = vec4 (1.0f); + vec4 color; + color = (texture (textures[1], In.uv)); + outColor = color; } \ No newline at end of file diff --git a/TempShaderFolder/TestCubeFs.spv b/TempShaderFolder/TestCubeFs.spv index 669dc8b8..4ca2a59d 100644 Binary files a/TempShaderFolder/TestCubeFs.spv and b/TempShaderFolder/TestCubeFs.spv differ diff --git a/TempShaderFolder/TestCubeVs.glsl b/TempShaderFolder/TestCubeVs.glsl index b2d52104..de84adf6 100644 --- a/TempShaderFolder/TestCubeVs.glsl +++ b/TempShaderFolder/TestCubeVs.glsl @@ -24,7 +24,7 @@ layout(location = 0) out struct //mat3 BTN; vec4 vertColor; //vec3 localSpacePosition; - //vec2 uv; + vec2 uv; //vec3 localLightPosition; //vec3 localEyePosition; @@ -57,6 +57,7 @@ void main() // render NDC first //gl_Position = vec4(aVertexPos, 1.0f); + Out.uv = aUV; gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f); Out.vertColor = vec4 (aVertexPos, 1.0f); } \ No newline at end of file diff --git a/TempShaderFolder/TestCubeVs.spv b/TempShaderFolder/TestCubeVs.spv index eb9a1209..4b1ddac1 100644 Binary files a/TempShaderFolder/TestCubeVs.spv and b/TempShaderFolder/TestCubeVs.spv differ