From df5b2b6795a3c90b28cf73ca48f7993d31c8944b Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Fri, 13 Mar 2026 22:30:46 +0100 Subject: [PATCH] Minor changes --- external/vcpkg | 2 +- res/shaders/lib/Common.slang | 50 ++--------------------------------- res/shaders/lib/Frustum.slang | 47 ++++++++++++++++++++++++++++++++ src/Benchmark/main.cpp | 10 +------ src/Editor/main.cpp | 4 --- 5 files changed, 51 insertions(+), 62 deletions(-) create mode 100644 res/shaders/lib/Frustum.slang diff --git a/external/vcpkg b/external/vcpkg index f9a99aa..ce35b1a 160000 --- a/external/vcpkg +++ b/external/vcpkg @@ -1 +1 @@ -Subproject commit f9a99aa79c1309001e36572fa42d7d8edebfc451 +Subproject commit ce35b1a53aac26d7fcdb8ee1ef7a8e4eea02d27b diff --git a/res/shaders/lib/Common.slang b/res/shaders/lib/Common.slang index 80ddad3..3ed67ae 100644 --- a/res/shaders/lib/Common.slang +++ b/res/shaders/lib/Common.slang @@ -1,3 +1,5 @@ +import Frustum; + const static float PI = 3.1415926535897932f; const static uint BLOCK_SIZE = 32; static const uint64_t MAX_TEXCOORDS = 8; @@ -96,51 +98,3 @@ float4 clipToScreen(float4 clip) float zf = pz * ndc.z + oz; return float4(texCoords * pViewParams.screenDimensions, zf, 1.0f); } - -struct Plane -{ - float4 nd; - float3 getNormal() - { - return nd.xyz; - } - float getDistance() - { - return nd.w; - } - bool pointInside(float3 point) - { - return dot(getNormal(), point) - getDistance() > 0.0f; - } -}; - -struct Frustum -{ - Plane sides[4]; - bool pointInside(float3 point) - { - for(int p = 0; p < 4; ++p) - { - if(!sides[p].pointInside(point)) - { - return false; - } - } - return true; - } -}; -Plane computePlane(float3 p0, float3 p1, float3 p2) -{ - Plane plane; - - float3 v0 = p1 - p0; - float3 v2 = p2 - p0; - - float3 n = normalize(cross(v0, v2)); - - float d = dot(n, p0); - - plane.nd = float4(n, d); - - return plane; -} diff --git a/res/shaders/lib/Frustum.slang b/res/shaders/lib/Frustum.slang new file mode 100644 index 0000000..cc00875 --- /dev/null +++ b/res/shaders/lib/Frustum.slang @@ -0,0 +1,47 @@ +struct Plane +{ + float4 nd; + float3 getNormal() + { + return nd.xyz; + } + float getDistance() + { + return nd.w; + } + bool pointInside(float3 point) + { + return dot(getNormal(), point) - getDistance() > 0.0f; + } +}; + +struct Frustum +{ + Plane sides[4]; + bool pointInside(float3 point) + { + for(int p = 0; p < 4; ++p) + { + if(!sides[p].pointInside(point)) + { + return false; + } + } + return true; + } +}; +Plane computePlane(float3 p0, float3 p1, float3 p2) +{ + Plane plane; + + float3 v0 = p1 - p0; + float3 v2 = p2 - p0; + + float3 n = normalize(cross(v0, v2)); + + float d = dot(n, p0); + + plane.nd = float4(n, d); + + return plane; +} \ No newline at end of file diff --git a/src/Benchmark/main.cpp b/src/Benchmark/main.cpp index 695e3d8..4d2cf01 100644 --- a/src/Benchmark/main.cpp +++ b/src/Benchmark/main.cpp @@ -1,11 +1,7 @@ #include "Asset/AssetRegistry.h" #include "Graphics/Initializer.h" #include "Graphics/StaticMeshVertexData.h" -#ifdef __APPLE__ -#include "Graphics/Metal/Graphics.h" -#else #include "Graphics/Vulkan/Graphics.h" -#endif #include "PlayView.h" #include "Window/WindowManager.h" #include @@ -29,11 +25,7 @@ int main(int argc, char** argv) { std::filesystem::path binaryPath = "MeshShadingDemo.dll"; -#ifdef __APPLE__ - graphics = new Metal::Graphics(); -#else - graphics = new Vulkan::Graphics(); -#endif + graphics = new Vulkan::Graphics(); GraphicsInitializer initializer; graphics->init(initializer); StaticMeshVertexData* vd = StaticMeshVertexData::getInstance(); diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 9fc664e..377c2d3 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -36,11 +36,7 @@ int main() { std::filesystem::path binaryPath = sourcePath / "bin" / fmt::format("{}.{}", gameName, libraryEnding); std::filesystem::path cmakePath = outputPath / "cmake"; if (true) { -#ifdef __APPLE__ - graphics = new Metal::Graphics(); -#else graphics = new Vulkan::Graphics(); -#endif GraphicsInitializer initializer; graphics->init(initializer); StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();