From 2c6790b332183a3f97cd9262f1a43a36c4a91e8d Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Thu, 7 Mar 2024 14:53:21 +0800 Subject: [PATCH 01/48] temp --- samples/Sponza/Engine/Models/cube_2.obj | 91 + samples/Sponza/Engine/Models/plane_2.obj | 21 + samples/Sponza/Engine/Models/sphere_4.obj | 106 + samples/Sponza/MxApplication.cpp | 4 +- samples/Sponza/sponza2.json | 3763 +++++++++++++++++ src/Core/Rendering/RenderController.cpp | 49 +- src/Core/Rendering/RenderPipeline.h | 2 + src/Platform/OpenGL/ShaderBase.cpp | 2 +- .../OpenGL/Shaders/apply_ssr_fragment.glsl | 2 + .../OpenGL/Shaders/dirlight_fragment.glsl | 4 +- src/Platform/OpenGL/Shaders/dof_coc.glsl | 4 +- src/Platform/OpenGL/Shaders/fog_fragment.glsl | 4 +- .../OpenGL/Shaders/gbuffer_fragment.glsl | 2 + .../OpenGL/Shaders/gbuffer_mask_fragment.glsl | 2 + .../OpenGL/Shaders/gbuffer_vertex.glsl | 2 + src/Platform/OpenGL/Shaders/ibl_fragment.glsl | 4 +- .../OpenGL/Shaders/pointlight_fragment.glsl | 4 +- .../Shaders/pointlight_nonshadow_vertex.glsl | 4 +- .../Shaders/pointlight_shadow_vertex.glsl | 4 +- .../OpenGL/Shaders/spotlight_fragment.glsl | 4 +- .../Shaders/spotlight_nonshadow_vertex.glsl | 4 +- .../Shaders/spotlight_shadow_vertex.glsl | 4 +- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 159 +- .../OpenGL/Shaders/transparent_fragment.glsl | 5 +- 24 files changed, 4170 insertions(+), 80 deletions(-) create mode 100644 samples/Sponza/Engine/Models/cube_2.obj create mode 100644 samples/Sponza/Engine/Models/plane_2.obj create mode 100644 samples/Sponza/Engine/Models/sphere_4.obj create mode 100644 samples/Sponza/sponza2.json diff --git a/samples/Sponza/Engine/Models/cube_2.obj b/samples/Sponza/Engine/Models/cube_2.obj new file mode 100644 index 000000000..a4df721e8 --- /dev/null +++ b/samples/Sponza/Engine/Models/cube_2.obj @@ -0,0 +1,91 @@ +v -0.5 -0.5 0.5 +v 0.5 -0.5 0.5 +v -0.5 0.5 0.5 +v 0.5 0.5 0.5 +v 0.5 -0.5 -0.5 +v 0.5 0.5 -0.5 +v 0.5 -0.5 0.5 +v 0.5 0.5 0.5 +v 0.5 -0.5 0.5 +v -0.5 -0.5 0.5 +v 0.5 -0.5 -0.5 +v -0.5 -0.5 -0.5 +v -0.5 -0.5 -0.5 +v 0.5 -0.5 -0.5 +v -0.5 0.5 -0.5 +v 0.5 0.5 -0.5 +v 0.5 0.5 0.5 +v -0.5 0.5 0.5 +v 0.5 0.5 -0.5 +v -0.5 0.5 -0.5 +v -0.5 0.5 0.5 +v -0.5 -0.5 0.5 +v -0.5 0.5 -0.5 +v -0.5 -0.5 -0.5 +# total vertex count: 24 + +vt 0 0 +vt 1 0 +vt 0 1 +vt 1 1 +vt 1 0 +vt 1 1 +vt 0 0 +vt 0 1 +vt 1 1 +vt 0 1 +vt 1 0 +vt 0 0 +vt 1 0 +vt 0 0 +vt 1 1 +vt 0 1 +vt 0 1 +vt 1 1 +vt 0 0 +vt 1 0 +vt 1 1 +vt 1 0 +vt 0 1 +vt 0 0 +# total texcoord count: 24 + +vn 0 0 1 +vn 0 0 1 +vn 0 0 1 +vn 0 0 1 +vn 1 0 0 +vn 1 0 0 +vn 1 0 0 +vn 1 0 0 +vn 0 -1 0 +vn 0 -1 0 +vn 0 -1 0 +vn 0 -1 0 +vn 0 0 -1 +vn 0 0 -1 +vn 0 0 -1 +vn 0 0 -1 +vn 0 1 0 +vn 0 1 0 +vn 0 1 0 +vn 0 1 0 +vn -1 0 0 +vn -1 0 0 +vn -1 0 0 +vn -1 0 0 +# total normal count: 24 + +f 1/1/1 2/2/2 3/3/3 +f 2/2/2 4/4/4 3/3/3 +f 5/5/5 6/6/6 7/7/7 +f 6/6/6 8/8/8 7/7/7 +f 9/9/9 10/10/10 11/11/11 +f 10/10/10 12/12/12 11/11/11 +f 13/13/13 15/15/15 14/14/14 +f 14/14/14 15/15/15 16/16/16 +f 17/17/17 19/19/19 18/18/18 +f 18/18/18 19/19/19 20/20/20 +f 21/21/21 23/23/23 22/22/22 +f 22/22/22 23/23/23 24/24/24 +# total index count: 36 diff --git a/samples/Sponza/Engine/Models/plane_2.obj b/samples/Sponza/Engine/Models/plane_2.obj new file mode 100644 index 000000000..84162003d --- /dev/null +++ b/samples/Sponza/Engine/Models/plane_2.obj @@ -0,0 +1,21 @@ +v -0.5 0 -0.5 +v -0.5 0 0.5 +v 0.5 0 -0.5 +v 0.5 0 0.5 +# total vertex count: 4 + +vt 0 0 +vt 0 1 +vt 1 0 +vt 1 1 +# total texcoord count: 4 + +vn 0 1 0 +vn 0 1 0 +vn 0 1 0 +vn 0 1 0 +# total normal count: 4 + +f 1/1/1 2/2/2 3/3/3 +f 2/2/2 4/4/4 3/3/3 +# total index count: 6 diff --git a/samples/Sponza/Engine/Models/sphere_4.obj b/samples/Sponza/Engine/Models/sphere_4.obj new file mode 100644 index 000000000..96a7d3680 --- /dev/null +++ b/samples/Sponza/Engine/Models/sphere_4.obj @@ -0,0 +1,106 @@ +v 0 -0.5 0 +v -0 -0.5 0 +v -0 -0.5 -0 +v 0 -0.5 -0 +v 0 -0.5 0 +v 0.353553 -0.353553 0 +v -1.54543e-08 -0.353553 0.353553 +v -0.353553 -0.353553 -3.09086e-08 +v 4.21608e-09 -0.353553 -0.353553 +v 0.353553 -0.353553 6.18172e-08 +v 0.5 2.18557e-08 0 +v -2.18557e-08 2.18557e-08 0.5 +v -0.5 2.18557e-08 -4.37114e-08 +v 5.96244e-09 2.18557e-08 -0.5 +v 0.5 2.18557e-08 8.74228e-08 +v 0.353553 0.353553 0 +v -1.54543e-08 0.353553 0.353553 +v -0.353553 0.353553 -3.09086e-08 +v 4.21608e-09 0.353553 -0.353553 +v 0.353553 0.353553 6.18172e-08 +v -4.37114e-08 0.5 -0 +v 1.91069e-15 0.5 -4.37114e-08 +v 4.37114e-08 0.5 3.82137e-15 +v -5.21253e-16 0.5 4.37114e-08 +v -4.37114e-08 0.5 -7.64274e-15 +# total vertex count: 25 + +vt 1 0 +vt 0.75 0 +vt 0.5 0 +vt 0.25 0 +vt 0 0 +vt 1 0.25 +vt 0.75 0.25 +vt 0.5 0.25 +vt 0.25 0.25 +vt 0 0.25 +vt 1 0.5 +vt 0.75 0.5 +vt 0.5 0.5 +vt 0.25 0.5 +vt 0 0.5 +vt 1 0.75 +vt 0.75 0.75 +vt 0.5 0.75 +vt 0.25 0.75 +vt 0 0.75 +vt 1 1 +vt 0.75 1 +vt 0.5 1 +vt 0.25 1 +vt 0 1 +# total texcoord count: 25 + +vn 0 -1 0 +vn -0 -1 0 +vn -0 -1 -0 +vn 0 -1 -0 +vn 0 -1 0 +vn 0.707107 -0.707107 0 +vn -3.09086e-08 -0.707107 0.707107 +vn -0.707107 -0.707107 -6.18172e-08 +vn 8.43216e-09 -0.707107 -0.707107 +vn 0.707107 -0.707107 1.23634e-07 +vn 1 4.37114e-08 0 +vn -4.37114e-08 4.37114e-08 1 +vn -1 4.37114e-08 -8.74228e-08 +vn 1.19249e-08 4.37114e-08 -1 +vn 1 4.37114e-08 1.74846e-07 +vn 0.707107 0.707107 0 +vn -3.09086e-08 0.707107 0.707107 +vn -0.707107 0.707107 -6.18172e-08 +vn 8.43216e-09 0.707107 -0.707107 +vn 0.707107 0.707107 1.23634e-07 +vn -8.74228e-08 1 -0 +vn 3.82137e-15 1 -8.74228e-08 +vn 8.74228e-08 1 7.64274e-15 +vn -1.04251e-15 1 8.74228e-08 +vn -8.74228e-08 1 -1.52855e-14 +# total normal count: 25 + +f 2/2/2 6/6/6 7/7/7 +f 3/3/3 7/7/7 8/8/8 +f 4/4/4 8/8/8 9/9/9 +f 5/5/5 9/9/9 10/10/10 +f 6/6/6 11/11/11 7/7/7 +f 7/7/7 11/11/11 12/12/12 +f 7/7/7 12/12/12 8/8/8 +f 8/8/8 12/12/12 13/13/13 +f 8/8/8 13/13/13 9/9/9 +f 9/9/9 13/13/13 14/14/14 +f 9/9/9 14/14/14 10/10/10 +f 10/10/10 14/14/14 15/15/15 +f 11/11/11 16/16/16 12/12/12 +f 12/12/12 16/16/16 17/17/17 +f 12/12/12 17/17/17 13/13/13 +f 13/13/13 17/17/17 18/18/18 +f 13/13/13 18/18/18 14/14/14 +f 14/14/14 18/18/18 19/19/19 +f 14/14/14 19/19/19 15/15/15 +f 15/15/15 19/19/19 20/20/20 +f 16/16/16 21/21/21 17/17/17 +f 17/17/17 22/22/22 18/18/18 +f 18/18/18 23/23/23 19/19/19 +f 19/19/19 24/24/24 20/20/20 +# total index count: 72 diff --git a/samples/Sponza/MxApplication.cpp b/samples/Sponza/MxApplication.cpp index 29b243a66..688929b24 100644 --- a/samples/Sponza/MxApplication.cpp +++ b/samples/Sponza/MxApplication.cpp @@ -8,7 +8,7 @@ namespace Sponza { virtual void OnCreate() { - Scene::Load("sponza.json"_id); + Scene::Load("sponza2.json"_id); } }; } @@ -19,4 +19,4 @@ int main() Sponza::SponzaApplication app; app.Run(); return 0; -} \ No newline at end of file +} \ No newline at end of file diff --git a/samples/Sponza/sponza2.json b/samples/Sponza/sponza2.json new file mode 100644 index 000000000..678622411 --- /dev/null +++ b/samples/Sponza/sponza2.json @@ -0,0 +1,3763 @@ +{ + "AudioBuffer": null, + "CubeMap": [ + { + "_filepath": "Resources/skybox.png", + "id": 2 + }, + { + "_filepath": "Resources/skybox_irradiance.png", + "id": 3 + } + ], + "Material": [ + { + "albedo map": 102, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 1.0, + 1.0, + 1.0 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 0, + "metallic factor": 0.0, + "metallic map": 18446744073709551615, + "name": "DefaultMaterial", + "normal map": 18446744073709551615, + "roughness factor": 0.75, + "roughness map": 18446744073709551615, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 18446744073709551615, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 1.0, + 1.0, + 1.0 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 1, + "metallic factor": 1.0, + "metallic map": 18446744073709551615, + "name": "DefaultMaterial", + "normal map": 18446744073709551615, + "roughness factor": 1.0, + "roughness map": 18446744073709551615, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 14, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 2, + "metallic factor": 1.0, + "metallic map": 12, + "name": "DefaultMaterial", + "normal map": 24, + "roughness factor": 1.0, + "roughness map": 17, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 21, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 3, + "metallic factor": 1.0, + "metallic map": 18446744073709551615, + "name": "Lion Head", + "normal map": 27, + "roughness factor": 0.0, + "roughness map": 18446744073709551615, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 23, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 4, + "metallic factor": 1.0, + "metallic map": 18, + "name": "DefaultMaterial", + "normal map": 31, + "roughness factor": 1.0, + "roughness map": 13, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 26, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 5, + "metallic factor": 1.0, + "metallic map": 15, + "name": "DefaultMaterial", + "normal map": 34, + "roughness factor": 1.0, + "roughness map": 16, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 30, + "alpha mode": "MASKED", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 6, + "metallic factor": 1.0, + "metallic map": 19, + "name": "DefaultMaterial", + "normal map": 29, + "roughness factor": 1.0, + "roughness map": 20, + "transparency": 0.5, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 32, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 7, + "metallic factor": 1.0, + "metallic map": 28, + "name": "DefaultMaterial", + "normal map": 25, + "roughness factor": 1.0, + "roughness map": 22, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 41, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 8, + "metallic factor": 1.0, + "metallic map": 36, + "name": "DefaultMaterial", + "normal map": 35, + "roughness factor": 1.0, + "roughness map": 38, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 44, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 9, + "metallic factor": 1.0, + "metallic map": 40, + "name": "DefaultMaterial", + "normal map": 39, + "roughness factor": 1.0, + "roughness map": 33, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 45, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 10, + "metallic factor": 1.0, + "metallic map": 43, + "name": "DefaultMaterial", + "normal map": 42, + "roughness factor": 1.0, + "roughness map": 37, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 46, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 11, + "metallic factor": 1.0, + "metallic map": 48, + "name": "DefaultMaterial", + "normal map": 47, + "roughness factor": 1.0, + "roughness map": 49, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 50, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 12, + "metallic factor": 1.0, + "metallic map": 52, + "name": "DefaultMaterial", + "normal map": 51, + "roughness factor": 1.0, + "roughness map": 53, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 54, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 13, + "metallic factor": 1.0, + "metallic map": 56, + "name": "DefaultMaterial", + "normal map": 55, + "roughness factor": 1.0, + "roughness map": 57, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 61, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 14, + "metallic factor": 0.0, + "metallic map": 18446744073709551615, + "name": "DefaultMaterial", + "normal map": 18446744073709551615, + "roughness factor": 1.0, + "roughness map": 18446744073709551615, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 58, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 15, + "metallic factor": 1.0, + "metallic map": 70, + "name": "DefaultMaterial", + "normal map": 59, + "roughness factor": 1.0, + "roughness map": 60, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 63, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 16, + "metallic factor": 1.0, + "metallic map": 75, + "name": "DefaultMaterial", + "normal map": 64, + "roughness factor": 1.0, + "roughness map": 65, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 67, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 17, + "metallic factor": 1.0, + "metallic map": 79, + "name": "DefaultMaterial", + "normal map": 68, + "roughness factor": 1.0, + "roughness map": 62, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 74, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 18, + "metallic factor": 0.25, + "metallic map": 18446744073709551615, + "name": "Floor", + "normal map": 82, + "roughness factor": 1.0, + "roughness map": 66, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 78, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 19, + "metallic factor": 1.0, + "metallic map": 71, + "name": "DefaultMaterial", + "normal map": 80, + "roughness factor": 1.0, + "roughness map": 72, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 83, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 20, + "metallic factor": 1.0, + "metallic map": 76, + "name": "DefaultMaterial", + "normal map": 77, + "roughness factor": 1.0, + "roughness map": 69, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 95, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 21, + "metallic factor": 1.0, + "metallic map": 73, + "name": "DefaultMaterial", + "normal map": 87, + "roughness factor": 1.0, + "roughness map": 81, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 90, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 22, + "metallic factor": 1.0, + "metallic map": 85, + "name": "DefaultMaterial", + "normal map": 11, + "roughness factor": 1.0, + "roughness map": 86, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 94, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 23, + "metallic factor": 1.0, + "metallic map": 18446744073709551615, + "name": "Lion Head", + "normal map": 10, + "roughness factor": 0.0, + "roughness map": 18446744073709551615, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 98, + "alpha mode": "OPAQUE", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 24, + "metallic factor": 1.0, + "metallic map": 91, + "name": "DefaultMaterial", + "normal map": 100, + "roughness factor": 1.0, + "roughness map": 84, + "transparency": 1.0, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 99, + "alpha mode": "MASKED", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.02500000037252903, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 25, + "metallic factor": 1.0, + "metallic map": 93, + "name": "DefaultMaterial", + "normal map": 92, + "roughness factor": 1.0, + "roughness map": 101, + "transparency": 0.5, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 96, + "alpha mode": "MASKED", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 0.5879999995231628, + 0.5879999995231628, + 0.5879999995231628 + ], + "displacement": 0.0, + "emission": 0.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 26, + "metallic factor": 1.0, + "metallic map": 89, + "name": "DefaultMaterial", + "normal map": 88, + "roughness factor": 0.0, + "roughness map": 97, + "transparency": 0.5, + "uv multipliers": [ + 1.0, + 1.0 + ] + }, + { + "albedo map": 103, + "alpha mode": "TRANSPARENT", + "ambient occlusion map": 18446744073709551615, + "base color": [ + 1.0, + 0.9999899864196777, + 0.9999899864196777 + ], + "displacement": 0.02500000037252903, + "emission": 10.0, + "emissive map": 18446744073709551615, + "height map": 18446744073709551615, + "id": 27, + "metallic factor": 1.0, + "metallic map": 18446744073709551615, + "name": "DefaultMaterial", + "normal map": 18446744073709551615, + "roughness factor": 1.0, + "roughness map": 18446744073709551615, + "transparency": 0.20000000298023224, + "uv multipliers": [ + 1.0, + 1.0 + ] + } + ], + "Mesh": [ + { + "_filepath": "Engine/Models/pyramid_1.obj", + "aabb": { + "max": [ + 1.0, + 1.0, + 1.0 + ], + "min": [ + -1.0, + -1.0, + 0.0 + ] + }, + "bounding sphere": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "radius": 2.0 + }, + "id": 0 + }, + { + "_filepath": "Engine/Models/sphere_8.obj", + "aabb": { + "max": [ + 0.5, + 0.5, + 0.5 + ], + "min": [ + -0.5, + -0.5, + -0.5 + ] + }, + "bounding sphere": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "radius": 0.5 + }, + "id": 1 + }, + { + "_filepath": "Engine/Models/pyramid_1.obj", + "aabb": { + "max": [ + 1.0, + 1.0, + 1.0 + ], + "min": [ + -1.0, + -1.0, + 0.0 + ] + }, + "bounding sphere": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "radius": 2.0 + }, + "id": 2 + }, + { + "_filepath": "Engine/Models/sphere_8.obj", + "aabb": { + "max": [ + 0.5, + 0.5, + 0.5 + ], + "min": [ + -0.5, + -0.5, + -0.5 + ] + }, + "bounding sphere": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "radius": 0.5 + }, + "id": 3 + }, + { + "_filepath": "Engine/Models/sphere_20.obj", + "aabb": { + "max": [ + 0.5, + 0.5, + 0.5 + ], + "min": [ + -0.5, + -0.5, + -0.5 + ] + }, + "bounding sphere": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "radius": 0.5000000596046448 + }, + "id": 8 + }, + { + "_filepath": "Resources/Sponza/glTF/Sponza.gltf", + "aabb": { + "max": [ + 1860.427001953125, + 777.9378662109375, + 1144.1165771484375 + ], + "min": [ + -1860.427001953125, + -777.9378662109375, + -1144.1165771484375 + ] + }, + "bounding sphere": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "radius": 2887.561767578125 + }, + "id": 9 + } + ], + "Script": [ + { + "filepath": "Resources/ShootSpheres.cpp", + "name": "ShootSpheres" + } + ], + "Texture": [ + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/13982482287905699490.jpg" + }, + "id": 10, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/16299174074766089871.jpg" + }, + "id": 11, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_24.png" + }, + "id": 12, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_22.png" + }, + "id": 13, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/2969916736137545357.jpg" + }, + "id": 14, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_21.png" + }, + "id": 15, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_21.png" + }, + "id": 16, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_24.png" + }, + "id": 17, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_22.png" + }, + "id": 18, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_20.png" + }, + "id": 19, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_20.png" + }, + "id": 20, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/6772804448157695701.jpg" + }, + "id": 21, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_19.png" + }, + "id": 22, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/8481240838833932244.jpg" + }, + "id": 23, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/14118779221266351425.jpg" + }, + "id": 24, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/4910669866631290573.jpg" + }, + "id": 25, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/755318871556304029.jpg" + }, + "id": 26, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/759203620573749278.jpg" + }, + "id": 27, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_19.png" + }, + "id": 28, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/14170708867020035030.jpg" + }, + "id": 29, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/16275776544635328252.png" + }, + "id": 30, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/10381718147657362067.jpg" + }, + "id": 31, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/9288698199695299068.jpg" + }, + "id": 32, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_17.png" + }, + "id": 33, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/3827035219084910048.jpg" + }, + "id": 34, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/4601176305987539675.jpg" + }, + "id": 35, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_18.png" + }, + "id": 36, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_16.png" + }, + "id": 37, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_18.png" + }, + "id": 38, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/6593109234861095314.jpg" + }, + "id": 39, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_17.png" + }, + "id": 40, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/11474523244911310074.jpg" + }, + "id": 41, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/332936164838540657.jpg" + }, + "id": 42, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_16.png" + }, + "id": 43, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/17876391417123941155.jpg" + }, + "id": 44, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/2185409758123873465.jpg" + }, + "id": 45, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/2775690330959970771.jpg" + }, + "id": 46, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/2374361008830720677.jpg" + }, + "id": 47, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_15.png" + }, + "id": 48, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_15.png" + }, + "id": 49, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/4675343432951571524.jpg" + }, + "id": 50, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/7056944414013900257.jpg" + }, + "id": 51, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_14.png" + }, + "id": 52, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_14.png" + }, + "id": 53, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/4975155472559461469.jpg" + }, + "id": 54, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/2299742237651021498.jpg" + }, + "id": 55, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_13.png" + }, + "id": 56, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_13.png" + }, + "id": 57, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/6151467286084645207.jpg" + }, + "id": 58, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/7645212358685992005.jpg" + }, + "id": 59, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_11.png" + }, + "id": 60, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/white.png" + }, + "id": 61, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_9.png" + }, + "id": 62, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/11490520546946913238.jpg" + }, + "id": 63, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/3628158980083700836.jpg" + }, + "id": 64, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_10.png" + }, + "id": 65, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_8.png" + }, + "id": 66, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/7441062115984513793.jpg" + }, + "id": 67, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/6667038893015345571.jpg" + }, + "id": 68, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_6.png" + }, + "id": 69, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_11.png" + }, + "id": 70, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_7.png" + }, + "id": 71, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_7.png" + }, + "id": 72, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_5.png" + }, + "id": 73, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/5823059166183034438.jpg" + }, + "id": 74, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_10.png" + }, + "id": 75, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_6.png" + }, + "id": 76, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/10388182081421875623.jpg" + }, + "id": 77, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/6047387724914829168.jpg" + }, + "id": 78, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_9.png" + }, + "id": 79, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/15722799267630235092.jpg" + }, + "id": 80, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_5.png" + }, + "id": 81, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/14267839433702832875.jpg" + }, + "id": 82, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/15295713303328085182.jpg" + }, + "id": 83, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_2.png" + }, + "id": 84, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_4.png" + }, + "id": 85, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_4.png" + }, + "id": 86, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/2051777328469649772.jpg" + }, + "id": 87, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/8773302468495022225.jpg" + }, + "id": 88, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_0.png" + }, + "id": 89, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/5792855332885324923.jpg" + }, + "id": 90, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_2.png" + }, + "id": 91, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/12501374198249454378.jpg" + }, + "id": 92, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/metallic_1.png" + }, + "id": 93, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/8750083169368950601.jpg" + }, + "id": 94, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/14650633544276105767.jpg" + }, + "id": 95, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/5061699253647017043.png" + }, + "id": 96, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_0.png" + }, + "id": 97, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/7268504077753552595.jpg" + }, + "id": 98, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/Sponza/glTF/8006627369776289000.png" + }, + "id": 99, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RG", + "path": "Resources/Sponza/glTF/4477655471536070370.jpg" + }, + "id": 100, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "R", + "path": "Resources/Sponza/glTF/roughness_1.png" + }, + "id": 101, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGB", + "path": "Resources/moon.jpg" + }, + "id": 102, + "wrap type": "REPEAT" + }, + { + "border color": [ + 0.0, + 0.0, + 0.0, + 0.0 + ], + "filepath": { + "format": "RGBA", + "path": "Resources/fire.png" + }, + "id": 103, + "wrap type": "REPEAT" + } + ], + "globals": { + "gravity": [ + 0.0, + -9.800000190734863, + 0.0 + ], + "overlay-debug": false, + "paused": false, + "physics-step": 1.0, + "time-scale": 1.0, + "total-time": 3900.35009765625, + "viewport": 0 + }, + "mxobjects": [ + { + "CameraController": { + "camera type": "PERSPECTIVE", + "direction": [ + 0.9978463053703308, + 0.06556776911020279, + 0.0018980845343321562 + ], + "forward vector": [ + 0.9999982118606567, + 0.0, + 0.001902177813462913 + ], + "id": 0, + "is listening window resize event": true, + "is rendering": true, + "perspective camera": { + "aspect ratio": 1.7777777910232544, + "fov": 65.0, + "zfar": 100000.0, + "znear": 0.10000000149011612 + }, + "right vector": [ + -0.0019022214692085981, + 0.0, + 0.9999982118606567 + ], + "up vector": [ + 0.0, + 1.0, + 0.0 + ] + }, + "CameraEffects": { + "bloom iterations": 3, + "bloom weight": 0.5, + "chromatic aberration distortion": 0.800000011920929, + "chromatic aberration intensity": 0.07999999821186066, + "chromatic aberration min distance": 0.800000011920929, + "dof bokeh radius": 10.0, + "dof focus distance": 0.0, + "dof focus range": 5.0, + "fog color": [ + 0.5, + 0.6000000238418579, + 0.699999988079071 + ], + "fog density": 0.0, + "fog distance": 1.0, + "fxaa": false, + "id": 0, + "vignette radius": 0.10000000149011612 + }, + "CameraSSAO": { + "blur iterations": 1, + "blur lod": 2, + "id": 0, + "intensity": 3.1500000953674316, + "radius": 1.0, + "sample count": 4 + }, + "CameraSSGI": { + "blur iterations": 1, + "blur lod": 5, + "distance": 50.0, + "id": 0, + "intensity": 2.5, + "ray steps": 3 + }, + "CameraSSR": { + "id": 0, + "start distance": 2.009999990463257, + "steps": 10, + "thickness": 0.5 + }, + "CameraToneMapping": { + "aces coefficients": { + "a": 0.25, + "b": 0.3059999942779541, + "c": 0.0989999994635582, + "d": 0.3499999940395355, + "e": 0.02500000037252903, + "f": 0.4000000059604645 + }, + "color grading": { + "B": [ + 0.0, + 0.0, + 1.0 + ], + "G": [ + 0.0, + 1.0, + 0.0 + ], + "R": [ + 1.0, + 0.0, + 0.0 + ] + }, + "color scale": 1.0, + "exposure": 1.0, + "eye adaptation speed": 1.0, + "eye adaptation threshold": 0.10000000149011612, + "gamma": 2.200000047683716, + "id": 0, + "max luminance": 100000.0, + "min luminance": 0.30000001192092896, + "white point": 0.5 + }, + "CapsuleCollider": { + "bounding capsule": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "height": 4.5, + "orientation": "Y", + "radius": 0.75, + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "id": 0 + }, + "CharacterController": { + "id": 0, + "jump power": 12.0, + "jump speed": 10.0 + }, + "InputController": { + "back key binding": "S", + "down key binding": "LEFT_SHIFT", + "forward key binding": "W", + "id": 0, + "is horizontal rotation bound": true, + "is vertical rotation bound": true, + "left key binding": "A", + "move speed": 10.0, + "right key binding": "D", + "rotate speed": 10.0, + "up key binding": "SPACE", + "use camera style movement": true + }, + "RigidBody": { + "angular air resistance": 0.0, + "angular force factor": [ + 0.0, + 0.0, + 0.0 + ], + "angular velocity": [ + 0.0, + 0.0, + 0.0 + ], + "anisotropic friction": [ + 1.0, + 1.0, + 1.0 + ], + "bounce factor": 0.0, + "friction": 0.0, + "gravity": [ + 0.0, + -9.800000190734863, + 0.0 + ], + "has anisotropic friction": false, + "id": 0, + "is ray castable": true, + "is trigger": false, + "linear air resistance": 0.0, + "linear force factor": [ + 1.0, + 1.0, + 1.0 + ], + "linear velocity": [ + 0.0, + 5.7220458984375e-06, + 2.6808647746179304e-08 + ], + "mass": 1.0, + "push velocity": [ + 0.0, + 0.0, + 0.0 + ], + "rolling friction": 0.0, + "spinning friction": 0.0, + "turn velocity": [ + 0.0, + 0.0, + 0.0 + ], + "type": "DYNAMIC" + }, + "Script": { + "_name": "ShootSpheres", + "database": { + "_database": null + }, + "id": 0 + }, + "Skybox": { + "cubemap": 2, + "id": 0, + "intensity": 0.0, + "irradiance": 3, + "rotation": [ + 0.0, + 0.0, + 0.0 + ] + }, + "displayed": true, + "name": "Camera", + "transform": { + "position": [ + -25.250308990478516, + 2.999999523162842, + -0.40193822979927063 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "InstanceFactory": { + "id": 0, + "instances": null, + "is static": false + }, + "MeshRenderer": { + "id": 0, + "materials": [ + 0 + ] + }, + "MeshSource": { + "casts shadow": true, + "id": 0, + "is drawn": true, + "is static": false, + "mesh": 8 + }, + "displayed": true, + "name": "Sphere Factory", + "transform": { + "position": [ + 0.0, + 0.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "CompoundCollider": { + "children": [ + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 1800.0, + 75.0, + 1075.0 + ], + "min": [ + -1800.0, + -75.0, + -1075.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 0.0, + -725.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 1800.0, + 750.0, + 250.0 + ], + "min": [ + -1800.0, + -750.0, + -250.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 0.0, + 0.0, + 850.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 1800.0, + 750.0, + 250.0 + ], + "min": [ + -1800.0, + -750.0, + -250.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 0.0, + 0.0, + -850.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 250.0, + 750.0, + 1075.0 + ], + "min": [ + -250.0, + -750.0, + -1075.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 1600.0, + 0.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 250.0, + 750.0, + 1075.0 + ], + "min": [ + -250.0, + -750.0, + -1075.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + -1600.0, + 0.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "height": 100.0, + "orientation": "Y", + "radius x": 75.0, + "radius z": 75.0, + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "Cylinder" + }, + "transform": { + "position": [ + 1180.0, + -600.0, + 440.0000305175781 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "height": 100.0, + "orientation": "Y", + "radius x": 75.0, + "radius z": 75.0, + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "Cylinder" + }, + "transform": { + "position": [ + 1180.0, + -600.0, + -410.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "height": 100.0, + "orientation": "Y", + "radius x": 75.0, + "radius z": 75.0, + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "Cylinder" + }, + "transform": { + "position": [ + -1140.0, + -600.0, + 440.0000305175781 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "height": 100.0, + "orientation": "Y", + "radius x": 75.0, + "radius z": 75.0, + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "Cylinder" + }, + "transform": { + "position": [ + -1140.0, + -600.0, + -410.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 980.0000610351563, + 300.0, + 40.0 + ], + "min": [ + -980.0000610351563, + -300.0, + -40.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 0.0, + -425.0, + -225.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 980.0000610351563, + 300.0, + 40.0 + ], + "min": [ + -980.0000610351563, + -300.0, + -40.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 0.0, + -425.0, + 225.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 40.0, + 50.0, + 265.0 + ], + "min": [ + -40.0, + -50.0, + -265.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 950.0, + -175.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 40.0, + 50.0, + 265.0 + ], + "min": [ + -40.0, + -50.0, + -265.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + -950.0, + -175.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 1800.0, + 10.0, + 250.0 + ], + "min": [ + -1800.0, + -10.0, + -250.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 0.0, + -235.0, + 450.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 1800.0, + 10.0, + 250.0 + ], + "min": [ + -1800.0, + -10.0, + -250.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 0.0, + -235.0, + -450.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 250.0, + 10.0, + 1075.0 + ], + "min": [ + -250.0, + -10.0, + -1075.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 1175.0, + -235.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 250.0, + 10.0, + 1075.0 + ], + "min": [ + -250.0, + -10.0, + -1075.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + -1175.0, + -235.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 1800.0, + 250.0, + 250.0 + ], + "min": [ + -1800.0, + -250.0, + -250.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 0.0, + 500.0, + 450.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 1800.0, + 250.0, + 250.0 + ], + "min": [ + -1800.0, + -250.0, + -250.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 0.0, + 500.0, + -450.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 250.0, + 250.0, + 1075.0 + ], + "min": [ + -250.0, + -250.0, + -1075.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + 1175.0, + 500.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + }, + { + "shape": { + "bounding": { + "center": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 250.0, + 250.0, + 1075.0 + ], + "min": [ + -250.0, + -250.0, + -1075.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "type": "BoundingBox" + }, + "transform": { + "position": [ + -1175.0, + 500.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 1.0, + 1.0, + 1.0 + ] + } + } + ], + "id": 0 + }, + "MeshRenderer": { + "id": 1, + "materials": [ + 26, + 25, + 24, + 23, + 22, + 21, + 20, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + }, + "MeshSource": { + "casts shadow": true, + "id": 1, + "is drawn": true, + "is static": false, + "mesh": 9 + }, + "RigidBody": { + "angular air resistance": 0.0, + "angular force factor": [ + 1.0, + 1.0, + 1.0 + ], + "angular velocity": [ + 0.0, + 0.0, + 0.0 + ], + "anisotropic friction": [ + 1.0, + 1.0, + 1.0 + ], + "bounce factor": 0.10000000149011612, + "friction": 0.5, + "gravity": [ + 0.0, + 0.0, + 0.0 + ], + "has anisotropic friction": false, + "id": 1, + "is ray castable": true, + "is trigger": false, + "linear air resistance": 0.0, + "linear force factor": [ + 1.0, + 1.0, + 1.0 + ], + "linear velocity": [ + 0.0, + 0.0, + 0.0 + ], + "mass": 0.0, + "push velocity": [ + 0.0, + 0.0, + 0.0 + ], + "rolling friction": 0.0, + "spinning friction": 0.0, + "turn velocity": [ + 0.0, + 0.0, + 0.0 + ], + "type": "STATIC" + }, + "displayed": true, + "name": "Sponza", + "transform": { + "position": [ + 0.0, + 13.0, + 0.0 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 0.019999999552965164, + 0.019999999552965164, + 0.019999999552965164 + ] + } + }, + { + "MeshRenderer": { + "id": 2, + "materials": [ + 27 + ] + }, + "ParticleSystem": { + "fading": 1.5, + "id": 0, + "is relative": true, + "max initial time alive": 1.0, + "max particle count": 128, + "max particle size": 0.15000000596046448, + "max spawn distance": 0.0, + "min particle size": 0.05000000074505806, + "min spawn distance": 0.0, + "particle angular speed": 0.0, + "particle lifetime": 1.0, + "particle speed": 0.800000011920929, + "shape": "HEMISPHERE" + }, + "PointLight": { + "ambient intensity": 0.10000000149011612, + "casts shadows": false, + "color": [ + 1.0, + 0.6764705777168274, + 0.0 + ], + "id": 0, + "intensity": 100.0, + "radius": 5.0 + }, + "displayed": true, + "name": "Fire 1", + "transform": { + "position": [ + -11.17866039276123, + 2.3849868774414063, + 3.6654486656188965 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 0.30000001192092896, + 1.25, + 0.30000001192092896 + ] + } + }, + { + "MeshRenderer": { + "id": 3, + "materials": [ + 27 + ] + }, + "ParticleSystem": { + "fading": 1.5, + "id": 1, + "is relative": true, + "max initial time alive": 1.0, + "max particle count": 128, + "max particle size": 0.15000000596046448, + "max spawn distance": 0.0, + "min particle size": 0.05000000074505806, + "min spawn distance": 0.0, + "particle angular speed": 0.0, + "particle lifetime": 1.0, + "particle speed": 0.800000011920929, + "shape": "HEMISPHERE" + }, + "PointLight": { + "ambient intensity": 0.10000000149011612, + "casts shadows": false, + "color": [ + 1.0, + 0.6764705777168274, + 0.0 + ], + "id": 1, + "intensity": 100.0, + "radius": 5.0 + }, + "displayed": true, + "name": "Fire 2", + "transform": { + "position": [ + 10.98430061340332, + 2.3849868774414063, + 3.6654486656188965 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 0.30000001192092896, + 1.25, + 0.30000001192092896 + ] + } + }, + { + "MeshRenderer": { + "id": 4, + "materials": [ + 27 + ] + }, + "ParticleSystem": { + "fading": 1.5, + "id": 2, + "is relative": true, + "max initial time alive": 1.0, + "max particle count": 128, + "max particle size": 0.15000000596046448, + "max spawn distance": 0.0, + "min particle size": 0.05000000074505806, + "min spawn distance": 0.0, + "particle angular speed": 0.0, + "particle lifetime": 1.0, + "particle speed": 0.800000011920929, + "shape": "HEMISPHERE" + }, + "PointLight": { + "ambient intensity": 0.10000000149011612, + "casts shadows": false, + "color": [ + 1.0, + 0.6764705777168274, + 0.0 + ], + "id": 2, + "intensity": 100.0, + "radius": 5.0 + }, + "displayed": true, + "name": "Fire 3", + "transform": { + "position": [ + -11.17866039276123, + 2.3849868774414063, + -3.6654486656188965 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 0.30000001192092896, + 1.25, + 0.30000001192092896 + ] + } + }, + { + "MeshRenderer": { + "id": 5, + "materials": [ + 27 + ] + }, + "ParticleSystem": { + "fading": 1.5, + "id": 3, + "is relative": true, + "max initial time alive": 1.0, + "max particle count": 128, + "max particle size": 0.15000000596046448, + "max spawn distance": 0.0, + "min particle size": 0.05000000074505806, + "min spawn distance": 0.0, + "particle angular speed": 0.0, + "particle lifetime": 1.0, + "particle speed": 0.800000011920929, + "shape": "HEMISPHERE" + }, + "PointLight": { + "ambient intensity": 0.10000000149011612, + "casts shadows": false, + "color": [ + 1.0, + 0.6764705777168274, + 0.0 + ], + "id": 3, + "intensity": 100.0, + "radius": 5.0 + }, + "displayed": true, + "name": "Fire 4", + "transform": { + "position": [ + 10.948619842529297, + 2.3849868774414063, + -3.6654486656188965 + ], + "rotation": [ + 0.0, + 0.0, + 0.0 + ], + "scale": [ + 0.30000001192092896, + 1.25, + 0.30000001192092896 + ] + } + } + ] +} \ No newline at end of file diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 79a0fb3fb..0739fc6ee 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -657,7 +657,7 @@ namespace MxEngine this->BindGBuffer(camera, *SSRShader, textureId); this->BindCameraInformation(camera, *SSRShader); - SSRShader->SetUniform("thickness", camera.SSR->GetThickness()); + SSRShader->SetUniform("thickness", camera.SSR->GetThickness()); SSRShader->SetUniform("startDistance", camera.SSR->GetStartDistance()); SSRShader->SetUniform("steps", (int)camera.SSR->GetSteps()); @@ -1029,11 +1029,12 @@ namespace MxEngine shader.SetUniform("camera.position", camera.ViewportPosition); shader.SetUniform("camera.viewProjMatrix", camera.ViewProjectionMatrix); shader.SetUniform("camera.invViewProjMatrix", camera.InverseViewProjMatrix); + shader.SetUniform("camera.viewMatrix", camera.ViewMatrix); + shader.SetUniform("camera.projectionMatrix", camera.ProjectionMatrix); } - void RenderController::BindGBuffer(const CameraUnit& camera, const Shader& shader, Texture::TextureBindId& startId) { - camera.AlbedoTexture->Bind(startId++); + camera.AlbedoTexture->Bind(startId++); camera.NormalTexture->Bind(startId++); camera.MaterialTexture->Bind(startId++); camera.DepthTexture->Bind(startId++); @@ -1043,9 +1044,9 @@ namespace MxEngine shader.SetUniform("materialTex", camera.MaterialTexture->GetBoundId()); shader.SetUniform("depthTex", camera.DepthTexture->GetBoundId()); } - + const Renderer& RenderController::GetRenderEngine() const - { + { return this->renderer; } @@ -1443,7 +1444,7 @@ namespace MxEngine } void RenderController::SubmitCamera( - const CameraController& controller, + const CameraController& cameraController, const Transform& parentTransform, const Skybox* skybox, const CameraEffects* effects, @@ -1455,28 +1456,30 @@ namespace MxEngine { auto& camera = this->Pipeline.Cameras.emplace_back(); - bool isPerspective = controller.GetCameraType() == CameraType::PERSPECTIVE; + bool isPerspective = cameraController.GetCameraType() == CameraType::PERSPECTIVE; bool hasSkybox = skybox != nullptr; bool hasToneMapping = toneMapping != nullptr; camera.ViewportPosition = parentTransform.GetPosition(); - camera.AspectRatio = controller.Camera.GetAspectRatio(); - camera.StaticViewProjectionMatrix = controller.GetMatrix(MakeVector3(0.0f)); - camera.ViewProjectionMatrix = controller.GetMatrix(parentTransform.GetPosition()); + camera.AspectRatio = cameraController.Camera.GetAspectRatio(); + camera.StaticViewProjectionMatrix = cameraController.GetMatrix(MakeVector3(0.0f)); + camera.ViewMatrix = cameraController.GetViewMatrix(parentTransform.GetPosition()); + camera.ProjectionMatrix = cameraController.GetProjectionMatrix(); + camera.ViewProjectionMatrix = cameraController.GetMatrix(parentTransform.GetPosition()); camera.InverseViewProjMatrix = Inverse(camera.ViewProjectionMatrix); - camera.Culler = controller.GetFrustrumCuller(); - camera.IsPerspective = controller.GetCameraType() == CameraType::PERSPECTIVE; - camera.GBuffer = controller.GetGBuffer(); - camera.AlbedoTexture = controller.GetAlbedoTexture(); - camera.NormalTexture = controller.GetNormalTexture(); - camera.MaterialTexture = controller.GetMaterialTexture(); - camera.DepthTexture = controller.GetDepthTexture(); - camera.AverageWhiteTexture = controller.GetAverageWhiteTexture(); - camera.HDRTexture = controller.GetHDRTexture(); - camera.SwapTexture1 = controller.GetSwapHDRTexture1(); - camera.SwapTexture2 = controller.GetSwapHDRTexture2(); - camera.OutputTexture = controller.GetRenderTexture(); - camera.RenderToTexture = controller.IsRendering(); + camera.Culler = cameraController.GetFrustrumCuller(); + camera.IsPerspective = cameraController.GetCameraType() == CameraType::PERSPECTIVE; + camera.GBuffer = cameraController.GetGBuffer(); + camera.AlbedoTexture = cameraController.GetAlbedoTexture(); + camera.NormalTexture = cameraController.GetNormalTexture(); + camera.MaterialTexture = cameraController.GetMaterialTexture(); + camera.DepthTexture = cameraController.GetDepthTexture(); + camera.AverageWhiteTexture = cameraController.GetAverageWhiteTexture(); + camera.HDRTexture = cameraController.GetHDRTexture(); + camera.SwapTexture1 = cameraController.GetSwapHDRTexture1(); + camera.SwapTexture2 = cameraController.GetSwapHDRTexture2(); + camera.OutputTexture = cameraController.GetRenderTexture(); + camera.RenderToTexture = cameraController.IsRendering(); camera.SkyboxTexture = hasSkybox && skybox->CubeMap.IsValid() ? skybox->CubeMap : this->Pipeline.Environment.DefaultSkybox; camera.IrradianceTexture = hasSkybox && skybox->Irradiance.IsValid() ? skybox->Irradiance : camera.SkyboxTexture; camera.SkyboxIntensity = hasSkybox ? skybox->GetIntensity() : Skybox::DefaultIntensity; diff --git a/src/Core/Rendering/RenderPipeline.h b/src/Core/Rendering/RenderPipeline.h index 8b7b3c701..93ea71115 100644 --- a/src/Core/Rendering/RenderPipeline.h +++ b/src/Core/Rendering/RenderPipeline.h @@ -70,6 +70,8 @@ namespace MxEngine FrustrumCuller Culler; Matrix4x4 InverseViewProjMatrix; Matrix4x4 ViewProjectionMatrix; + Matrix4x4 ViewMatrix; + Matrix4x4 ProjectionMatrix; Matrix4x4 StaticViewProjectionMatrix; TextureHandle OutputTexture; diff --git a/src/Platform/OpenGL/ShaderBase.cpp b/src/Platform/OpenGL/ShaderBase.cpp index 538449125..93e338ee1 100644 --- a/src/Platform/OpenGL/ShaderBase.cpp +++ b/src/Platform/OpenGL/ShaderBase.cpp @@ -55,7 +55,7 @@ namespace MxEngine cache[uniformName] = location; return location; } - + ShaderBase::UniformIdType ShaderBase::UniformCache::GetUniformLocationSilent(const char* uniformName) { auto it = cache.find_as(uniformName); diff --git a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl index a13e301bd..1255ad8eb 100644 --- a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl @@ -8,6 +8,8 @@ struct Camera vec3 position; mat4 viewProjMatrix; mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform sampler2D albedoTex; diff --git a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl index 6a7e49e9b..26b1c3d2a 100644 --- a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl @@ -6,8 +6,10 @@ in vec2 TexCoord; struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform sampler2D albedoTex; diff --git a/src/Platform/OpenGL/Shaders/dof_coc.glsl b/src/Platform/OpenGL/Shaders/dof_coc.glsl index cc54c18ad..7bfab9a78 100644 --- a/src/Platform/OpenGL/Shaders/dof_coc.glsl +++ b/src/Platform/OpenGL/Shaders/dof_coc.glsl @@ -8,8 +8,10 @@ uniform sampler2D depthTex; struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform Camera camera; uniform float focusDistance; diff --git a/src/Platform/OpenGL/Shaders/fog_fragment.glsl b/src/Platform/OpenGL/Shaders/fog_fragment.glsl index 3bf9ba056..d8c6fd601 100644 --- a/src/Platform/OpenGL/Shaders/fog_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/fog_fragment.glsl @@ -12,8 +12,10 @@ uniform sampler2D depthTex; struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform sampler2D cameraOutput; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl index 03c87762c..4db18764f 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl @@ -26,6 +26,8 @@ struct Camera vec3 position; mat4 viewProjMatrix; mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform sampler2D map_albedo; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl index 17292e798..9578c4c41 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl @@ -24,6 +24,8 @@ struct Camera vec3 position; mat4 viewProjMatrix; mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform sampler2D map_albedo; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl index 2241e6d13..97a8401c6 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl @@ -14,6 +14,8 @@ struct Camera vec3 position; mat4 viewProjMatrix; mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/ibl_fragment.glsl b/src/Platform/OpenGL/Shaders/ibl_fragment.glsl index 6d883b3f7..dbba9cd12 100644 --- a/src/Platform/OpenGL/Shaders/ibl_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ibl_fragment.glsl @@ -12,8 +12,10 @@ uniform float gamma; struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl b/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl index 89e35178a..53356d433 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl @@ -24,8 +24,10 @@ struct PointLight struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform samplerCube lightDepthMap; diff --git a/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl b/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl index dd17b5853..18a4e6940 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl @@ -13,8 +13,10 @@ out PointLightInfo struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl b/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl index 9a44b4c29..7c7d208a0 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl @@ -10,8 +10,10 @@ out PointLightInfo struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl b/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl index eb118d1df..dee7d086d 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl @@ -30,8 +30,10 @@ struct SpotLight struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform mat4 worldToLightTransform; diff --git a/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl b/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl index 1a2affbcd..efa444b7a 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl @@ -17,8 +17,10 @@ out SpotLightInfo struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl b/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl index 56102a9ac..1ab0abae9 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl @@ -13,8 +13,10 @@ out SpotLightInfo struct Camera { vec3 position; - mat4 invViewProjMatrix; mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index a9ead8478..eaea50dd0 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -3,20 +3,21 @@ in vec2 TexCoord; out vec4 OutColor; +uniform sampler2D albedoTex; +uniform sampler2D normalTex; +uniform sampler2D materialTex; +uniform sampler2D depthTex; +uniform sampler2D HDRTex; + struct Camera { vec3 position; mat4 viewProjMatrix; mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; }; - -uniform sampler2D albedoTex; -uniform sampler2D normalTex; -uniform sampler2D materialTex; -uniform sampler2D depthTex; -uniform sampler2D HDRTex; - uniform Camera camera; uniform EnvironmentInfo environment; @@ -24,46 +25,120 @@ uniform int steps; uniform float thickness; uniform float startDistance; -void main() +float sampleDepth(vec2 uv) { - FragmentInfo fragment = getFragmentInfo(TexCoord, albedoTex, normalTex, materialTex, depthTex, camera.invViewProjMatrix); + return texture(depthTex,uv).r; +} - vec3 viewDistance = camera.position - fragment.position; - vec3 viewDirection = normalize(viewDistance); +vec3 transform(mat4 m,vec3 p) +{ + vec4 temp=m*vec4(p,1.0); + return temp.xyz; +} - vec3 pivot = normalize(reflect(-viewDirection, fragment.normal)); - vec3 startPos = fragment.position + (pivot * 0.0001); +vec4 transform(mat4 m,vec4 p) +{ + return m*p; +} - float currentLength = min(length(viewDistance) / steps, startDistance); - float bestDepth = 10000.0; - vec2 bestUV = vec2(0.0); +void swapComp(inout vec2 v) +{ + v=v.yx; +} - for (int i = 0; i < steps; i++) - { - vec3 currentPosition = startPos + pivot * currentLength; - vec4 projectedPosition = worldToFragSpace(currentPosition, camera.viewProjMatrix); - vec2 currentUV = projectedPosition.xy; - float projectedDepth = projectedPosition.z; +void main() +{ + vec2 uResolution=vec2(1600.0,900.0); + FragmentInfo fragment = getFragmentInfo( + TexCoord, albedoTex, normalTex, materialTex, depthTex, camera.invViewProjMatrix); + float rayLength=1000.f; + + vec3 viewDistance = camera.position - fragment.position; + vec3 viewDirection = normalize(viewDistance); + vec3 reflectDirection = normalize(reflect(-viewDirection, fragment.normal)); + + vec3 wp0 = fragment.position; + vec3 wp1 = fragment.position+reflectDirection*rayLength; + + vec3 vp0=transform(camera.viewMatrix,wp0); + vec3 vp1=transform(camera.viewMatrix,wp1); - if (currentUV.x > 1.0 || currentUV.y > 1.0 || - currentUV.x < 0.0 || currentUV.y < 0.0) break; + vec4 ho0=transform(camera.projectionMatrix,vec4(vp0,1.0)); + vec4 ho1=transform(camera.projectionMatrix,vec4(vp1,1.0)); + + float w0=1.0/ho0.w; + float w1=1.0/ho1.w; + + vec3 vpProj0=vp0*w0; + vec3 vpProj1=vp1*w1; + + vec2 ndc0=ho0.xy*w0; + vec2 ndc1=ho1.xy*w1; + + vec2 scr0 =(ndc0+1.0)/2*uResolution; + vec2 scr1 =(ndc1+1.0)/2*uResolution; + + scr1+=distance(scr0,scr1)<0.01?0.01:0.0; + + vec2 delta=scr1-scr0; + bool permute=false; + if(abs(delta.x) < abs(delta.y)) + { + permute=true; + swapComp(delta); + swapComp(scr0); + swapComp(scr1); + } + float stepDir=sign(delta.x); + float invDx=stepDir/delta.x; + + vec3 dVpProj=(vpProj1-vpProj0)*invDx; + float dw=(w1-w0)*invDx; + vec2 dScr=vec2(stepDir,delta.y*invDx); + + scr0+=dScr; + vpProj0+=dVpProj; + w0+=dw; + + float lastZmax = vp0.z; + vec2 result; + bool isHit=false; + const mat4 invProj = inverse(camera.projectionMatrix); + int step=0; + bool checkthickness=false; + for(;step<2000;step++,scr0+=dScr,vpProj0.z+=dVpProj.z,w0+=dw) + { + result.xy=permute?scr0.yx:scr0; + vec2 depths; + depths.x=lastZmax; + depths.y=(dVpProj.z*0.5+vpProj0.z)/(dw*0.5+w0); + lastZmax=depths.y; + if(depths.x uResolution.x || result.x < 0 || result.y > uResolution.y || result.y < 0) + break; + + vec2 uv=result/uResolution; + float d = sampleDepth(uv); + vec4 normPosition = vec4(2.0f * uv - vec2(1.0f), d, 1.0f); + vec4 vpos = invProj * normPosition; + vpos/=vpos.w; + float sceneDepth=vpos.z; - float currentFragDepth = texture(depthTex, currentUV).r; - float depthDiff = abs(1.0 / projectedDepth - 1.0 / currentFragDepth); - if (depthDiff < bestDepth) - { - bestUV = currentUV; - bestDepth = depthDiff; - if (depthDiff < thickness) - break; - } - else - { - vec3 newPosition = reconstructWorldPosition(currentFragDepth, currentUV, camera.invViewProjMatrix); - currentLength = length(startPos - newPosition); - } - } - - vec3 reflection = bestUV != vec2(0.0) ? texture(HDRTex, bestUV).rgb : vec3(0.0); - OutColor = vec4(reflection, 1.0); + if(!checkthickness&&(depths.y-sceneDepth>thickness)) + checkthickness=true; + float curDiff=sceneDepth-depths.y; + float prevDiff=sceneDepth-depths.x; + if((curDiff>0 && prevDiff<0) || + (checkthickness && abs(curDiff) Date: Sat, 9 Mar 2024 10:14:54 +0800 Subject: [PATCH 02/48] Merge branch 'hierarchical_z_buffer' of https://github.com/asc-community/MxEngine into screen_space_ray_tracing --- .../Components/Camera/CameraController.cpp | 17 +++++++ src/Core/Components/Camera/CameraController.h | 2 + src/Core/Rendering/RenderAdaptor.cpp | 5 +++ src/Core/Rendering/RenderController.cpp | 27 ++++++++++++ src/Core/Rendering/RenderController.h | 1 + src/Core/Rendering/RenderPipeline.h | 1 + .../hierarchical_depth_buffer_generator.glsl | 44 +++++++++++++++++++ src/Platform/OpenGL/Texture.cpp | 11 ++++- src/Platform/OpenGL/Texture.h | 1 + 9 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index ab0229f9a..a6f9d7bf4 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -35,6 +35,7 @@ #include "PerspectiveCamera.h" #include "FrustrumCamera.h" #include "Core/Runtime/Reflection.h" +#include "fmt/format.h" namespace MxEngine { @@ -430,6 +431,11 @@ namespace MxEngine return this->renderBuffers->Depth; } + MxVector CameraController::GetHiZ() const + { + return this->renderBuffers->HiZ; + } + TextureHandle CameraController::GetAverageWhiteTexture() const { return this->renderBuffers->AverageWhite; @@ -461,6 +467,7 @@ namespace MxEngine this->HDR = Factory::Create(); this->SwapHDR1 = Factory::Create(); this->SwapHDR2 = Factory::Create(); + for (int i = 0; i < 3; i++) HiZ.emplace_back(Factory::Create()); this->Resize(width, height); @@ -497,6 +504,15 @@ namespace MxEngine this->Depth->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera depth")); this->Depth->SetWrapType(TextureWrap::CLAMP_TO_EDGE); + for (int i = 0; i < this->HiZ.size(); i++) + { + int scale = pow(2, i+1); + MxString tag = ToMxString(fmt::format("!camera depth lv{}", i + 1)); + this->HiZ[i]->Load(nullptr, width / scale, height / scale, 1, false, TextureFormat::R32F); + this->HiZ[i]->SetInternalEngineTag(tag); + this->HiZ[i]->SetWrapType(TextureWrap::CLAMP_TO_EDGE); + } + this->AverageWhite->Load(nullptr, 1, 1, 3, false, TextureFormat::RGBA16F); this->AverageWhite->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera white")); this->AverageWhite->SetWrapType(TextureWrap::CLAMP_TO_EDGE); @@ -524,6 +540,7 @@ namespace MxEngine Factory::Destroy(this->HDR); Factory::Destroy(this->SwapHDR1); Factory::Destroy(this->SwapHDR2); + for(auto& it:this->HiZ)Factory::Destroy(it); } MXENGINE_REFLECT_TYPE diff --git a/src/Core/Components/Camera/CameraController.h b/src/Core/Components/Camera/CameraController.h index 73b885e33..15edef324 100644 --- a/src/Core/Components/Camera/CameraController.h +++ b/src/Core/Components/Camera/CameraController.h @@ -49,6 +49,7 @@ namespace MxEngine TextureHandle Normal; TextureHandle Material; TextureHandle Depth; + MxVector HiZ; TextureHandle AverageWhite; TextureHandle HDR; TextureHandle SwapHDR1; @@ -131,6 +132,7 @@ namespace MxEngine TextureHandle GetNormalTexture() const; TextureHandle GetMaterialTexture() const; TextureHandle GetDepthTexture() const; + MxVector GetHiZ() const; TextureHandle GetAverageWhiteTexture() const; TextureHandle GetHDRTexture() const; TextureHandle GetSwapHDRTexture1() const; diff --git a/src/Core/Rendering/RenderAdaptor.cpp b/src/Core/Rendering/RenderAdaptor.cpp index 78ef8b50f..29ba68bcb 100644 --- a/src/Core/Rendering/RenderAdaptor.cpp +++ b/src/Core/Rendering/RenderAdaptor.cpp @@ -143,6 +143,11 @@ namespace MxEngine shaderFolder / "gbuffer_fragment.glsl" ); + environment.Shaders["HIZ"_id] = AssetManager::LoadShader( + shaderFolder / "rect_vertex.glsl", + shaderFolder / "hierarchical_depth_buffer_generator.glsl" + ); + environment.Shaders["GBufferMask"_id] = AssetManager::LoadShader( shaderFolder / "gbuffer_vertex.glsl", shaderFolder / "gbuffer_mask_fragment.glsl" diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 0739fc6ee..19b409ebb 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -385,6 +385,14 @@ namespace MxEngine void RenderController::PerformPostProcessing(CameraUnit& camera) { + // MAKE_SCOPE_PROFILER("RenderController::PerformPostProcessing()"); + + // camera.AlbedoTexture->GenerateMipmaps(); + // camera.MaterialTexture->GenerateMipmaps(); + // camera.NormalTexture->GenerateMipmaps(); + // camera.DepthTexture->GenerateMipmaps(); + + // this->GenerateHIZ(camera.DepthTexture, camera.HiZ); MAKE_RENDER_PASS_SCOPE("RenderController::PerformPostProcessing()"); this->ApplySSAO(camera, camera.HDRTexture, camera.SwapTexture1, camera.SwapTexture2); @@ -643,6 +651,25 @@ namespace MxEngine std::swap(input, output); } + void RenderController::GenerateHIZ(TextureHandle& zBuffer, MxVector& HiZ) + { + MAKE_SCOPE_PROFILER("RenderController::GenerateHIZ()"); + + auto& shader = this->Pipeline.Environment.Shaders["HIZ"_id]; + + MxVector inputTex = {zBuffer}; + for (auto it : HiZ) inputTex.emplace_back(it); + + for (int i =0;iBind(); + inputTex[i]->Bind(0); + auto& outputTex = inputTex[i + 1]; + shader->SetUniform("uPreviousLevelRes", VectorInt2(outputTex->GetWidth(), outputTex->GetHeight())); + this->RenderToTexture(outputTex, shader); + } + } + void RenderController::ApplySSR(CameraUnit& camera, TextureHandle& input, TextureHandle& temporary, TextureHandle& output) { if (camera.SSR == nullptr || camera.SSR->GetSteps() == 0) return; diff --git a/src/Core/Rendering/RenderController.h b/src/Core/Rendering/RenderController.h index 2aa40502c..b685fa966 100644 --- a/src/Core/Rendering/RenderController.h +++ b/src/Core/Rendering/RenderController.h @@ -91,6 +91,7 @@ namespace MxEngine void BindFogInformation(const CameraUnit& camera, const Shader& shader); void AttachDefaultVAO(); void RenderToAttachedFrameBuffer(const Shader& shader); + void GenerateHIZ(TextureHandle& input, MxVector& HiZ); public: const Renderer& GetRenderEngine() const; diff --git a/src/Core/Rendering/RenderPipeline.h b/src/Core/Rendering/RenderPipeline.h index 93ea71115..46fbecb85 100644 --- a/src/Core/Rendering/RenderPipeline.h +++ b/src/Core/Rendering/RenderPipeline.h @@ -62,6 +62,7 @@ namespace MxEngine TextureHandle NormalTexture; TextureHandle MaterialTexture; TextureHandle DepthTexture; + MxVector< TextureHandle> HiZ; TextureHandle AverageWhiteTexture; TextureHandle HDRTexture; TextureHandle SwapTexture1; diff --git a/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl b/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl new file mode 100644 index 000000000..d662ddf74 --- /dev/null +++ b/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl @@ -0,0 +1,44 @@ +layout(binding = 0) uniform sampler2D depthBuffer; +uniform ivec2 uPreviousLevelRes; + +out vec4 OutColor; + +void main() +{ + ivec2 currentTexCoord = ivec2(gl_FragCoord); + ivec2 lastTexCoord = 2 * currentTexCoord; + + vec4 depth; + depth.x = texelFetch(depthBuffer,lastTexCoord, 0).r; + depth.y = texelFetch(depthBuffer, lastTexCoord + ivec2(1, 0), 0).r; + depth.z = texelFetch(depthBuffer,lastTexCoord + ivec2(1, 1),0).r; + depth.w = texelFetch(depthBuffer,lastTexCoord + ivec2(0, 1), 0).r; + + float minDepth = min(min(depth.x, depth.y), + min(depth.z, depth.w)); + + bool extraCol = ((uPreviousLevelRes.x & 1) != 0); + bool extraRow = ((uPreviousLevelRes.y & 1) != 0); + if (extraCol) + { + vec2 col; + col.x = texelFetch(depthBuffer, lastTexCoord + ivec2(2, 0), 0).r; + col.y = texelFetch(depthBuffer, lastTexCoord + ivec2(2, 1), 0).r; + + if (extraRow) + { + float corner = texelFetch(depthBuffer, lastTexCoord + ivec2(2, 2), 0).r; + minDepth = min(minDepth, corner); + } + minDepth = min(minDepth, min(col.x, col.y)); + } + if (extraRow) + { + vec2 row; + row.x = texelFetch(depthBuffer, lastTexCoord + ivec2(0, 2), 0).r; + row.y = texelFetch(depthBuffer, lastTexCoord + ivec2(1, 2), 0).r; + minDepth = min(minDepth, min(row.x, row.y)); + } + + OutColor = vec4(minDepth,0.f,0.f,1.f); +} diff --git a/src/Platform/OpenGL/Texture.cpp b/src/Platform/OpenGL/Texture.cpp index 8bed20146..957704919 100644 --- a/src/Platform/OpenGL/Texture.cpp +++ b/src/Platform/OpenGL/Texture.cpp @@ -43,7 +43,7 @@ namespace MxEngine GL_RG8, GL_RG16, GL_R16F, - GL_R32F, + GL_R32F_EXT,//cannot use GL_R32F. Why? GL_RG16F, GL_RG32F, GL_RGB, @@ -205,7 +205,10 @@ namespace MxEngine switch (channels) { case 1: - dataChannels = GL_RED; + if (format != TextureFormat::R32F) + dataChannels = GL_RED; + else + dataChannels = GL_RED_EXT; break; case 2: dataChannels = GL_RG; @@ -320,6 +323,10 @@ namespace MxEngine GLCALL(glGenerateMipmap(GL_TEXTURE_2D)); } + void Texture::Pooling() const + { + } + void Texture::SetBorderColor(Vector4 color) { this->Bind(0); diff --git a/src/Platform/OpenGL/Texture.h b/src/Platform/OpenGL/Texture.h index 0602fe4ce..3e159dea1 100644 --- a/src/Platform/OpenGL/Texture.h +++ b/src/Platform/OpenGL/Texture.h @@ -115,6 +115,7 @@ namespace MxEngine void SetMinLOD(size_t lod); size_t GetMaxTextureLOD() const; Image GetRawTextureData() const; + void Pooling() const; void GenerateMipmaps(); void SetBorderColor(Vector4 color); bool IsMultisampled() const; From f300418adb47e45edbab90dad56b46edf81021ee Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 9 Mar 2024 11:42:17 +0800 Subject: [PATCH 03/48] max pooling --- .../Components/Camera/CameraController.cpp | 2 +- src/Core/Rendering/RenderController.cpp | 46 ++++++------------- src/Core/Rendering/RenderController.h | 3 +- .../hierarchical_depth_buffer_generator.glsl | 16 ++++--- src/Platform/OpenGL/Texture.cpp | 4 -- src/Platform/OpenGL/Texture.h | 1 - 6 files changed, 26 insertions(+), 46 deletions(-) diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index a6f9d7bf4..9b8629e85 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -467,7 +467,7 @@ namespace MxEngine this->HDR = Factory::Create(); this->SwapHDR1 = Factory::Create(); this->SwapHDR2 = Factory::Create(); - for (int i = 0; i < 3; i++) HiZ.emplace_back(Factory::Create()); + for (int i = 0; i < 2; i++) HiZ.emplace_back(Factory::Create()); this->Resize(width, height); diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 19b409ebb..b15013dfb 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -352,11 +352,21 @@ namespace MxEngine std::swap(input, output); } - void RenderController::GenerateDepthPyramid(TextureHandle& depth) + void RenderController::GenerateDepthPyramid(TextureHandle& zBuffer, MxVector& HiZ) { MAKE_RENDER_PASS_SCOPE("RenderController::GenerateDepthPyramid()"); - // generate depth texture mipmaps for post-processing algorithms. Replace later with hierarhical depth map - depth->GenerateMipmaps(); + auto& shader = this->Pipeline.Environment.Shaders["HIZ"_id]; + MxVector inputTex = { zBuffer }; + for (auto it : HiZ) inputTex.emplace_back(it); + + for (int i = 0; i < HiZ.size(); i++) + { + shader->Bind(); + inputTex[i]->Bind(0); + auto& outputTex = inputTex[i + 1]; + shader->SetUniform("uPreviousLevelRes", VectorInt2(outputTex->GetWidth(), outputTex->GetHeight())); + this->RenderToTexture(outputTex, shader); + } } TextureHandle RenderController::ComputeAverageWhite(CameraUnit& camera) @@ -385,14 +395,6 @@ namespace MxEngine void RenderController::PerformPostProcessing(CameraUnit& camera) { - // MAKE_SCOPE_PROFILER("RenderController::PerformPostProcessing()"); - - // camera.AlbedoTexture->GenerateMipmaps(); - // camera.MaterialTexture->GenerateMipmaps(); - // camera.NormalTexture->GenerateMipmaps(); - // camera.DepthTexture->GenerateMipmaps(); - - // this->GenerateHIZ(camera.DepthTexture, camera.HiZ); MAKE_RENDER_PASS_SCOPE("RenderController::PerformPostProcessing()"); this->ApplySSAO(camera, camera.HDRTexture, camera.SwapTexture1, camera.SwapTexture2); @@ -651,25 +653,6 @@ namespace MxEngine std::swap(input, output); } - void RenderController::GenerateHIZ(TextureHandle& zBuffer, MxVector& HiZ) - { - MAKE_SCOPE_PROFILER("RenderController::GenerateHIZ()"); - - auto& shader = this->Pipeline.Environment.Shaders["HIZ"_id]; - - MxVector inputTex = {zBuffer}; - for (auto it : HiZ) inputTex.emplace_back(it); - - for (int i =0;iBind(); - inputTex[i]->Bind(0); - auto& outputTex = inputTex[i + 1]; - shader->SetUniform("uPreviousLevelRes", VectorInt2(outputTex->GetWidth(), outputTex->GetHeight())); - this->RenderToTexture(outputTex, shader); - } - } - void RenderController::ApplySSR(CameraUnit& camera, TextureHandle& input, TextureHandle& temporary, TextureHandle& output) { if (camera.SSR == nullptr || camera.SSR->GetSteps() == 0) return; @@ -1501,6 +1484,7 @@ namespace MxEngine camera.NormalTexture = cameraController.GetNormalTexture(); camera.MaterialTexture = cameraController.GetMaterialTexture(); camera.DepthTexture = cameraController.GetDepthTexture(); + camera.HiZ = cameraController.GetHiZ(); camera.AverageWhiteTexture = cameraController.GetAverageWhiteTexture(); camera.HDRTexture = cameraController.GetHDRTexture(); camera.SwapTexture1 = cameraController.GetSwapHDRTexture1(); @@ -1656,7 +1640,7 @@ namespace MxEngine this->DrawObjects(camera, *this->Pipeline.Environment.Shaders["GBuffer"_id], this->Pipeline.OpaqueObjects); this->DrawObjects(camera, *this->Pipeline.Environment.Shaders["GBufferMask"_id], this->Pipeline.MaskedObjects); - this->GenerateDepthPyramid(camera.DepthTexture); + this->GenerateDepthPyramid(camera.DepthTexture,camera.HiZ); this->DrawParticles(camera, this->Pipeline.OpaqueParticleSystems, *this->Pipeline.Environment.Shaders["ParticleOpaque"_id]); diff --git a/src/Core/Rendering/RenderController.h b/src/Core/Rendering/RenderController.h index b685fa966..b18450a10 100644 --- a/src/Core/Rendering/RenderController.h +++ b/src/Core/Rendering/RenderController.h @@ -62,7 +62,7 @@ namespace MxEngine void DrawObject(const RenderUnit& unit, size_t instanceCount, size_t baseInstance, const Shader& shader); void ComputeBloomEffect(CameraUnit& camera, const TextureHandle& output); TextureHandle ComputeAverageWhite(CameraUnit& camera); - void GenerateDepthPyramid(TextureHandle& depth); + void GenerateDepthPyramid(TextureHandle& zBuffer, MxVector& HiZ); void PerformPostProcessing(CameraUnit& camera); void PerformLightPass(CameraUnit& camera); void DrawTransparentObjects(CameraUnit& camera); @@ -91,7 +91,6 @@ namespace MxEngine void BindFogInformation(const CameraUnit& camera, const Shader& shader); void AttachDefaultVAO(); void RenderToAttachedFrameBuffer(const Shader& shader); - void GenerateHIZ(TextureHandle& input, MxVector& HiZ); public: const Renderer& GetRenderEngine() const; diff --git a/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl b/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl index d662ddf74..7d8272a94 100644 --- a/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl +++ b/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl @@ -14,9 +14,11 @@ void main() depth.z = texelFetch(depthBuffer,lastTexCoord + ivec2(1, 1),0).r; depth.w = texelFetch(depthBuffer,lastTexCoord + ivec2(0, 1), 0).r; - float minDepth = min(min(depth.x, depth.y), - min(depth.z, depth.w)); - + //Depth is reversed.The closer to the object the higher depth we get. + //So instead of min pooling we perform max pooling. + float maxDepth = max(max(depth.x, depth.y), + max(depth.z, depth.w)); + bool extraCol = ((uPreviousLevelRes.x & 1) != 0); bool extraRow = ((uPreviousLevelRes.y & 1) != 0); if (extraCol) @@ -28,17 +30,17 @@ void main() if (extraRow) { float corner = texelFetch(depthBuffer, lastTexCoord + ivec2(2, 2), 0).r; - minDepth = min(minDepth, corner); + maxDepth = max(maxDepth, corner); } - minDepth = min(minDepth, min(col.x, col.y)); + maxDepth = max(maxDepth, max(col.x, col.y)); } if (extraRow) { vec2 row; row.x = texelFetch(depthBuffer, lastTexCoord + ivec2(0, 2), 0).r; row.y = texelFetch(depthBuffer, lastTexCoord + ivec2(1, 2), 0).r; - minDepth = min(minDepth, min(row.x, row.y)); + maxDepth = max(maxDepth, max(row.x, row.y)); } - OutColor = vec4(minDepth,0.f,0.f,1.f); + OutColor = vec4(maxDepth,0.f,0.f,1.f); } diff --git a/src/Platform/OpenGL/Texture.cpp b/src/Platform/OpenGL/Texture.cpp index 957704919..4a6f91dea 100644 --- a/src/Platform/OpenGL/Texture.cpp +++ b/src/Platform/OpenGL/Texture.cpp @@ -323,10 +323,6 @@ namespace MxEngine GLCALL(glGenerateMipmap(GL_TEXTURE_2D)); } - void Texture::Pooling() const - { - } - void Texture::SetBorderColor(Vector4 color) { this->Bind(0); diff --git a/src/Platform/OpenGL/Texture.h b/src/Platform/OpenGL/Texture.h index 3e159dea1..0602fe4ce 100644 --- a/src/Platform/OpenGL/Texture.h +++ b/src/Platform/OpenGL/Texture.h @@ -115,7 +115,6 @@ namespace MxEngine void SetMinLOD(size_t lod); size_t GetMaxTextureLOD() const; Image GetRawTextureData() const; - void Pooling() const; void GenerateMipmaps(); void SetBorderColor(Vector4 color); bool IsMultisampled() const; From e9079f97a0fa5db017755024a69de98acd55b079 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 9 Mar 2024 21:48:50 +0800 Subject: [PATCH 04/48] prototype --- samples/Sponza/sponza2.json | 38 ++++------ src/Core/Rendering/RenderController.cpp | 29 +++++--- src/Core/Rendering/RenderController.h | 1 + src/Platform/OpenGL/ShaderBase.cpp | 10 +-- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 74 +++++++++++++------ 5 files changed, 93 insertions(+), 59 deletions(-) diff --git a/samples/Sponza/sponza2.json b/samples/Sponza/sponza2.json index 678622411..cd2a87b68 100644 --- a/samples/Sponza/sponza2.json +++ b/samples/Sponza/sponza2.json @@ -2220,7 +2220,7 @@ "paused": false, "physics-step": 1.0, "time-scale": 1.0, - "total-time": 3900.35009765625, + "total-time": 5737.36962890625, "viewport": 0 }, "mxobjects": [ @@ -2228,14 +2228,14 @@ "CameraController": { "camera type": "PERSPECTIVE", "direction": [ - 0.9978463053703308, - 0.06556776911020279, - 0.0018980845343321562 + 0.7886037826538086, + -0.18925577402114868, + 0.5850524306297302 ], "forward vector": [ - 0.9999982118606567, + 0.8031178712844849, 0.0, - 0.001902177813462913 + 0.5958201885223389 ], "id": 0, "is listening window resize event": true, @@ -2247,9 +2247,9 @@ "znear": 0.10000000149011612 }, "right vector": [ - -0.0019022214692085981, + -0.5958201885223389, 0.0, - 0.9999982118606567 + 0.8031178712844849 ], "up vector": [ 0.0, @@ -2285,17 +2285,9 @@ "radius": 1.0, "sample count": 4 }, - "CameraSSGI": { - "blur iterations": 1, - "blur lod": 5, - "distance": 50.0, - "id": 0, - "intensity": 2.5, - "ray steps": 3 - }, "CameraSSR": { "id": 0, - "start distance": 2.009999990463257, + "start distance": 2.0, "steps": 10, "thickness": 0.5 }, @@ -2408,9 +2400,9 @@ 1.0 ], "linear velocity": [ - 0.0, - 5.7220458984375e-06, - 2.6808647746179304e-08 + -4.694485937761783e-07, + 2.86102294921875e-06, + 1.1736214844404458e-07 ], "mass": 1.0, "push velocity": [ @@ -2449,9 +2441,9 @@ "name": "Camera", "transform": { "position": [ - -25.250308990478516, - 2.999999523162842, - -0.40193822979927063 + -21.208274841308594, + 2.999999761581421, + -2.669466972351074 ], "rotation": [ 0.0, diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index b15013dfb..186c265a4 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -79,11 +79,11 @@ namespace MxEngine ); generatorMasked.GenerateFor( *this->Pipeline.Environment.Shaders["DirLightMaskDepthMap"_id], - this->Pipeline.Lighting.DirectionalLights, + this->Pipeline.Lighting.DirectionalLights, ShadowMapGenerator::LoadStoreOptions::LOAD ); } - + if (hasSpotLights) { MAKE_RENDER_PASS_SCOPE("RenderController::PrepareSpotLightMaps()"); @@ -91,13 +91,13 @@ namespace MxEngine *this->Pipeline.Environment.Shaders["SpotLightDepthMap"_id], this->Pipeline.Lighting.SpotLights, ShadowMapGenerator::LoadStoreOptions::CLEAR - ); + ); generatorMasked.GenerateFor( *this->Pipeline.Environment.Shaders["SpotLightMaskDepthMap"_id], this->Pipeline.Lighting.SpotLights, ShadowMapGenerator::LoadStoreOptions::LOAD - ); - } + ); + } if (hasPointLights) { @@ -666,10 +666,10 @@ namespace MxEngine Texture::TextureBindId textureId = 0; this->BindGBuffer(camera, *SSRShader, textureId); this->BindCameraInformation(camera, *SSRShader); + this->BindHiZ(camera, *SSRShader, textureId); - SSRShader->SetUniform("thickness", camera.SSR->GetThickness()); - SSRShader->SetUniform("startDistance", camera.SSR->GetStartDistance()); - SSRShader->SetUniform("steps", (int)camera.SSR->GetSteps()); + SSRShader->SetUniform("thickness", camera.SSR->GetThickness()); + SSRShader->SetUniform("screenResolution", Vector2(camera.HDRTexture->GetWidth(), camera.HDRTexture->GetHeight())); this->RenderToTexture(temporary, SSRShader); @@ -1039,8 +1039,9 @@ namespace MxEngine shader.SetUniform("camera.position", camera.ViewportPosition); shader.SetUniform("camera.viewProjMatrix", camera.ViewProjectionMatrix); shader.SetUniform("camera.invViewProjMatrix", camera.InverseViewProjMatrix); - shader.SetUniform("camera.viewMatrix", camera.ViewMatrix); + shader.SetUniform("camera.viewMatrix", camera.ViewMatrix); shader.SetUniform("camera.projectionMatrix", camera.ProjectionMatrix); + shader.SetUniform("camera.invProjectionMatrix", Inverse(camera.ProjectionMatrix)); } void RenderController::BindGBuffer(const CameraUnit& camera, const Shader& shader, Texture::TextureBindId& startId) { @@ -1054,6 +1055,16 @@ namespace MxEngine shader.SetUniform("materialTex", camera.MaterialTexture->GetBoundId()); shader.SetUniform("depthTex", camera.DepthTexture->GetBoundId()); } + + void RenderController::BindHiZ(const CameraUnit& camera, const Shader& shader, Texture::TextureBindId& startId) + { + for(int i=0;iBind(startId++); + shader.SetUniform(ToMxString( fmt::format("hiZTex{}", i)), it->GetBoundId()); + } + } const Renderer& RenderController::GetRenderEngine() const { diff --git a/src/Core/Rendering/RenderController.h b/src/Core/Rendering/RenderController.h index b18450a10..5e0cefbce 100644 --- a/src/Core/Rendering/RenderController.h +++ b/src/Core/Rendering/RenderController.h @@ -86,6 +86,7 @@ namespace MxEngine void SubmitInstancedLights(); void SubmitDirectionalLightInformation(ShaderHandle& shader, Texture::TextureBindId textureId); void BindGBuffer(const CameraUnit& camera, const Shader& shader, Texture::TextureBindId& startId); + void BindHiZ(const CameraUnit& camera, const Shader& shader, Texture::TextureBindId& startId); void BindSkyboxInformation(const CameraUnit& camera, const Shader& shader, Texture::TextureBindId& startId); void BindCameraInformation(const CameraUnit& camera, const Shader& shader); void BindFogInformation(const CameraUnit& camera, const Shader& shader); diff --git a/src/Platform/OpenGL/ShaderBase.cpp b/src/Platform/OpenGL/ShaderBase.cpp index 93e338ee1..2669ad1d3 100644 --- a/src/Platform/OpenGL/ShaderBase.cpp +++ b/src/Platform/OpenGL/ShaderBase.cpp @@ -166,7 +166,7 @@ namespace MxEngine template<> ShaderBase::ShaderId ShaderBase::CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& path) - { + { GLCALL(ShaderId shaderId = glCreateShader((GLenum)type)); ShaderPreprocessor preprocessor(sourceCode); @@ -183,10 +183,10 @@ namespace MxEngine { MXLOG_WARNING("OpenGL::Shader", "failed to compile shader stage: " + ToMxString(path)); } - - return shaderId; - } - + + return shaderId; + } + void ShaderBase::DeleteShader(ShaderId id) { GLCALL(glDeleteShader(id)); diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index eaea50dd0..aa0de3c61 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -8,6 +8,8 @@ uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; uniform sampler2D HDRTex; +uniform sampler2D hiZTex0; +uniform sampler2D hiZTex1; struct Camera { @@ -16,18 +18,24 @@ struct Camera mat4 invViewProjMatrix; mat4 viewMatrix; mat4 projectionMatrix; + mat4 invProjectionMatrix; }; uniform Camera camera; uniform EnvironmentInfo environment; -uniform int steps; uniform float thickness; -uniform float startDistance; +uniform vec2 screenResolution; -float sampleDepth(vec2 uv) +float sampleDepth(ivec2 uv,int level) { - return texture(depthTex,uv).r; + switch(level) + { + case 0:return texelFetch(depthTex,uv,0).r; + case 1:return texelFetch(hiZTex0,uv/ivec2(2),0).r; + case 2:return texelFetch(hiZTex1,uv/ivec2(4),0).r; + //Add more levels if needed + } } vec3 transform(mat4 m,vec3 p) @@ -46,9 +54,15 @@ void swapComp(inout vec2 v) v=v.yx; } +#define TRACE_RAY(stp) \ + do{\ + scr0+=dScr*int(stp);\ + vpProj0.z+=dVpProj.z*int(stp);\ + w0+=dw*int(stp);\ + }while(false); + void main() { - vec2 uResolution=vec2(1600.0,900.0); FragmentInfo fragment = getFragmentInfo( TexCoord, albedoTex, normalTex, materialTex, depthTex, camera.invViewProjMatrix); float rayLength=1000.f; @@ -75,8 +89,8 @@ void main() vec2 ndc0=ho0.xy*w0; vec2 ndc1=ho1.xy*w1; - vec2 scr0 =(ndc0+1.0)/2*uResolution; - vec2 scr1 =(ndc1+1.0)/2*uResolution; + vec2 scr0 =(ndc0+1.0)/2.0*screenResolution; + vec2 scr1 =(ndc1+1.0)/2.0*screenResolution; scr1+=distance(scr0,scr1)<0.01?0.01:0.0; @@ -103,42 +117,58 @@ void main() float lastZmax = vp0.z; vec2 result; bool isHit=false; - const mat4 invProj = inverse(camera.projectionMatrix); - int step=0; bool checkthickness=false; - for(;step<2000;step++,scr0+=dScr,vpProj0.z+=dVpProj.z,w0+=dw) + int level=0; + int maxLevel=2; + float testStp=0.0; + int maxStp=int(sqrt(screenResolution.x*screenResolution.x+screenResolution.y*screenResolution.y)); + //Todo: /(ㄒoㄒ)/~~ Handle diffuse lobe. Sampling more rays or using cone tracing when the BRDF lobe is fat. + for(int curStep=0; curStep uResolution.x || result.x < 0 || result.y > uResolution.y || result.y < 0) + //check boundary + if( result.x > screenResolution.x || result.x < 0 || + result.y > screenResolution.y || result.y < 0) break; - vec2 uv=result/uResolution; - float d = sampleDepth(uv); - vec4 normPosition = vec4(2.0f * uv - vec2(1.0f), d, 1.0f); - vec4 vpos = invProj * normPosition; + float d = sampleDepth(ivec2(result),level); + vec4 normPosition = vec4(2.0f * result - vec2(1.0f), d, 1.0f); + vec4 vpos = transform(camera.invProjectionMatrix,normPosition); vpos/=vpos.w; - float sceneDepth=vpos.z; + float sceneDepth=vpos.z; if(!checkthickness&&(depths.y-sceneDepth>thickness)) checkthickness=true; + float curDiff=sceneDepth-depths.y; - float prevDiff=sceneDepth-depths.x; - if((curDiff>0 && prevDiff<0) || - (checkthickness && abs(curDiff)0 || curDiff<0&&abs(curDiff) Date: Sat, 9 Mar 2024 21:56:34 +0800 Subject: [PATCH 05/48] formatting --- src/Core/Rendering/RenderController.cpp | 1 + src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 237 +++++++++--------- 2 files changed, 120 insertions(+), 118 deletions(-) diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 186c265a4..ab0accc42 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -1676,3 +1676,4 @@ namespace MxEngine this->AttachDefaultVAO(); } } + diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index aa0de3c61..601b5ad57 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -18,7 +18,7 @@ struct Camera mat4 invViewProjMatrix; mat4 viewMatrix; mat4 projectionMatrix; - mat4 invProjectionMatrix; + mat4 invProjectionMatrix; }; uniform Camera camera; @@ -26,32 +26,33 @@ uniform EnvironmentInfo environment; uniform float thickness; uniform vec2 screenResolution; +uniform float intensity;//For users who wanna emphasize emotion -float sampleDepth(ivec2 uv,int level) +float sampleDepth(ivec2 uv, int level) { - switch(level) - { - case 0:return texelFetch(depthTex,uv,0).r; - case 1:return texelFetch(hiZTex0,uv/ivec2(2),0).r; - case 2:return texelFetch(hiZTex1,uv/ivec2(4),0).r; - //Add more levels if needed - } + switch (level) + { + case 0:return texelFetch(depthTex, uv, 0).r; + case 1:return texelFetch(hiZTex0, uv / ivec2(2), 0).r; + case 2:return texelFetch(hiZTex1, uv / ivec2(4), 0).r; + //Add more levels if needed + } } -vec3 transform(mat4 m,vec3 p) +vec3 transform(mat4 m, vec3 p) { - vec4 temp=m*vec4(p,1.0); - return temp.xyz; + vec4 temp = m * vec4(p, 1.0); + return temp.xyz; } -vec4 transform(mat4 m,vec4 p) +vec4 transform(mat4 m, vec4 p) { - return m*p; + return m * p; } void swapComp(inout vec2 v) { - v=v.yx; + v = v.yx; } #define TRACE_RAY(stp) \ @@ -65,110 +66,110 @@ void main() { FragmentInfo fragment = getFragmentInfo( TexCoord, albedoTex, normalTex, materialTex, depthTex, camera.invViewProjMatrix); - float rayLength=1000.f; - - vec3 viewDistance = camera.position - fragment.position; + float rayLength = 8000.f; + + vec3 viewDistance = camera.position - fragment.position; vec3 viewDirection = normalize(viewDistance); vec3 reflectDirection = normalize(reflect(-viewDirection, fragment.normal)); - + vec3 wp0 = fragment.position; - vec3 wp1 = fragment.position+reflectDirection*rayLength; - - vec3 vp0=transform(camera.viewMatrix,wp0); - vec3 vp1=transform(camera.viewMatrix,wp1); - - vec4 ho0=transform(camera.projectionMatrix,vec4(vp0,1.0)); - vec4 ho1=transform(camera.projectionMatrix,vec4(vp1,1.0)); - - float w0=1.0/ho0.w; - float w1=1.0/ho1.w; - - vec3 vpProj0=vp0*w0; - vec3 vpProj1=vp1*w1; - - vec2 ndc0=ho0.xy*w0; - vec2 ndc1=ho1.xy*w1; - - vec2 scr0 =(ndc0+1.0)/2.0*screenResolution; - vec2 scr1 =(ndc1+1.0)/2.0*screenResolution; - - scr1+=distance(scr0,scr1)<0.01?0.01:0.0; - - vec2 delta=scr1-scr0; - bool permute=false; - if(abs(delta.x) < abs(delta.y)) - { - permute=true; - swapComp(delta); - swapComp(scr0); - swapComp(scr1); - } - float stepDir=sign(delta.x); - float invDx=stepDir/delta.x; - - vec3 dVpProj=(vpProj1-vpProj0)*invDx; - float dw=(w1-w0)*invDx; - vec2 dScr=vec2(stepDir,delta.y*invDx); - - scr0+=dScr; - vpProj0+=dVpProj; - w0+=dw; - - float lastZmax = vp0.z; - vec2 result; - bool isHit=false; - bool checkthickness=false; - int level=0; - int maxLevel=2; - float testStp=0.0; - int maxStp=int(sqrt(screenResolution.x*screenResolution.x+screenResolution.y*screenResolution.y)); - //Todo: /(ㄒoㄒ)/~~ Handle diffuse lobe. Sampling more rays or using cone tracing when the BRDF lobe is fat. - for(int curStep=0; curStep screenResolution.x || result.x < 0 || - result.y > screenResolution.y || result.y < 0) - break; - - float d = sampleDepth(ivec2(result),level); - vec4 normPosition = vec4(2.0f * result - vec2(1.0f), d, 1.0f); - vec4 vpos = transform(camera.invProjectionMatrix,normPosition); - vpos/=vpos.w; - float sceneDepth=vpos.z; - - if(!checkthickness&&(depths.y-sceneDepth>thickness)) - checkthickness=true; - - float curDiff=sceneDepth-depths.y; - if( checkthickness && - (curDiff>0 || curDiff<0&&abs(curDiff) screenResolution.x || result.x < 0 || + result.y > screenResolution.y || result.y < 0) + break; + + float d = sampleDepth(ivec2(result), level); + vec4 normPosition = vec4(2.0f * result - vec2(1.0f), d, 1.0f); + vec4 vpos = transform(camera.invProjectionMatrix, normPosition); + vpos /= vpos.w; + float sceneDepth = vpos.z; + + if (!checkthickness && (depths.y - sceneDepth > thickness)) + checkthickness = true; + + float curDiff = sceneDepth - depths.y; + if (checkthickness && + (curDiff > 0 || curDiff < 0 && abs(curDiff) < thickness)) + { + if (level == 0) + { + isHit = true; + break; + } + TRACE_RAY(-pow(2.0, level)); + level = 0; + } + else + { + level = min(maxLevel, level + 1); + TRACE_RAY(pow(2.0, level)); + } + } + + if (isHit) + OutColor = vec4(texelFetch(HDRTex, ivec2(result), 0).rgb * intensity, 1.0); + else + OutColor = vec4(0.0); } \ No newline at end of file From c7830c0552c85294e7ecc81da4a6839c0c9587fb Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 9 Mar 2024 22:09:24 +0800 Subject: [PATCH 06/48] add intensity --- src/Core/Components/Camera/CameraSSR.cpp | 31 ++++++------------------ src/Core/Components/Camera/CameraSSR.h | 11 ++++----- src/Core/Rendering/RenderController.cpp | 3 ++- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/Core/Components/Camera/CameraSSR.cpp b/src/Core/Components/Camera/CameraSSR.cpp index 99ccf69bf..77f49fbf9 100644 --- a/src/Core/Components/Camera/CameraSSR.cpp +++ b/src/Core/Components/Camera/CameraSSR.cpp @@ -37,31 +37,22 @@ namespace MxEngine return this->thickness; } - size_t CameraSSR::GetSteps() const - { - return this->steps; - } - - float CameraSSR::GetStartDistance() const - { - return this->startDistance; - } - void CameraSSR::SetThickness(float thickness) { this->thickness = Max(thickness, 0.0f); } - void CameraSSR::SetSteps(size_t steps) + float CameraSSR::GetIntensity() const { - this->steps = steps; + return this->intensity; } - void CameraSSR::SetStartDistance(float distance) + + void CameraSSR::SetIntensity(float intensity) { - this->startDistance = Max(distance, 0.0f); + this->intensity = Min(intensity,1.0f); } - + MXENGINE_REFLECT_TYPE { rttr::registration::class_("CameraSSR") @@ -75,16 +66,10 @@ namespace MxEngine rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 10000.0f }), rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) ) - .property("steps", &CameraSSR::GetSteps, &CameraSSR::SetSteps) - ( - rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), - rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 128.0f }), - rttr::metadata(EditorInfo::EDIT_PRECISION, 0.1f) - ) - .property("start distance", &CameraSSR::GetStartDistance, &CameraSSR::SetStartDistance) + .property("intensity", &CameraSSR::GetIntensity, &CameraSSR::SetIntensity) ( rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), - rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 10000000.0f }), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1.0f, 10.0f }), rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) ); } diff --git a/src/Core/Components/Camera/CameraSSR.h b/src/Core/Components/Camera/CameraSSR.h index ff5d75a7b..48524a948 100644 --- a/src/Core/Components/Camera/CameraSSR.h +++ b/src/Core/Components/Camera/CameraSSR.h @@ -37,17 +37,16 @@ namespace MxEngine MAKE_COMPONENT(CameraSSR); float thickness = 0.5f; - size_t steps = 10; - float startDistance = 2.0f; + float intensity = 4.0f; + public: CameraSSR() = default; float GetThickness() const; - size_t GetSteps() const; - float GetStartDistance() const; + float GetIntensity()const; void SetThickness(float thickness); - void SetSteps(size_t steps); - void SetStartDistance(float distance); + void SetIntensity(float intensity); + }; } \ No newline at end of file diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index ab0accc42..924b18076 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -655,7 +655,7 @@ namespace MxEngine void RenderController::ApplySSR(CameraUnit& camera, TextureHandle& input, TextureHandle& temporary, TextureHandle& output) { - if (camera.SSR == nullptr || camera.SSR->GetSteps() == 0) return; + if (camera.SSR == nullptr ) return; MAKE_RENDER_PASS_SCOPE("RenderController::ApplySSR()"); auto& SSRShader = this->Pipeline.Environment.Shaders["SSR"_id]; @@ -670,6 +670,7 @@ namespace MxEngine SSRShader->SetUniform("thickness", camera.SSR->GetThickness()); SSRShader->SetUniform("screenResolution", Vector2(camera.HDRTexture->GetWidth(), camera.HDRTexture->GetHeight())); + SSRShader->SetUniform("intensity", camera.SSR->GetIntensity()); this->RenderToTexture(temporary, SSRShader); From 38042e82320404c85315b5e8f5066a69f69bdac3 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:00:26 +0800 Subject: [PATCH 07/48] add mask --- src/Core/Components/Camera/CameraController.cpp | 13 +++++++++++++ src/Core/Components/Camera/CameraController.h | 2 ++ src/Core/Components/Camera/CameraSSR.cpp | 4 ++-- src/Core/Rendering/RenderController.cpp | 5 +++++ src/Core/Rendering/RenderPipeline.h | 1 + src/Core/Resources/Material.cpp | 4 ++++ src/Core/Resources/Material.h | 1 + src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl | 3 +++ src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 6 ++++++ 9 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index 9b8629e85..975e1dae8 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -426,6 +426,11 @@ namespace MxEngine return this->renderBuffers->Material; } + TextureHandle CameraController::GetSSRMask()const + { + return this->renderBuffers->SSRMask; + } + TextureHandle CameraController::GetDepthTexture() const { return this->renderBuffers->Depth; @@ -462,6 +467,7 @@ namespace MxEngine this->Albedo = Factory::Create(); this->Normal = Factory::Create(); this->Material = Factory::Create(); + this->SSRMask = Factory::Create(); this->Depth = Factory::Create(); this->AverageWhite = Factory::Create(); this->HDR = Factory::Create(); @@ -474,12 +480,14 @@ namespace MxEngine this->GBuffer->AttachTexture(this->Albedo, Attachment::COLOR_ATTACHMENT0); this->GBuffer->AttachTextureExtra(this->Normal, Attachment::COLOR_ATTACHMENT1); this->GBuffer->AttachTextureExtra(this->Material, Attachment::COLOR_ATTACHMENT2); + this->GBuffer->AttachTextureExtra(this->SSRMask, Attachment::COLOR_ATTACHMENT3); this->GBuffer->AttachTextureExtra(this->Depth, Attachment::DEPTH_ATTACHMENT); std::array attachments = { Attachment::COLOR_ATTACHMENT0, Attachment::COLOR_ATTACHMENT1, Attachment::COLOR_ATTACHMENT2, + Attachment::COLOR_ATTACHMENT3 }; this->GBuffer->UseDrawBuffers(attachments); this->GBuffer->Validate(); @@ -500,6 +508,10 @@ namespace MxEngine this->Material->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera material")); this->Material->SetWrapType(TextureWrap::CLAMP_TO_EDGE); + this->SSRMask->Load(nullptr, width, height, 1, false, TextureFormat::R32F); + this->SSRMask->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("ssr mask")); + this->SSRMask->SetWrapType(TextureWrap::CLAMP_TO_EDGE); + this->Depth->LoadDepth(width, height, TextureFormat::DEPTH32F); this->Depth->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera depth")); this->Depth->SetWrapType(TextureWrap::CLAMP_TO_EDGE); @@ -536,6 +548,7 @@ namespace MxEngine Factory::Destroy(this->Albedo); Factory::Destroy(this->Normal); Factory::Destroy(this->Material); + Factory::Destroy(this->SSRMask); Factory::Destroy(this->Depth); Factory::Destroy(this->HDR); Factory::Destroy(this->SwapHDR1); diff --git a/src/Core/Components/Camera/CameraController.h b/src/Core/Components/Camera/CameraController.h index 15edef324..90ee2a351 100644 --- a/src/Core/Components/Camera/CameraController.h +++ b/src/Core/Components/Camera/CameraController.h @@ -49,6 +49,7 @@ namespace MxEngine TextureHandle Normal; TextureHandle Material; TextureHandle Depth; + TextureHandle SSRMask; MxVector HiZ; TextureHandle AverageWhite; TextureHandle HDR; @@ -131,6 +132,7 @@ namespace MxEngine TextureHandle GetAlbedoTexture() const; TextureHandle GetNormalTexture() const; TextureHandle GetMaterialTexture() const; + TextureHandle GetSSRMask()const; TextureHandle GetDepthTexture() const; MxVector GetHiZ() const; TextureHandle GetAverageWhiteTexture() const; diff --git a/src/Core/Components/Camera/CameraSSR.cpp b/src/Core/Components/Camera/CameraSSR.cpp index 77f49fbf9..8fbcc80fb 100644 --- a/src/Core/Components/Camera/CameraSSR.cpp +++ b/src/Core/Components/Camera/CameraSSR.cpp @@ -50,7 +50,7 @@ namespace MxEngine void CameraSSR::SetIntensity(float intensity) { - this->intensity = Min(intensity,1.0f); + this->intensity = intensity; } MXENGINE_REFLECT_TYPE @@ -63,7 +63,7 @@ namespace MxEngine .property("thickness", &CameraSSR::GetThickness, &CameraSSR::SetThickness) ( rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), - rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 10000.0f }), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1.0f, 100.0f }), rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) ) .property("intensity", &CameraSSR::GetIntensity, &CameraSSR::SetIntensity) diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 924b18076..d685d765e 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -277,6 +277,8 @@ namespace MxEngine shader.SetUniform("parentModel", unit.ModelMatrix); //-V807 shader.SetUniform("parentNormal", unit.NormalMatrix); shader.SetUniform("parentColor", material.BaseColor); + + shader.SetUniform("receiveSSR", material.ReceiveSSR); this->DrawIndices(RenderPrimitive::TRIANGLES, unit.IndexCount, unit.IndexOffset, unit.VertexOffset, instanceCount, baseInstance); } @@ -666,6 +668,8 @@ namespace MxEngine Texture::TextureBindId textureId = 0; this->BindGBuffer(camera, *SSRShader, textureId); this->BindCameraInformation(camera, *SSRShader); + SSRShader->SetUniform("ssrMask", camera.SSRMaskTexture->GetBoundId()); + camera.SSRMaskTexture->Bind(textureId++); this->BindHiZ(camera, *SSRShader, textureId); SSRShader->SetUniform("thickness", camera.SSR->GetThickness()); @@ -1495,6 +1499,7 @@ namespace MxEngine camera.AlbedoTexture = cameraController.GetAlbedoTexture(); camera.NormalTexture = cameraController.GetNormalTexture(); camera.MaterialTexture = cameraController.GetMaterialTexture(); + camera.SSRMaskTexture = cameraController.GetSSRMask(); camera.DepthTexture = cameraController.GetDepthTexture(); camera.HiZ = cameraController.GetHiZ(); camera.AverageWhiteTexture = cameraController.GetAverageWhiteTexture(); diff --git a/src/Core/Rendering/RenderPipeline.h b/src/Core/Rendering/RenderPipeline.h index 46fbecb85..3009b0142 100644 --- a/src/Core/Rendering/RenderPipeline.h +++ b/src/Core/Rendering/RenderPipeline.h @@ -62,6 +62,7 @@ namespace MxEngine TextureHandle NormalTexture; TextureHandle MaterialTexture; TextureHandle DepthTexture; + TextureHandle SSRMaskTexture; MxVector< TextureHandle> HiZ; TextureHandle AverageWhiteTexture; TextureHandle HDRTexture; diff --git a/src/Core/Resources/Material.cpp b/src/Core/Resources/Material.cpp index 2df5459ab..a7b6ebf94 100644 --- a/src/Core/Resources/Material.cpp +++ b/src/Core/Resources/Material.cpp @@ -57,6 +57,10 @@ namespace MxEngine ( rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE) ) + .property("receive SSR", &Material::ReceiveSSR) + ( + rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE) + ) .property("normal map", &Material::NormalMap) ( rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE) diff --git a/src/Core/Resources/Material.h b/src/Core/Resources/Material.h index 00ae21025..ca4e0d88a 100644 --- a/src/Core/Resources/Material.h +++ b/src/Core/Resources/Material.h @@ -59,6 +59,7 @@ namespace MxEngine float RoughnessFactor = 0.75f; float MetallicFactor = 0.0f; + bool ReceiveSSR{ false }; Vector3 BaseColor{ 1.0f }; Vector2 UVMultipliers{ 1.0f }; AlphaModeGroup AlphaMode = AlphaModeGroup::OPAQUE; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl index 4db18764f..edc2adaf3 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl @@ -12,6 +12,7 @@ in VSout layout(location = 0) out vec4 OutAlbedo; layout(location = 1) out vec4 OutNormal; layout(location = 2) out vec4 OutMaterial; +layout(location = 3) out vec4 OutSSRMask; struct Material { @@ -42,6 +43,7 @@ uniform vec2 uvMultipliers; uniform float displacement; uniform float gamma; uniform Camera camera; +uniform bool receiveSSR; vec3 calcNormal(vec2 texcoord, mat3 TBN, sampler2D normalMap) { @@ -76,4 +78,5 @@ void main() OutAlbedo = vec4(fsin.RenderColor * albedo, emmisive / (emmisive + 1.0f)); OutNormal = vec4(0.5f * normal + 0.5f, 1.0f); OutMaterial = vec4(parallaxOcclusion * occlusion, roughness, metallic, 1.0f); + OutSSRMask = vec4(float(receiveSSR),vec3(1.0)); } \ No newline at end of file diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index 601b5ad57..6548e22bd 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -7,6 +7,7 @@ uniform sampler2D albedoTex; uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; +uniform sampler2D ssrMask; uniform sampler2D HDRTex; uniform sampler2D hiZTex0; uniform sampler2D hiZTex1; @@ -64,6 +65,11 @@ void swapComp(inout vec2 v) void main() { + if(texelFetch(ssrMask,ivec2(gl_FragCoord.xy),0).r<0.5) + { + OutColor = vec4(0.0); + return; + } FragmentInfo fragment = getFragmentInfo( TexCoord, albedoTex, normalTex, materialTex, depthTex, camera.invViewProjMatrix); float rayLength = 8000.f; From 64a14339a1b5a505e4d4a898e64f264374cecc9f Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:12:31 +0800 Subject: [PATCH 08/48] Delete samples/Sponza/Engine/Models/cube_2.obj --- samples/Sponza/Engine/Models/cube_2.obj | 91 ------------------------- 1 file changed, 91 deletions(-) delete mode 100644 samples/Sponza/Engine/Models/cube_2.obj diff --git a/samples/Sponza/Engine/Models/cube_2.obj b/samples/Sponza/Engine/Models/cube_2.obj deleted file mode 100644 index a4df721e8..000000000 --- a/samples/Sponza/Engine/Models/cube_2.obj +++ /dev/null @@ -1,91 +0,0 @@ -v -0.5 -0.5 0.5 -v 0.5 -0.5 0.5 -v -0.5 0.5 0.5 -v 0.5 0.5 0.5 -v 0.5 -0.5 -0.5 -v 0.5 0.5 -0.5 -v 0.5 -0.5 0.5 -v 0.5 0.5 0.5 -v 0.5 -0.5 0.5 -v -0.5 -0.5 0.5 -v 0.5 -0.5 -0.5 -v -0.5 -0.5 -0.5 -v -0.5 -0.5 -0.5 -v 0.5 -0.5 -0.5 -v -0.5 0.5 -0.5 -v 0.5 0.5 -0.5 -v 0.5 0.5 0.5 -v -0.5 0.5 0.5 -v 0.5 0.5 -0.5 -v -0.5 0.5 -0.5 -v -0.5 0.5 0.5 -v -0.5 -0.5 0.5 -v -0.5 0.5 -0.5 -v -0.5 -0.5 -0.5 -# total vertex count: 24 - -vt 0 0 -vt 1 0 -vt 0 1 -vt 1 1 -vt 1 0 -vt 1 1 -vt 0 0 -vt 0 1 -vt 1 1 -vt 0 1 -vt 1 0 -vt 0 0 -vt 1 0 -vt 0 0 -vt 1 1 -vt 0 1 -vt 0 1 -vt 1 1 -vt 0 0 -vt 1 0 -vt 1 1 -vt 1 0 -vt 0 1 -vt 0 0 -# total texcoord count: 24 - -vn 0 0 1 -vn 0 0 1 -vn 0 0 1 -vn 0 0 1 -vn 1 0 0 -vn 1 0 0 -vn 1 0 0 -vn 1 0 0 -vn 0 -1 0 -vn 0 -1 0 -vn 0 -1 0 -vn 0 -1 0 -vn 0 0 -1 -vn 0 0 -1 -vn 0 0 -1 -vn 0 0 -1 -vn 0 1 0 -vn 0 1 0 -vn 0 1 0 -vn 0 1 0 -vn -1 0 0 -vn -1 0 0 -vn -1 0 0 -vn -1 0 0 -# total normal count: 24 - -f 1/1/1 2/2/2 3/3/3 -f 2/2/2 4/4/4 3/3/3 -f 5/5/5 6/6/6 7/7/7 -f 6/6/6 8/8/8 7/7/7 -f 9/9/9 10/10/10 11/11/11 -f 10/10/10 12/12/12 11/11/11 -f 13/13/13 15/15/15 14/14/14 -f 14/14/14 15/15/15 16/16/16 -f 17/17/17 19/19/19 18/18/18 -f 18/18/18 19/19/19 20/20/20 -f 21/21/21 23/23/23 22/22/22 -f 22/22/22 23/23/23 24/24/24 -# total index count: 36 From f0739eca5d43a1a0798dddcb72a0800b2bacf7a6 Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:12:43 +0800 Subject: [PATCH 09/48] Delete samples/Sponza/Engine/Models/plane_2.obj --- samples/Sponza/Engine/Models/plane_2.obj | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 samples/Sponza/Engine/Models/plane_2.obj diff --git a/samples/Sponza/Engine/Models/plane_2.obj b/samples/Sponza/Engine/Models/plane_2.obj deleted file mode 100644 index 84162003d..000000000 --- a/samples/Sponza/Engine/Models/plane_2.obj +++ /dev/null @@ -1,21 +0,0 @@ -v -0.5 0 -0.5 -v -0.5 0 0.5 -v 0.5 0 -0.5 -v 0.5 0 0.5 -# total vertex count: 4 - -vt 0 0 -vt 0 1 -vt 1 0 -vt 1 1 -# total texcoord count: 4 - -vn 0 1 0 -vn 0 1 0 -vn 0 1 0 -vn 0 1 0 -# total normal count: 4 - -f 1/1/1 2/2/2 3/3/3 -f 2/2/2 4/4/4 3/3/3 -# total index count: 6 From 37d54d0120f0a4d7d7354fb15196462a8cef0540 Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:13:08 +0800 Subject: [PATCH 10/48] Delete samples/Sponza/Engine/Models/sphere_4.obj --- samples/Sponza/Engine/Models/sphere_4.obj | 106 ---------------------- 1 file changed, 106 deletions(-) delete mode 100644 samples/Sponza/Engine/Models/sphere_4.obj diff --git a/samples/Sponza/Engine/Models/sphere_4.obj b/samples/Sponza/Engine/Models/sphere_4.obj deleted file mode 100644 index 96a7d3680..000000000 --- a/samples/Sponza/Engine/Models/sphere_4.obj +++ /dev/null @@ -1,106 +0,0 @@ -v 0 -0.5 0 -v -0 -0.5 0 -v -0 -0.5 -0 -v 0 -0.5 -0 -v 0 -0.5 0 -v 0.353553 -0.353553 0 -v -1.54543e-08 -0.353553 0.353553 -v -0.353553 -0.353553 -3.09086e-08 -v 4.21608e-09 -0.353553 -0.353553 -v 0.353553 -0.353553 6.18172e-08 -v 0.5 2.18557e-08 0 -v -2.18557e-08 2.18557e-08 0.5 -v -0.5 2.18557e-08 -4.37114e-08 -v 5.96244e-09 2.18557e-08 -0.5 -v 0.5 2.18557e-08 8.74228e-08 -v 0.353553 0.353553 0 -v -1.54543e-08 0.353553 0.353553 -v -0.353553 0.353553 -3.09086e-08 -v 4.21608e-09 0.353553 -0.353553 -v 0.353553 0.353553 6.18172e-08 -v -4.37114e-08 0.5 -0 -v 1.91069e-15 0.5 -4.37114e-08 -v 4.37114e-08 0.5 3.82137e-15 -v -5.21253e-16 0.5 4.37114e-08 -v -4.37114e-08 0.5 -7.64274e-15 -# total vertex count: 25 - -vt 1 0 -vt 0.75 0 -vt 0.5 0 -vt 0.25 0 -vt 0 0 -vt 1 0.25 -vt 0.75 0.25 -vt 0.5 0.25 -vt 0.25 0.25 -vt 0 0.25 -vt 1 0.5 -vt 0.75 0.5 -vt 0.5 0.5 -vt 0.25 0.5 -vt 0 0.5 -vt 1 0.75 -vt 0.75 0.75 -vt 0.5 0.75 -vt 0.25 0.75 -vt 0 0.75 -vt 1 1 -vt 0.75 1 -vt 0.5 1 -vt 0.25 1 -vt 0 1 -# total texcoord count: 25 - -vn 0 -1 0 -vn -0 -1 0 -vn -0 -1 -0 -vn 0 -1 -0 -vn 0 -1 0 -vn 0.707107 -0.707107 0 -vn -3.09086e-08 -0.707107 0.707107 -vn -0.707107 -0.707107 -6.18172e-08 -vn 8.43216e-09 -0.707107 -0.707107 -vn 0.707107 -0.707107 1.23634e-07 -vn 1 4.37114e-08 0 -vn -4.37114e-08 4.37114e-08 1 -vn -1 4.37114e-08 -8.74228e-08 -vn 1.19249e-08 4.37114e-08 -1 -vn 1 4.37114e-08 1.74846e-07 -vn 0.707107 0.707107 0 -vn -3.09086e-08 0.707107 0.707107 -vn -0.707107 0.707107 -6.18172e-08 -vn 8.43216e-09 0.707107 -0.707107 -vn 0.707107 0.707107 1.23634e-07 -vn -8.74228e-08 1 -0 -vn 3.82137e-15 1 -8.74228e-08 -vn 8.74228e-08 1 7.64274e-15 -vn -1.04251e-15 1 8.74228e-08 -vn -8.74228e-08 1 -1.52855e-14 -# total normal count: 25 - -f 2/2/2 6/6/6 7/7/7 -f 3/3/3 7/7/7 8/8/8 -f 4/4/4 8/8/8 9/9/9 -f 5/5/5 9/9/9 10/10/10 -f 6/6/6 11/11/11 7/7/7 -f 7/7/7 11/11/11 12/12/12 -f 7/7/7 12/12/12 8/8/8 -f 8/8/8 12/12/12 13/13/13 -f 8/8/8 13/13/13 9/9/9 -f 9/9/9 13/13/13 14/14/14 -f 9/9/9 14/14/14 10/10/10 -f 10/10/10 14/14/14 15/15/15 -f 11/11/11 16/16/16 12/12/12 -f 12/12/12 16/16/16 17/17/17 -f 12/12/12 17/17/17 13/13/13 -f 13/13/13 17/17/17 18/18/18 -f 13/13/13 18/18/18 14/14/14 -f 14/14/14 18/18/18 19/19/19 -f 14/14/14 19/19/19 15/15/15 -f 15/15/15 19/19/19 20/20/20 -f 16/16/16 21/21/21 17/17/17 -f 17/17/17 22/22/22 18/18/18 -f 18/18/18 23/23/23 19/19/19 -f 19/19/19 24/24/24 20/20/20 -# total index count: 72 From abda4e1980edeb3e9c8a1514f338a89198c2d4df Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:13:38 +0800 Subject: [PATCH 11/48] Delete samples/Sponza/sponza2.json --- samples/Sponza/sponza2.json | 3755 ----------------------------------- 1 file changed, 3755 deletions(-) delete mode 100644 samples/Sponza/sponza2.json diff --git a/samples/Sponza/sponza2.json b/samples/Sponza/sponza2.json deleted file mode 100644 index cd2a87b68..000000000 --- a/samples/Sponza/sponza2.json +++ /dev/null @@ -1,3755 +0,0 @@ -{ - "AudioBuffer": null, - "CubeMap": [ - { - "_filepath": "Resources/skybox.png", - "id": 2 - }, - { - "_filepath": "Resources/skybox_irradiance.png", - "id": 3 - } - ], - "Material": [ - { - "albedo map": 102, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 1.0, - 1.0, - 1.0 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 0, - "metallic factor": 0.0, - "metallic map": 18446744073709551615, - "name": "DefaultMaterial", - "normal map": 18446744073709551615, - "roughness factor": 0.75, - "roughness map": 18446744073709551615, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 18446744073709551615, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 1.0, - 1.0, - 1.0 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 1, - "metallic factor": 1.0, - "metallic map": 18446744073709551615, - "name": "DefaultMaterial", - "normal map": 18446744073709551615, - "roughness factor": 1.0, - "roughness map": 18446744073709551615, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 14, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 2, - "metallic factor": 1.0, - "metallic map": 12, - "name": "DefaultMaterial", - "normal map": 24, - "roughness factor": 1.0, - "roughness map": 17, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 21, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 3, - "metallic factor": 1.0, - "metallic map": 18446744073709551615, - "name": "Lion Head", - "normal map": 27, - "roughness factor": 0.0, - "roughness map": 18446744073709551615, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 23, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 4, - "metallic factor": 1.0, - "metallic map": 18, - "name": "DefaultMaterial", - "normal map": 31, - "roughness factor": 1.0, - "roughness map": 13, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 26, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 5, - "metallic factor": 1.0, - "metallic map": 15, - "name": "DefaultMaterial", - "normal map": 34, - "roughness factor": 1.0, - "roughness map": 16, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 30, - "alpha mode": "MASKED", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 6, - "metallic factor": 1.0, - "metallic map": 19, - "name": "DefaultMaterial", - "normal map": 29, - "roughness factor": 1.0, - "roughness map": 20, - "transparency": 0.5, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 32, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 7, - "metallic factor": 1.0, - "metallic map": 28, - "name": "DefaultMaterial", - "normal map": 25, - "roughness factor": 1.0, - "roughness map": 22, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 41, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 8, - "metallic factor": 1.0, - "metallic map": 36, - "name": "DefaultMaterial", - "normal map": 35, - "roughness factor": 1.0, - "roughness map": 38, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 44, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 9, - "metallic factor": 1.0, - "metallic map": 40, - "name": "DefaultMaterial", - "normal map": 39, - "roughness factor": 1.0, - "roughness map": 33, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 45, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 10, - "metallic factor": 1.0, - "metallic map": 43, - "name": "DefaultMaterial", - "normal map": 42, - "roughness factor": 1.0, - "roughness map": 37, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 46, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 11, - "metallic factor": 1.0, - "metallic map": 48, - "name": "DefaultMaterial", - "normal map": 47, - "roughness factor": 1.0, - "roughness map": 49, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 50, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 12, - "metallic factor": 1.0, - "metallic map": 52, - "name": "DefaultMaterial", - "normal map": 51, - "roughness factor": 1.0, - "roughness map": 53, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 54, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 13, - "metallic factor": 1.0, - "metallic map": 56, - "name": "DefaultMaterial", - "normal map": 55, - "roughness factor": 1.0, - "roughness map": 57, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 61, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 14, - "metallic factor": 0.0, - "metallic map": 18446744073709551615, - "name": "DefaultMaterial", - "normal map": 18446744073709551615, - "roughness factor": 1.0, - "roughness map": 18446744073709551615, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 58, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 15, - "metallic factor": 1.0, - "metallic map": 70, - "name": "DefaultMaterial", - "normal map": 59, - "roughness factor": 1.0, - "roughness map": 60, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 63, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 16, - "metallic factor": 1.0, - "metallic map": 75, - "name": "DefaultMaterial", - "normal map": 64, - "roughness factor": 1.0, - "roughness map": 65, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 67, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 17, - "metallic factor": 1.0, - "metallic map": 79, - "name": "DefaultMaterial", - "normal map": 68, - "roughness factor": 1.0, - "roughness map": 62, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 74, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 18, - "metallic factor": 0.25, - "metallic map": 18446744073709551615, - "name": "Floor", - "normal map": 82, - "roughness factor": 1.0, - "roughness map": 66, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 78, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 19, - "metallic factor": 1.0, - "metallic map": 71, - "name": "DefaultMaterial", - "normal map": 80, - "roughness factor": 1.0, - "roughness map": 72, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 83, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 20, - "metallic factor": 1.0, - "metallic map": 76, - "name": "DefaultMaterial", - "normal map": 77, - "roughness factor": 1.0, - "roughness map": 69, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 95, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 21, - "metallic factor": 1.0, - "metallic map": 73, - "name": "DefaultMaterial", - "normal map": 87, - "roughness factor": 1.0, - "roughness map": 81, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 90, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 22, - "metallic factor": 1.0, - "metallic map": 85, - "name": "DefaultMaterial", - "normal map": 11, - "roughness factor": 1.0, - "roughness map": 86, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 94, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 23, - "metallic factor": 1.0, - "metallic map": 18446744073709551615, - "name": "Lion Head", - "normal map": 10, - "roughness factor": 0.0, - "roughness map": 18446744073709551615, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 98, - "alpha mode": "OPAQUE", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 24, - "metallic factor": 1.0, - "metallic map": 91, - "name": "DefaultMaterial", - "normal map": 100, - "roughness factor": 1.0, - "roughness map": 84, - "transparency": 1.0, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 99, - "alpha mode": "MASKED", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.02500000037252903, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 25, - "metallic factor": 1.0, - "metallic map": 93, - "name": "DefaultMaterial", - "normal map": 92, - "roughness factor": 1.0, - "roughness map": 101, - "transparency": 0.5, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 96, - "alpha mode": "MASKED", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 0.5879999995231628, - 0.5879999995231628, - 0.5879999995231628 - ], - "displacement": 0.0, - "emission": 0.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 26, - "metallic factor": 1.0, - "metallic map": 89, - "name": "DefaultMaterial", - "normal map": 88, - "roughness factor": 0.0, - "roughness map": 97, - "transparency": 0.5, - "uv multipliers": [ - 1.0, - 1.0 - ] - }, - { - "albedo map": 103, - "alpha mode": "TRANSPARENT", - "ambient occlusion map": 18446744073709551615, - "base color": [ - 1.0, - 0.9999899864196777, - 0.9999899864196777 - ], - "displacement": 0.02500000037252903, - "emission": 10.0, - "emissive map": 18446744073709551615, - "height map": 18446744073709551615, - "id": 27, - "metallic factor": 1.0, - "metallic map": 18446744073709551615, - "name": "DefaultMaterial", - "normal map": 18446744073709551615, - "roughness factor": 1.0, - "roughness map": 18446744073709551615, - "transparency": 0.20000000298023224, - "uv multipliers": [ - 1.0, - 1.0 - ] - } - ], - "Mesh": [ - { - "_filepath": "Engine/Models/pyramid_1.obj", - "aabb": { - "max": [ - 1.0, - 1.0, - 1.0 - ], - "min": [ - -1.0, - -1.0, - 0.0 - ] - }, - "bounding sphere": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "radius": 2.0 - }, - "id": 0 - }, - { - "_filepath": "Engine/Models/sphere_8.obj", - "aabb": { - "max": [ - 0.5, - 0.5, - 0.5 - ], - "min": [ - -0.5, - -0.5, - -0.5 - ] - }, - "bounding sphere": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "radius": 0.5 - }, - "id": 1 - }, - { - "_filepath": "Engine/Models/pyramid_1.obj", - "aabb": { - "max": [ - 1.0, - 1.0, - 1.0 - ], - "min": [ - -1.0, - -1.0, - 0.0 - ] - }, - "bounding sphere": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "radius": 2.0 - }, - "id": 2 - }, - { - "_filepath": "Engine/Models/sphere_8.obj", - "aabb": { - "max": [ - 0.5, - 0.5, - 0.5 - ], - "min": [ - -0.5, - -0.5, - -0.5 - ] - }, - "bounding sphere": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "radius": 0.5 - }, - "id": 3 - }, - { - "_filepath": "Engine/Models/sphere_20.obj", - "aabb": { - "max": [ - 0.5, - 0.5, - 0.5 - ], - "min": [ - -0.5, - -0.5, - -0.5 - ] - }, - "bounding sphere": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "radius": 0.5000000596046448 - }, - "id": 8 - }, - { - "_filepath": "Resources/Sponza/glTF/Sponza.gltf", - "aabb": { - "max": [ - 1860.427001953125, - 777.9378662109375, - 1144.1165771484375 - ], - "min": [ - -1860.427001953125, - -777.9378662109375, - -1144.1165771484375 - ] - }, - "bounding sphere": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "radius": 2887.561767578125 - }, - "id": 9 - } - ], - "Script": [ - { - "filepath": "Resources/ShootSpheres.cpp", - "name": "ShootSpheres" - } - ], - "Texture": [ - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/13982482287905699490.jpg" - }, - "id": 10, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/16299174074766089871.jpg" - }, - "id": 11, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_24.png" - }, - "id": 12, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_22.png" - }, - "id": 13, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/2969916736137545357.jpg" - }, - "id": 14, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_21.png" - }, - "id": 15, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_21.png" - }, - "id": 16, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_24.png" - }, - "id": 17, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_22.png" - }, - "id": 18, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_20.png" - }, - "id": 19, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_20.png" - }, - "id": 20, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/6772804448157695701.jpg" - }, - "id": 21, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_19.png" - }, - "id": 22, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/8481240838833932244.jpg" - }, - "id": 23, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/14118779221266351425.jpg" - }, - "id": 24, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/4910669866631290573.jpg" - }, - "id": 25, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/755318871556304029.jpg" - }, - "id": 26, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/759203620573749278.jpg" - }, - "id": 27, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_19.png" - }, - "id": 28, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/14170708867020035030.jpg" - }, - "id": 29, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/16275776544635328252.png" - }, - "id": 30, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/10381718147657362067.jpg" - }, - "id": 31, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/9288698199695299068.jpg" - }, - "id": 32, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_17.png" - }, - "id": 33, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/3827035219084910048.jpg" - }, - "id": 34, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/4601176305987539675.jpg" - }, - "id": 35, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_18.png" - }, - "id": 36, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_16.png" - }, - "id": 37, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_18.png" - }, - "id": 38, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/6593109234861095314.jpg" - }, - "id": 39, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_17.png" - }, - "id": 40, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/11474523244911310074.jpg" - }, - "id": 41, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/332936164838540657.jpg" - }, - "id": 42, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_16.png" - }, - "id": 43, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/17876391417123941155.jpg" - }, - "id": 44, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/2185409758123873465.jpg" - }, - "id": 45, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/2775690330959970771.jpg" - }, - "id": 46, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/2374361008830720677.jpg" - }, - "id": 47, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_15.png" - }, - "id": 48, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_15.png" - }, - "id": 49, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/4675343432951571524.jpg" - }, - "id": 50, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/7056944414013900257.jpg" - }, - "id": 51, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_14.png" - }, - "id": 52, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_14.png" - }, - "id": 53, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/4975155472559461469.jpg" - }, - "id": 54, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/2299742237651021498.jpg" - }, - "id": 55, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_13.png" - }, - "id": 56, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_13.png" - }, - "id": 57, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/6151467286084645207.jpg" - }, - "id": 58, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/7645212358685992005.jpg" - }, - "id": 59, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_11.png" - }, - "id": 60, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/white.png" - }, - "id": 61, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_9.png" - }, - "id": 62, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/11490520546946913238.jpg" - }, - "id": 63, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/3628158980083700836.jpg" - }, - "id": 64, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_10.png" - }, - "id": 65, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_8.png" - }, - "id": 66, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/7441062115984513793.jpg" - }, - "id": 67, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/6667038893015345571.jpg" - }, - "id": 68, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_6.png" - }, - "id": 69, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_11.png" - }, - "id": 70, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_7.png" - }, - "id": 71, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_7.png" - }, - "id": 72, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_5.png" - }, - "id": 73, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/5823059166183034438.jpg" - }, - "id": 74, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_10.png" - }, - "id": 75, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_6.png" - }, - "id": 76, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/10388182081421875623.jpg" - }, - "id": 77, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/6047387724914829168.jpg" - }, - "id": 78, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_9.png" - }, - "id": 79, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/15722799267630235092.jpg" - }, - "id": 80, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_5.png" - }, - "id": 81, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/14267839433702832875.jpg" - }, - "id": 82, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/15295713303328085182.jpg" - }, - "id": 83, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_2.png" - }, - "id": 84, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_4.png" - }, - "id": 85, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_4.png" - }, - "id": 86, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/2051777328469649772.jpg" - }, - "id": 87, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/8773302468495022225.jpg" - }, - "id": 88, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_0.png" - }, - "id": 89, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/5792855332885324923.jpg" - }, - "id": 90, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_2.png" - }, - "id": 91, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/12501374198249454378.jpg" - }, - "id": 92, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/metallic_1.png" - }, - "id": 93, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/8750083169368950601.jpg" - }, - "id": 94, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/14650633544276105767.jpg" - }, - "id": 95, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/5061699253647017043.png" - }, - "id": 96, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_0.png" - }, - "id": 97, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/7268504077753552595.jpg" - }, - "id": 98, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/Sponza/glTF/8006627369776289000.png" - }, - "id": 99, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RG", - "path": "Resources/Sponza/glTF/4477655471536070370.jpg" - }, - "id": 100, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "R", - "path": "Resources/Sponza/glTF/roughness_1.png" - }, - "id": 101, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGB", - "path": "Resources/moon.jpg" - }, - "id": 102, - "wrap type": "REPEAT" - }, - { - "border color": [ - 0.0, - 0.0, - 0.0, - 0.0 - ], - "filepath": { - "format": "RGBA", - "path": "Resources/fire.png" - }, - "id": 103, - "wrap type": "REPEAT" - } - ], - "globals": { - "gravity": [ - 0.0, - -9.800000190734863, - 0.0 - ], - "overlay-debug": false, - "paused": false, - "physics-step": 1.0, - "time-scale": 1.0, - "total-time": 5737.36962890625, - "viewport": 0 - }, - "mxobjects": [ - { - "CameraController": { - "camera type": "PERSPECTIVE", - "direction": [ - 0.7886037826538086, - -0.18925577402114868, - 0.5850524306297302 - ], - "forward vector": [ - 0.8031178712844849, - 0.0, - 0.5958201885223389 - ], - "id": 0, - "is listening window resize event": true, - "is rendering": true, - "perspective camera": { - "aspect ratio": 1.7777777910232544, - "fov": 65.0, - "zfar": 100000.0, - "znear": 0.10000000149011612 - }, - "right vector": [ - -0.5958201885223389, - 0.0, - 0.8031178712844849 - ], - "up vector": [ - 0.0, - 1.0, - 0.0 - ] - }, - "CameraEffects": { - "bloom iterations": 3, - "bloom weight": 0.5, - "chromatic aberration distortion": 0.800000011920929, - "chromatic aberration intensity": 0.07999999821186066, - "chromatic aberration min distance": 0.800000011920929, - "dof bokeh radius": 10.0, - "dof focus distance": 0.0, - "dof focus range": 5.0, - "fog color": [ - 0.5, - 0.6000000238418579, - 0.699999988079071 - ], - "fog density": 0.0, - "fog distance": 1.0, - "fxaa": false, - "id": 0, - "vignette radius": 0.10000000149011612 - }, - "CameraSSAO": { - "blur iterations": 1, - "blur lod": 2, - "id": 0, - "intensity": 3.1500000953674316, - "radius": 1.0, - "sample count": 4 - }, - "CameraSSR": { - "id": 0, - "start distance": 2.0, - "steps": 10, - "thickness": 0.5 - }, - "CameraToneMapping": { - "aces coefficients": { - "a": 0.25, - "b": 0.3059999942779541, - "c": 0.0989999994635582, - "d": 0.3499999940395355, - "e": 0.02500000037252903, - "f": 0.4000000059604645 - }, - "color grading": { - "B": [ - 0.0, - 0.0, - 1.0 - ], - "G": [ - 0.0, - 1.0, - 0.0 - ], - "R": [ - 1.0, - 0.0, - 0.0 - ] - }, - "color scale": 1.0, - "exposure": 1.0, - "eye adaptation speed": 1.0, - "eye adaptation threshold": 0.10000000149011612, - "gamma": 2.200000047683716, - "id": 0, - "max luminance": 100000.0, - "min luminance": 0.30000001192092896, - "white point": 0.5 - }, - "CapsuleCollider": { - "bounding capsule": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "height": 4.5, - "orientation": "Y", - "radius": 0.75, - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "id": 0 - }, - "CharacterController": { - "id": 0, - "jump power": 12.0, - "jump speed": 10.0 - }, - "InputController": { - "back key binding": "S", - "down key binding": "LEFT_SHIFT", - "forward key binding": "W", - "id": 0, - "is horizontal rotation bound": true, - "is vertical rotation bound": true, - "left key binding": "A", - "move speed": 10.0, - "right key binding": "D", - "rotate speed": 10.0, - "up key binding": "SPACE", - "use camera style movement": true - }, - "RigidBody": { - "angular air resistance": 0.0, - "angular force factor": [ - 0.0, - 0.0, - 0.0 - ], - "angular velocity": [ - 0.0, - 0.0, - 0.0 - ], - "anisotropic friction": [ - 1.0, - 1.0, - 1.0 - ], - "bounce factor": 0.0, - "friction": 0.0, - "gravity": [ - 0.0, - -9.800000190734863, - 0.0 - ], - "has anisotropic friction": false, - "id": 0, - "is ray castable": true, - "is trigger": false, - "linear air resistance": 0.0, - "linear force factor": [ - 1.0, - 1.0, - 1.0 - ], - "linear velocity": [ - -4.694485937761783e-07, - 2.86102294921875e-06, - 1.1736214844404458e-07 - ], - "mass": 1.0, - "push velocity": [ - 0.0, - 0.0, - 0.0 - ], - "rolling friction": 0.0, - "spinning friction": 0.0, - "turn velocity": [ - 0.0, - 0.0, - 0.0 - ], - "type": "DYNAMIC" - }, - "Script": { - "_name": "ShootSpheres", - "database": { - "_database": null - }, - "id": 0 - }, - "Skybox": { - "cubemap": 2, - "id": 0, - "intensity": 0.0, - "irradiance": 3, - "rotation": [ - 0.0, - 0.0, - 0.0 - ] - }, - "displayed": true, - "name": "Camera", - "transform": { - "position": [ - -21.208274841308594, - 2.999999761581421, - -2.669466972351074 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "InstanceFactory": { - "id": 0, - "instances": null, - "is static": false - }, - "MeshRenderer": { - "id": 0, - "materials": [ - 0 - ] - }, - "MeshSource": { - "casts shadow": true, - "id": 0, - "is drawn": true, - "is static": false, - "mesh": 8 - }, - "displayed": true, - "name": "Sphere Factory", - "transform": { - "position": [ - 0.0, - 0.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "CompoundCollider": { - "children": [ - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 1800.0, - 75.0, - 1075.0 - ], - "min": [ - -1800.0, - -75.0, - -1075.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 0.0, - -725.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 1800.0, - 750.0, - 250.0 - ], - "min": [ - -1800.0, - -750.0, - -250.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 0.0, - 0.0, - 850.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 1800.0, - 750.0, - 250.0 - ], - "min": [ - -1800.0, - -750.0, - -250.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 0.0, - 0.0, - -850.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 250.0, - 750.0, - 1075.0 - ], - "min": [ - -250.0, - -750.0, - -1075.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 1600.0, - 0.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 250.0, - 750.0, - 1075.0 - ], - "min": [ - -250.0, - -750.0, - -1075.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - -1600.0, - 0.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "height": 100.0, - "orientation": "Y", - "radius x": 75.0, - "radius z": 75.0, - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "Cylinder" - }, - "transform": { - "position": [ - 1180.0, - -600.0, - 440.0000305175781 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "height": 100.0, - "orientation": "Y", - "radius x": 75.0, - "radius z": 75.0, - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "Cylinder" - }, - "transform": { - "position": [ - 1180.0, - -600.0, - -410.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "height": 100.0, - "orientation": "Y", - "radius x": 75.0, - "radius z": 75.0, - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "Cylinder" - }, - "transform": { - "position": [ - -1140.0, - -600.0, - 440.0000305175781 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "height": 100.0, - "orientation": "Y", - "radius x": 75.0, - "radius z": 75.0, - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "Cylinder" - }, - "transform": { - "position": [ - -1140.0, - -600.0, - -410.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 980.0000610351563, - 300.0, - 40.0 - ], - "min": [ - -980.0000610351563, - -300.0, - -40.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 0.0, - -425.0, - -225.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 980.0000610351563, - 300.0, - 40.0 - ], - "min": [ - -980.0000610351563, - -300.0, - -40.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 0.0, - -425.0, - 225.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 40.0, - 50.0, - 265.0 - ], - "min": [ - -40.0, - -50.0, - -265.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 950.0, - -175.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 40.0, - 50.0, - 265.0 - ], - "min": [ - -40.0, - -50.0, - -265.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - -950.0, - -175.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 1800.0, - 10.0, - 250.0 - ], - "min": [ - -1800.0, - -10.0, - -250.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 0.0, - -235.0, - 450.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 1800.0, - 10.0, - 250.0 - ], - "min": [ - -1800.0, - -10.0, - -250.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 0.0, - -235.0, - -450.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 250.0, - 10.0, - 1075.0 - ], - "min": [ - -250.0, - -10.0, - -1075.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 1175.0, - -235.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 250.0, - 10.0, - 1075.0 - ], - "min": [ - -250.0, - -10.0, - -1075.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - -1175.0, - -235.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 1800.0, - 250.0, - 250.0 - ], - "min": [ - -1800.0, - -250.0, - -250.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 0.0, - 500.0, - 450.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 1800.0, - 250.0, - 250.0 - ], - "min": [ - -1800.0, - -250.0, - -250.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 0.0, - 500.0, - -450.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 250.0, - 250.0, - 1075.0 - ], - "min": [ - -250.0, - -250.0, - -1075.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - 1175.0, - 500.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - }, - { - "shape": { - "bounding": { - "center": [ - 0.0, - 0.0, - 0.0 - ], - "max": [ - 250.0, - 250.0, - 1075.0 - ], - "min": [ - -250.0, - -250.0, - -1075.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "type": "BoundingBox" - }, - "transform": { - "position": [ - -1175.0, - 500.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 1.0, - 1.0, - 1.0 - ] - } - } - ], - "id": 0 - }, - "MeshRenderer": { - "id": 1, - "materials": [ - 26, - 25, - 24, - 23, - 22, - 21, - 20, - 19, - 18, - 17, - 16, - 15, - 14, - 13, - 12, - 11, - 10, - 9, - 8, - 7, - 6, - 5, - 4, - 3, - 2, - 1 - ] - }, - "MeshSource": { - "casts shadow": true, - "id": 1, - "is drawn": true, - "is static": false, - "mesh": 9 - }, - "RigidBody": { - "angular air resistance": 0.0, - "angular force factor": [ - 1.0, - 1.0, - 1.0 - ], - "angular velocity": [ - 0.0, - 0.0, - 0.0 - ], - "anisotropic friction": [ - 1.0, - 1.0, - 1.0 - ], - "bounce factor": 0.10000000149011612, - "friction": 0.5, - "gravity": [ - 0.0, - 0.0, - 0.0 - ], - "has anisotropic friction": false, - "id": 1, - "is ray castable": true, - "is trigger": false, - "linear air resistance": 0.0, - "linear force factor": [ - 1.0, - 1.0, - 1.0 - ], - "linear velocity": [ - 0.0, - 0.0, - 0.0 - ], - "mass": 0.0, - "push velocity": [ - 0.0, - 0.0, - 0.0 - ], - "rolling friction": 0.0, - "spinning friction": 0.0, - "turn velocity": [ - 0.0, - 0.0, - 0.0 - ], - "type": "STATIC" - }, - "displayed": true, - "name": "Sponza", - "transform": { - "position": [ - 0.0, - 13.0, - 0.0 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 0.019999999552965164, - 0.019999999552965164, - 0.019999999552965164 - ] - } - }, - { - "MeshRenderer": { - "id": 2, - "materials": [ - 27 - ] - }, - "ParticleSystem": { - "fading": 1.5, - "id": 0, - "is relative": true, - "max initial time alive": 1.0, - "max particle count": 128, - "max particle size": 0.15000000596046448, - "max spawn distance": 0.0, - "min particle size": 0.05000000074505806, - "min spawn distance": 0.0, - "particle angular speed": 0.0, - "particle lifetime": 1.0, - "particle speed": 0.800000011920929, - "shape": "HEMISPHERE" - }, - "PointLight": { - "ambient intensity": 0.10000000149011612, - "casts shadows": false, - "color": [ - 1.0, - 0.6764705777168274, - 0.0 - ], - "id": 0, - "intensity": 100.0, - "radius": 5.0 - }, - "displayed": true, - "name": "Fire 1", - "transform": { - "position": [ - -11.17866039276123, - 2.3849868774414063, - 3.6654486656188965 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 0.30000001192092896, - 1.25, - 0.30000001192092896 - ] - } - }, - { - "MeshRenderer": { - "id": 3, - "materials": [ - 27 - ] - }, - "ParticleSystem": { - "fading": 1.5, - "id": 1, - "is relative": true, - "max initial time alive": 1.0, - "max particle count": 128, - "max particle size": 0.15000000596046448, - "max spawn distance": 0.0, - "min particle size": 0.05000000074505806, - "min spawn distance": 0.0, - "particle angular speed": 0.0, - "particle lifetime": 1.0, - "particle speed": 0.800000011920929, - "shape": "HEMISPHERE" - }, - "PointLight": { - "ambient intensity": 0.10000000149011612, - "casts shadows": false, - "color": [ - 1.0, - 0.6764705777168274, - 0.0 - ], - "id": 1, - "intensity": 100.0, - "radius": 5.0 - }, - "displayed": true, - "name": "Fire 2", - "transform": { - "position": [ - 10.98430061340332, - 2.3849868774414063, - 3.6654486656188965 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 0.30000001192092896, - 1.25, - 0.30000001192092896 - ] - } - }, - { - "MeshRenderer": { - "id": 4, - "materials": [ - 27 - ] - }, - "ParticleSystem": { - "fading": 1.5, - "id": 2, - "is relative": true, - "max initial time alive": 1.0, - "max particle count": 128, - "max particle size": 0.15000000596046448, - "max spawn distance": 0.0, - "min particle size": 0.05000000074505806, - "min spawn distance": 0.0, - "particle angular speed": 0.0, - "particle lifetime": 1.0, - "particle speed": 0.800000011920929, - "shape": "HEMISPHERE" - }, - "PointLight": { - "ambient intensity": 0.10000000149011612, - "casts shadows": false, - "color": [ - 1.0, - 0.6764705777168274, - 0.0 - ], - "id": 2, - "intensity": 100.0, - "radius": 5.0 - }, - "displayed": true, - "name": "Fire 3", - "transform": { - "position": [ - -11.17866039276123, - 2.3849868774414063, - -3.6654486656188965 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 0.30000001192092896, - 1.25, - 0.30000001192092896 - ] - } - }, - { - "MeshRenderer": { - "id": 5, - "materials": [ - 27 - ] - }, - "ParticleSystem": { - "fading": 1.5, - "id": 3, - "is relative": true, - "max initial time alive": 1.0, - "max particle count": 128, - "max particle size": 0.15000000596046448, - "max spawn distance": 0.0, - "min particle size": 0.05000000074505806, - "min spawn distance": 0.0, - "particle angular speed": 0.0, - "particle lifetime": 1.0, - "particle speed": 0.800000011920929, - "shape": "HEMISPHERE" - }, - "PointLight": { - "ambient intensity": 0.10000000149011612, - "casts shadows": false, - "color": [ - 1.0, - 0.6764705777168274, - 0.0 - ], - "id": 3, - "intensity": 100.0, - "radius": 5.0 - }, - "displayed": true, - "name": "Fire 4", - "transform": { - "position": [ - 10.948619842529297, - 2.3849868774414063, - -3.6654486656188965 - ], - "rotation": [ - 0.0, - 0.0, - 0.0 - ], - "scale": [ - 0.30000001192092896, - 1.25, - 0.30000001192092896 - ] - } - } - ] -} \ No newline at end of file From f6486723a1b8c923325ae5635780ddf7de6f1842 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:22:11 +0800 Subject: [PATCH 12/48] edit user input and MD --- README.md | 5 ++--- samples/Sponza/MxApplication.cpp | 2 +- src/Core/Components/Camera/CameraSSR.cpp | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 96d15eafc..22de73638 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ MxEngine is an educational modern-C++ general-purpose 3D game engine. -Right now MxEngine is developed only by me, [#Momo](https://github.com/MomoDeve), but any contributions are welcome and will be reviewed. +Right now MxEngine is developed only by me, [#Momo](https://github.com/MomoDeve) and [#Lucas](https://github.com/fall2019) contributing some features from time to time. Any contributions are welcome and will be reviewed. Fow now MxEngine supports OpenGL as graphic API and targets x64 only. I develop the project in my free time, so updates may be not so frequent! ***Note:** MxEngine is currently being ported to new Vulkan rendering backend. Development progress of the rendering library can be found here: [VulkanAbstractionLayer](https://github.com/asc-community/VulkanAbstractionLayer)* @@ -292,9 +292,8 @@ If you are interesed in libraries MxEngine depend on, consider reading [dependen shadow casting from dynamic lights, screen-space reflections

-## Special thanks -#### God Ray Effect by [#Fall2019](https://github.com/fall2019) +god ray effect

## Projects based on MxEngine diff --git a/samples/Sponza/MxApplication.cpp b/samples/Sponza/MxApplication.cpp index 688929b24..dad31a9c8 100644 --- a/samples/Sponza/MxApplication.cpp +++ b/samples/Sponza/MxApplication.cpp @@ -8,7 +8,7 @@ namespace Sponza { virtual void OnCreate() { - Scene::Load("sponza2.json"_id); + Scene::Load("sponza.json"_id); } }; } diff --git a/src/Core/Components/Camera/CameraSSR.cpp b/src/Core/Components/Camera/CameraSSR.cpp index 8fbcc80fb..dc9d085fd 100644 --- a/src/Core/Components/Camera/CameraSSR.cpp +++ b/src/Core/Components/Camera/CameraSSR.cpp @@ -69,7 +69,7 @@ namespace MxEngine .property("intensity", &CameraSSR::GetIntensity, &CameraSSR::SetIntensity) ( rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), - rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1.0f, 10.0f }), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1.0f, 50.0f }), rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) ); } From bb77182c560525ef9963c3033781e31fd2a26130 Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:28:13 +0800 Subject: [PATCH 13/48] Update MxApplication.cpp --- samples/Sponza/MxApplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Sponza/MxApplication.cpp b/samples/Sponza/MxApplication.cpp index dad31a9c8..9d3c2d75d 100644 --- a/samples/Sponza/MxApplication.cpp +++ b/samples/Sponza/MxApplication.cpp @@ -19,4 +19,4 @@ int main() Sponza::SponzaApplication app; app.Run(); return 0; -} \ No newline at end of file +} From 880399d7aa33b6de3ce86b0cebae13b5a4f29ffc Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:29:10 +0800 Subject: [PATCH 14/48] Update MxApplication.cpp From e69efabe6f50d550acdd4b0b6121327b5ded1d86 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:31:05 +0800 Subject: [PATCH 15/48] Update MxApplication.cpp --- samples/Sponza/MxApplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Sponza/MxApplication.cpp b/samples/Sponza/MxApplication.cpp index 9d3c2d75d..29b243a66 100644 --- a/samples/Sponza/MxApplication.cpp +++ b/samples/Sponza/MxApplication.cpp @@ -19,4 +19,4 @@ int main() Sponza::SponzaApplication app; app.Run(); return 0; -} +} \ No newline at end of file From 4dc13a5cbd2ca8c1d200506483f12da6a173dcb9 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:33:06 +0800 Subject: [PATCH 16/48] Update ShaderBase.cpp --- src/Platform/OpenGL/ShaderBase.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Platform/OpenGL/ShaderBase.cpp b/src/Platform/OpenGL/ShaderBase.cpp index 2669ad1d3..a7be57005 100644 --- a/src/Platform/OpenGL/ShaderBase.cpp +++ b/src/Platform/OpenGL/ShaderBase.cpp @@ -55,7 +55,7 @@ namespace MxEngine cache[uniformName] = location; return location; } - + ShaderBase::UniformIdType ShaderBase::UniformCache::GetUniformLocationSilent(const char* uniformName) { auto it = cache.find_as(uniformName); @@ -136,7 +136,7 @@ namespace MxEngine } GLCALL(glLinkProgram(program)); - if(PrintErrorsToLogProgram(program, GL_LINK_STATUS)) + if (PrintErrorsToLogProgram(program, GL_LINK_STATUS)) { MXLOG_WARNING("OpenGL::Shader", "failed to link shader program with id = " + ToMxString(program)); } @@ -166,7 +166,7 @@ namespace MxEngine template<> ShaderBase::ShaderId ShaderBase::CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& path) - { + { GLCALL(ShaderId shaderId = glCreateShader((GLenum)type)); ShaderPreprocessor preprocessor(sourceCode); @@ -183,10 +183,10 @@ namespace MxEngine { MXLOG_WARNING("OpenGL::Shader", "failed to compile shader stage: " + ToMxString(path)); } - - return shaderId; - } - + + return shaderId; + } + void ShaderBase::DeleteShader(ShaderId id) { GLCALL(glDeleteShader(id)); From ad91f57c0e47eb4958c7a594748b4ab83f77c7ca Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Mon, 11 Mar 2024 02:02:58 +0800 Subject: [PATCH 17/48] move Camera to header file --- src/Platform/OpenGL/ComputeShader.cpp | 2 +- src/Platform/OpenGL/Shader.cpp | 2 +- src/Platform/OpenGL/ShaderBase.cpp | 6 ++++-- src/Platform/OpenGL/ShaderBase.h | 3 ++- .../OpenGL/Shaders/Library/shader_utils.glsl | 18 +++++++++++++++++- .../OpenGL/Shaders/apply_ssr_fragment.glsl | 9 --------- .../OpenGL/Shaders/dirlight_fragment.glsl | 9 --------- src/Platform/OpenGL/Shaders/dof_coc.glsl | 9 +-------- src/Platform/OpenGL/Shaders/fog_fragment.glsl | 9 --------- .../OpenGL/Shaders/gbuffer_fragment.glsl | 11 ++--------- .../OpenGL/Shaders/gbuffer_mask_fragment.glsl | 10 +--------- .../OpenGL/Shaders/gbuffer_vertex.glsl | 10 +--------- .../OpenGL/Shaders/god_ray_fragment.glsl | 7 ------- src/Platform/OpenGL/Shaders/ibl_fragment.glsl | 9 --------- .../OpenGL/Shaders/pointlight_fragment.glsl | 9 --------- .../Shaders/pointlight_nonshadow_vertex.glsl | 10 +--------- .../Shaders/pointlight_shadow_vertex.glsl | 10 +--------- .../OpenGL/Shaders/spotlight_fragment.glsl | 9 --------- .../Shaders/spotlight_nonshadow_vertex.glsl | 10 +--------- .../Shaders/spotlight_shadow_vertex.glsl | 10 +--------- src/Platform/OpenGL/Shaders/ssao_fragment.glsl | 6 ------ src/Platform/OpenGL/Shaders/ssgi_fragment.glsl | 6 ------ src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 10 ---------- .../OpenGL/Shaders/transparent_fragment.glsl | 9 --------- src/Utilities/Parsing/ShaderPreprocessor.cpp | 7 +++---- 25 files changed, 37 insertions(+), 173 deletions(-) diff --git a/src/Platform/OpenGL/ComputeShader.cpp b/src/Platform/OpenGL/ComputeShader.cpp index d4d41a575..8b2a519c4 100644 --- a/src/Platform/OpenGL/ComputeShader.cpp +++ b/src/Platform/OpenGL/ComputeShader.cpp @@ -47,7 +47,7 @@ namespace MxEngine ComputeShader::BindableId ComputeShader::CreateShaderProgram(const MxString& source, const FilePath& path) { MXLOG_DEBUG("OpenGL::Shader", "compiling compute shader"); - ShaderId shaderId = ShaderBase::CreateShader(GL_COMPUTE_SHADER, source, path); + ShaderId shaderId = ShaderBase::CreateShader(GL_COMPUTE_SHADER, source, path,"COMPUTE"); BindableId program = ShaderBase::CreateProgram(&shaderId, 1); MXLOG_DEBUG("OpenGL::Shader", "created shader program with id = " + ToMxString(program)); diff --git a/src/Platform/OpenGL/Shader.cpp b/src/Platform/OpenGL/Shader.cpp index 484c0c85e..2f82614a1 100644 --- a/src/Platform/OpenGL/Shader.cpp +++ b/src/Platform/OpenGL/Shader.cpp @@ -61,7 +61,7 @@ namespace MxEngine { auto& stageInfo = stageInfos[i]; MXLOG_DEBUG("OpenGL::Shader", "compiling " + MxString(PipelineStageToString[stageInfo.Stage]) + " shader"); - ids[i] = ShaderBase::CreateShader(PipelineStageToNative[stageInfo.Stage], stageInfo.SourceCode, stageInfo.Path); + ids[i] = ShaderBase::CreateShader(PipelineStageToNative[stageInfo.Stage], stageInfo.SourceCode, stageInfo.Path, PipelineStageToString[stageInfo.Stage]); } // link stages into one shader program diff --git a/src/Platform/OpenGL/ShaderBase.cpp b/src/Platform/OpenGL/ShaderBase.cpp index a7be57005..c284cb6a7 100644 --- a/src/Platform/OpenGL/ShaderBase.cpp +++ b/src/Platform/OpenGL/ShaderBase.cpp @@ -165,14 +165,16 @@ namespace MxEngine } template<> - ShaderBase::ShaderId ShaderBase::CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& path) + ShaderBase::ShaderId ShaderBase::CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& path,MxString def) { GLCALL(ShaderId shaderId = glCreateShader((GLenum)type)); ShaderPreprocessor preprocessor(sourceCode); - + + std::transform(def.begin(), def.end(), def.begin(), [](char c) {return toupper(c); }); auto modifiedSourceCode = preprocessor .LoadIncludes(path.parent_path()) + .EmitPrefixLine("#define " + def + "_SHADER") .EmitPrefixLine(ShaderBase::GetShaderVersionString()) .GetResult(); diff --git a/src/Platform/OpenGL/ShaderBase.h b/src/Platform/OpenGL/ShaderBase.h index 7978df8f9..8ba112eef 100644 --- a/src/Platform/OpenGL/ShaderBase.h +++ b/src/Platform/OpenGL/ShaderBase.h @@ -66,13 +66,14 @@ namespace MxEngine void FreeProgram(); protected: static BindableId CreateProgram(const ShaderId* ids, size_t shaderCount); - template static ShaderId CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& filepath); + template static ShaderId CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& filepath,MxString def); template static MxVector GetShaderIncludeFiles(const MxString& sourceCode, const FilePath& filepath); static void DeleteShader(ShaderId id); void SetNewNativeHandle(BindableId id); public: static MxString GetShaderVersionString(); + static MxString GetShaderTypeString(); ShaderBase(); ~ShaderBase(); diff --git a/src/Platform/OpenGL/Shaders/Library/shader_utils.glsl b/src/Platform/OpenGL/Shaders/Library/shader_utils.glsl index 5b22bca76..6642707a0 100644 --- a/src/Platform/OpenGL/Shaders/Library/shader_utils.glsl +++ b/src/Platform/OpenGL/Shaders/Library/shader_utils.glsl @@ -6,6 +6,7 @@ vec3 reconstructWorldPosition(float depth, vec2 texcoord, mat4 invViewProjMatrix return worldPosition.xyz; } +#ifdef FRAGMENT_SHADER float getTextureLodLevel(vec2 uv) { vec2 dxVtc = dFdx(uv); @@ -13,12 +14,14 @@ float getTextureLodLevel(vec2 uv) float deltaMax2 = max(dot(dxVtc, dxVtc), dot(dyVtc, dyVtc)); return 0.5 * log2(deltaMax2); } +#endif float sampleShadowMap(sampler2D depthMap, vec2 coords, float lod, float compare) { return step(compare, texture(depthMap, coords, lod).r); } +#ifdef FRAGMENT_SHADER float calcShadowFactor2D(vec3 coords, sampler2D depthMap, vec4 textureLimitsXY, float bias) { if (coords.x < textureLimitsXY[0] || coords.x > textureLimitsXY[1]) return -1.0; @@ -47,6 +50,7 @@ float calcShadowFactor2D(vec3 coords, sampler2D depthMap, vec4 textureLimitsXY, return s / 9.0; } +#endif const int POINT_LIGHT_SAMPLES = 20; vec3 sampleOffsetDirections[POINT_LIGHT_SAMPLES] = vec3[] @@ -75,6 +79,7 @@ float CalcShadowFactor3D(vec3 fragToLightRay, vec3 viewDist, float zfar, float b return shadowFactor; } +#ifdef FRAGMENT_SHADER vec3 calcReflectionColor(samplerCube reflectionMap, mat3 reflectionMapTransform, vec3 viewDir, vec3 normal, float lod) { vec3 I = -viewDir; @@ -91,6 +96,7 @@ vec3 calcReflectionColor(samplerCube reflectionMap, mat3 reflectionMapTransform, { return calcReflectionColor(reflectionMap, reflectionMapTransform, viewDir, normal, 0.0); } +#endif vec4 worldToFragSpace(vec3 v, mat4 viewProj) { @@ -144,4 +150,14 @@ FragmentInfo getFragmentInfo(vec2 texCoord, sampler2D albedoTexture, sampler2D n float noise(vec2 p) { return fract(sin(dot(p, vec2(123.45, 875.43))) * 5432.3); -} \ No newline at end of file +} + +struct Camera +{ + vec3 position; + mat4 viewProjMatrix; + mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; + mat4 invProjectionMatrix; +}; \ No newline at end of file diff --git a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl index 1255ad8eb..edb56aa3e 100644 --- a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl @@ -3,15 +3,6 @@ in vec2 TexCoord; out vec4 OutColor; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform sampler2D albedoTex; uniform sampler2D normalTex; uniform sampler2D materialTex; diff --git a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl index 26b1c3d2a..04d80e1cf 100644 --- a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl @@ -3,15 +3,6 @@ out vec4 OutColor; in vec2 TexCoord; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform sampler2D albedoTex; uniform sampler2D normalTex; uniform sampler2D materialTex; diff --git a/src/Platform/OpenGL/Shaders/dof_coc.glsl b/src/Platform/OpenGL/Shaders/dof_coc.glsl index 7bfab9a78..aec953fcc 100644 --- a/src/Platform/OpenGL/Shaders/dof_coc.glsl +++ b/src/Platform/OpenGL/Shaders/dof_coc.glsl @@ -5,14 +5,7 @@ uniform sampler2D albedoTex; uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; + uniform Camera camera; uniform float focusDistance; uniform float focusRange; diff --git a/src/Platform/OpenGL/Shaders/fog_fragment.glsl b/src/Platform/OpenGL/Shaders/fog_fragment.glsl index d8c6fd601..20f625934 100644 --- a/src/Platform/OpenGL/Shaders/fog_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/fog_fragment.glsl @@ -9,15 +9,6 @@ uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform sampler2D cameraOutput; uniform Fog fog; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl index edc2adaf3..fb9147b69 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl @@ -1,5 +1,7 @@ layout(early_fragment_tests) in; +#include "Library/shader_utils.glsl" + in VSout { vec2 TexCoord; @@ -22,15 +24,6 @@ struct Material float transparency; }; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform sampler2D map_albedo; uniform sampler2D map_roughness; uniform sampler2D map_metallic; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl index 9578c4c41..c2c6f2d30 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/shader_utils.glsl" in VSout { vec2 TexCoord; @@ -19,15 +20,6 @@ struct Material float transparency; }; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform sampler2D map_albedo; uniform sampler2D map_roughness; uniform sampler2D map_metallic; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl index 97a8401c6..6400155a5 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl @@ -1,4 +1,5 @@ #include "Library/displacement.glsl" +#include "Library/shader_utils.glsl" layout(location = 0) in vec4 position; layout(location = 1) in vec2 texCoord; @@ -9,15 +10,6 @@ layout(location = 5) in mat4 model; layout(location = 9) in mat3 normalMatrix; layout(location = 12) in vec3 renderColor; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform Camera camera; uniform float displacement; uniform mat4 parentModel; diff --git a/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl b/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl index 907f98a44..332613982 100644 --- a/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl @@ -8,13 +8,6 @@ uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform sampler2D cameraOutput; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/ibl_fragment.glsl b/src/Platform/OpenGL/Shaders/ibl_fragment.glsl index dbba9cd12..78395eac3 100644 --- a/src/Platform/OpenGL/Shaders/ibl_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ibl_fragment.glsl @@ -9,15 +9,6 @@ uniform sampler2D materialTex; uniform sampler2D depthTex; uniform float gamma; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform Camera camera; uniform EnvironmentInfo environment; diff --git a/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl b/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl index 53356d433..bb2d8d1d4 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl @@ -21,15 +21,6 @@ struct PointLight vec4 color; }; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform samplerCube lightDepthMap; uniform bool castsShadows; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl b/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl index 18a4e6940..f9ec1dfa2 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl @@ -1,3 +1,4 @@ +#include "Library/shader_utils.glsl" layout(location = 0) in vec4 position; layout(location = 5) in mat4 transform; layout(location = 9) in vec4 sphereParameters; @@ -10,15 +11,6 @@ out PointLightInfo vec4 color; } pointLight; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform Camera camera; void main() diff --git a/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl b/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl index 7c7d208a0..f627750f4 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl @@ -1,3 +1,4 @@ +#include "Library/shader_utils.glsl" layout(location = 0) in vec4 position; out PointLightInfo @@ -7,15 +8,6 @@ out PointLightInfo vec4 color; } pointLight; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform Camera camera; uniform mat4 transform; uniform vec4 sphereParameters; diff --git a/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl b/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl index dee7d086d..a6f27ad7c 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl @@ -27,15 +27,6 @@ struct SpotLight float maxDistance; }; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform mat4 worldToLightTransform; uniform bool castsShadows; uniform sampler2D lightDepthMap; diff --git a/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl b/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl index efa444b7a..b83522910 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl @@ -1,3 +1,4 @@ +#include "Library/shader_utils.glsl" layout(location = 0) in vec4 position; layout(location = 5) in mat4 transform; layout(location = 9) in vec4 lightPosition; @@ -14,15 +15,6 @@ out SpotLightInfo float maxDistance; } spotLight; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform Camera camera; uniform mat4 worldToLightTransform; diff --git a/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl b/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl index 1ab0abae9..21ef5af16 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl @@ -1,3 +1,4 @@ +#include "Library/shader_utils.glsl" layout(location = 0) in vec4 position; out SpotLightInfo @@ -10,15 +11,6 @@ out SpotLightInfo float maxDistance; } spotLight; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform Camera camera; uniform mat4 worldToLightTransform; diff --git a/src/Platform/OpenGL/Shaders/ssao_fragment.glsl b/src/Platform/OpenGL/Shaders/ssao_fragment.glsl index d791a6d1c..a65ff3413 100644 --- a/src/Platform/OpenGL/Shaders/ssao_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssao_fragment.glsl @@ -8,12 +8,6 @@ uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - mat4 invViewProjMatrix; - mat4 viewProjMatrix; - vec3 position; -}; uniform Camera camera; uniform sampler2D noiseTex; diff --git a/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl b/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl index 6fc391dec..f9930adbf 100644 --- a/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl @@ -8,12 +8,6 @@ uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - vec3 position; -}; uniform Camera camera; uniform sampler2D inputTex; diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index 6548e22bd..7d61683cc 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -12,16 +12,6 @@ uniform sampler2D HDRTex; uniform sampler2D hiZTex0; uniform sampler2D hiZTex1; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; - mat4 invProjectionMatrix; -}; - uniform Camera camera; uniform EnvironmentInfo environment; diff --git a/src/Platform/OpenGL/Shaders/transparent_fragment.glsl b/src/Platform/OpenGL/Shaders/transparent_fragment.glsl index 78c8b04ae..ff2eaae86 100644 --- a/src/Platform/OpenGL/Shaders/transparent_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/transparent_fragment.glsl @@ -30,15 +30,6 @@ uniform Material material; uniform vec2 uvMultipliers; uniform float gamma; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - mat4 viewMatrix; - mat4 projectionMatrix; -}; - uniform int lightCount; uniform vec3 viewportPosition; uniform sampler2D envBRDFLUT; diff --git a/src/Utilities/Parsing/ShaderPreprocessor.cpp b/src/Utilities/Parsing/ShaderPreprocessor.cpp index 611d57b60..85e489275 100644 --- a/src/Utilities/Parsing/ShaderPreprocessor.cpp +++ b/src/Utilities/Parsing/ShaderPreprocessor.cpp @@ -77,10 +77,9 @@ namespace MxEngine this->includeFilePaths.push_back(path); #endif - auto it = this->source.find(include); - if (it != this->source.npos) this->source.erase(it, include.size()); - - this->source = File::ReadAllText(filepath) + this->source; + std::regex reg(include.c_str()); + MxString context = File::ReadAllText(filepath); + this->source = std::regex_replace(this->source.c_str(), reg, context.c_str()).c_str(); } // maybe there are new includes in included files if (!paths.empty()) this->LoadIncludes(lookupPath); From f580e27fe070aae67f45f49a01431ec82e315aa3 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Fri, 15 Mar 2024 18:20:28 +0800 Subject: [PATCH 18/48] Refactoring of shader compilation --- .../OpenGL/Shaders/Library/common_utils.glsl | 24 +++++++++++++++++++ ...{shader_utils.glsl => fragment_utils.glsl} | 21 ---------------- .../OpenGL/Shaders/Library/lighting.glsl | 2 +- .../OpenGL/Shaders/apply_ssgi_fragment.glsl | 3 ++- .../OpenGL/Shaders/apply_ssr_fragment.glsl | 10 +++----- .../OpenGL/Shaders/dirlight_fragment.glsl | 8 +------ src/Platform/OpenGL/Shaders/dof_bokeh.glsl | 3 ++- src/Platform/OpenGL/Shaders/dof_coc.glsl | 11 ++++----- src/Platform/OpenGL/Shaders/dof_combine.glsl | 3 ++- src/Platform/OpenGL/Shaders/fog_fragment.glsl | 10 ++------ .../OpenGL/Shaders/gbuffer_fragment.glsl | 8 +------ .../OpenGL/Shaders/gbuffer_mask_fragment.glsl | 8 +------ .../OpenGL/Shaders/gbuffer_vertex.glsl | 9 ++----- .../OpenGL/Shaders/god_ray_fragment.glsl | 8 +------ src/Platform/OpenGL/Shaders/ibl_fragment.glsl | 8 +------ .../particle_transparent_fragment.glsl | 1 + .../OpenGL/Shaders/pointlight_fragment.glsl | 8 +------ .../Shaders/pointlight_nonshadow_vertex.glsl | 8 +------ .../Shaders/pointlight_shadow_vertex.glsl | 8 +------ .../OpenGL/Shaders/spotlight_fragment.glsl | 8 +------ .../Shaders/spotlight_nonshadow_vertex.glsl | 8 +------ .../Shaders/spotlight_shadow_vertex.glsl | 8 +------ .../OpenGL/Shaders/ssao_fragment.glsl | 9 ++----- .../OpenGL/Shaders/ssgi_fragment.glsl | 7 +----- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 11 ++------- .../OpenGL/Shaders/transparent_fragment.glsl | 9 +------ src/Utilities/Parsing/ShaderPreprocessor.cpp | 7 +++--- 27 files changed, 63 insertions(+), 165 deletions(-) create mode 100644 src/Platform/OpenGL/Shaders/Library/common_utils.glsl rename src/Platform/OpenGL/Shaders/Library/{shader_utils.glsl => fragment_utils.glsl} (89%) diff --git a/src/Platform/OpenGL/Shaders/Library/common_utils.glsl b/src/Platform/OpenGL/Shaders/Library/common_utils.glsl new file mode 100644 index 000000000..abd47b755 --- /dev/null +++ b/src/Platform/OpenGL/Shaders/Library/common_utils.glsl @@ -0,0 +1,24 @@ +struct Camera +{ + vec3 position; + mat4 viewProjMatrix; + mat4 invViewProjMatrix; +}; +vec3 reconstructWorldPosition(float depth, vec2 texcoord, mat4 invViewProjMatrix) +{ + vec4 normPosition = vec4(2.0f * texcoord - vec2(1.0f), depth, 1.0f); + vec4 worldPosition = invViewProjMatrix * normPosition; + worldPosition /= worldPosition.w; + return worldPosition.xyz; +} +vec4 worldToFragSpace(vec3 v, mat4 viewProj) +{ + vec4 proj = viewProj * vec4(v, 1.0f); + proj.xyz /= proj.w; + proj.xy = proj.xy * 0.5f + vec2(0.5f); + return proj; +} +float noise(vec2 p) +{ + return fract(sin(dot(p, vec2(123.45, 875.43))) * 5432.3); +} \ No newline at end of file diff --git a/src/Platform/OpenGL/Shaders/Library/shader_utils.glsl b/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl similarity index 89% rename from src/Platform/OpenGL/Shaders/Library/shader_utils.glsl rename to src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl index 5b22bca76..846bf820d 100644 --- a/src/Platform/OpenGL/Shaders/Library/shader_utils.glsl +++ b/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl @@ -1,11 +1,3 @@ -vec3 reconstructWorldPosition(float depth, vec2 texcoord, mat4 invViewProjMatrix) -{ - vec4 normPosition = vec4(2.0f * texcoord - vec2(1.0f), depth, 1.0f); - vec4 worldPosition = invViewProjMatrix * normPosition; - worldPosition /= worldPosition.w; - return worldPosition.xyz; -} - float getTextureLodLevel(vec2 uv) { vec2 dxVtc = dFdx(uv); @@ -92,14 +84,6 @@ vec3 calcReflectionColor(samplerCube reflectionMap, mat3 reflectionMapTransform, return calcReflectionColor(reflectionMap, reflectionMapTransform, viewDir, normal, 0.0); } -vec4 worldToFragSpace(vec3 v, mat4 viewProj) -{ - vec4 proj = viewProj * vec4(v, 1.0f); - proj.xyz /= proj.w; - proj.xy = proj.xy * 0.5f + vec2(0.5f); - return proj; -} - struct FragmentInfo { vec3 albedo; @@ -140,8 +124,3 @@ FragmentInfo getFragmentInfo(vec2 texCoord, sampler2D albedoTexture, sampler2D n return fragment; } - -float noise(vec2 p) -{ - return fract(sin(dot(p, vec2(123.45, 875.43))) * 5432.3); -} \ No newline at end of file diff --git a/src/Platform/OpenGL/Shaders/Library/lighting.glsl b/src/Platform/OpenGL/Shaders/Library/lighting.glsl index 622f2eec8..0e4bc9179 100644 --- a/src/Platform/OpenGL/Shaders/Library/lighting.glsl +++ b/src/Platform/OpenGL/Shaders/Library/lighting.glsl @@ -1,4 +1,4 @@ -#include "Library/shader_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/pbr_lighting.glsl" vec3 calculateLighting(FragmentInfo fragment, vec3 viewDirection, vec3 lightDirection, vec3 lightColor, float ambientFactor, float shadowFactor) diff --git a/src/Platform/OpenGL/Shaders/apply_ssgi_fragment.glsl b/src/Platform/OpenGL/Shaders/apply_ssgi_fragment.glsl index 5a9834848..4117b4582 100644 --- a/src/Platform/OpenGL/Shaders/apply_ssgi_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/apply_ssgi_fragment.glsl @@ -1,4 +1,5 @@ -#include "Library/shader_utils.glsl" +#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" in vec2 TexCoord; out vec4 OutColor; diff --git a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl index a13e301bd..66c4d3c48 100644 --- a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl @@ -1,14 +1,10 @@ -#include "Library/shader_utils.glsl" +#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" in vec2 TexCoord; out vec4 OutColor; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; -}; + uniform sampler2D albedoTex; uniform sampler2D normalTex; diff --git a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl index 6a7e49e9b..c09609fd0 100644 --- a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl @@ -1,14 +1,8 @@ +#include "Library/common_utils.glsl" #include "Library/directional_light.glsl" - out vec4 OutColor; in vec2 TexCoord; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; uniform sampler2D albedoTex; uniform sampler2D normalTex; diff --git a/src/Platform/OpenGL/Shaders/dof_bokeh.glsl b/src/Platform/OpenGL/Shaders/dof_bokeh.glsl index 63d449983..a336d1795 100644 --- a/src/Platform/OpenGL/Shaders/dof_bokeh.glsl +++ b/src/Platform/OpenGL/Shaders/dof_bokeh.glsl @@ -1,4 +1,5 @@ -#include "Library/shader_utils.glsl" +#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" in vec2 TexCoord; out vec4 OutColor; layout(binding = 0)uniform sampler2D colorTex; diff --git a/src/Platform/OpenGL/Shaders/dof_coc.glsl b/src/Platform/OpenGL/Shaders/dof_coc.glsl index cc54c18ad..8e49b319d 100644 --- a/src/Platform/OpenGL/Shaders/dof_coc.glsl +++ b/src/Platform/OpenGL/Shaders/dof_coc.glsl @@ -1,16 +1,13 @@ -#include "Library/shader_utils.glsl" +#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" + in vec2 TexCoord; out vec4 OutColor; uniform sampler2D albedoTex; uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; + uniform Camera camera; uniform float focusDistance; uniform float focusRange; diff --git a/src/Platform/OpenGL/Shaders/dof_combine.glsl b/src/Platform/OpenGL/Shaders/dof_combine.glsl index 8b6451220..7bacbb5a5 100644 --- a/src/Platform/OpenGL/Shaders/dof_combine.glsl +++ b/src/Platform/OpenGL/Shaders/dof_combine.glsl @@ -1,4 +1,5 @@ -#include "Library/shader_utils.glsl" +#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" in vec2 TexCoord; out vec4 OutColor; layout(binding = 0)uniform sampler2D colorTex; diff --git a/src/Platform/OpenGL/Shaders/fog_fragment.glsl b/src/Platform/OpenGL/Shaders/fog_fragment.glsl index 3bf9ba056..c1e9510f9 100644 --- a/src/Platform/OpenGL/Shaders/fog_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/fog_fragment.glsl @@ -1,4 +1,5 @@ -#include "Library/shader_utils.glsl" +#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/fog.glsl" in vec2 TexCoord; @@ -9,13 +10,6 @@ uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform sampler2D cameraOutput; uniform Fog fog; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl index 03c87762c..20e6f8f3f 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" layout(early_fragment_tests) in; in VSout @@ -21,13 +22,6 @@ struct Material float transparency; }; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; -}; - uniform sampler2D map_albedo; uniform sampler2D map_roughness; uniform sampler2D map_metallic; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl index 17292e798..270144879 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" in VSout { vec2 TexCoord; @@ -19,13 +20,6 @@ struct Material float transparency; }; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; -}; - uniform sampler2D map_albedo; uniform sampler2D map_roughness; uniform sampler2D map_metallic; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl index 2241e6d13..ac6139008 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl @@ -1,5 +1,7 @@ +#include "Library/common_utils.glsl" #include "Library/displacement.glsl" + layout(location = 0) in vec4 position; layout(location = 1) in vec2 texCoord; layout(location = 2) in vec3 normal; @@ -9,13 +11,6 @@ layout(location = 5) in mat4 model; layout(location = 9) in mat3 normalMatrix; layout(location = 12) in vec3 renderColor; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; -}; - uniform Camera camera; uniform float displacement; uniform mat4 parentModel; diff --git a/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl b/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl index 907f98a44..3a959a11c 100644 --- a/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" #include "Library/directional_light.glsl" in vec2 TexCoord; @@ -8,13 +9,6 @@ uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform sampler2D cameraOutput; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/ibl_fragment.glsl b/src/Platform/OpenGL/Shaders/ibl_fragment.glsl index 6d883b3f7..2b7a5a8d2 100644 --- a/src/Platform/OpenGL/Shaders/ibl_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ibl_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" #include "Library/ibl_lighting.glsl" in vec2 TexCoord; @@ -9,13 +10,6 @@ uniform sampler2D materialTex; uniform sampler2D depthTex; uniform float gamma; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform Camera camera; uniform EnvironmentInfo environment; diff --git a/src/Platform/OpenGL/Shaders/particle_transparent_fragment.glsl b/src/Platform/OpenGL/Shaders/particle_transparent_fragment.glsl index 08c06f36e..9da4104ad 100644 --- a/src/Platform/OpenGL/Shaders/particle_transparent_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/particle_transparent_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" #include "Library/ibl_lighting.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl b/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl index 89e35178a..f02f1e55f 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" #include "Library/lighting.glsl" out vec4 OutColor; @@ -21,13 +22,6 @@ struct PointLight vec4 color; }; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform samplerCube lightDepthMap; uniform bool castsShadows; uniform Camera camera; diff --git a/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl b/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl index dd17b5853..1b0514006 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_nonshadow_vertex.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" layout(location = 0) in vec4 position; layout(location = 5) in mat4 transform; layout(location = 9) in vec4 sphereParameters; @@ -10,13 +11,6 @@ out PointLightInfo vec4 color; } pointLight; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform Camera camera; void main() diff --git a/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl b/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl index 9a44b4c29..fe122ca9b 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_shadow_vertex.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" layout(location = 0) in vec4 position; out PointLightInfo @@ -7,13 +8,6 @@ out PointLightInfo vec4 color; } pointLight; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform Camera camera; uniform mat4 transform; uniform vec4 sphereParameters; diff --git a/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl b/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl index eb118d1df..cac235900 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" #include "Library/lighting.glsl" out vec4 OutColor; @@ -27,13 +28,6 @@ struct SpotLight float maxDistance; }; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform mat4 worldToLightTransform; uniform bool castsShadows; uniform sampler2D lightDepthMap; diff --git a/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl b/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl index 1a2affbcd..de7d2cc07 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_nonshadow_vertex.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" layout(location = 0) in vec4 position; layout(location = 5) in mat4 transform; layout(location = 9) in vec4 lightPosition; @@ -14,13 +15,6 @@ out SpotLightInfo float maxDistance; } spotLight; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform Camera camera; uniform mat4 worldToLightTransform; diff --git a/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl b/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl index 56102a9ac..e2eff69c4 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_shadow_vertex.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" layout(location = 0) in vec4 position; out SpotLightInfo @@ -10,13 +11,6 @@ out SpotLightInfo float maxDistance; } spotLight; -struct Camera -{ - vec3 position; - mat4 invViewProjMatrix; - mat4 viewProjMatrix; -}; - uniform Camera camera; uniform mat4 worldToLightTransform; diff --git a/src/Platform/OpenGL/Shaders/ssao_fragment.glsl b/src/Platform/OpenGL/Shaders/ssao_fragment.glsl index d791a6d1c..f72c9fbf6 100644 --- a/src/Platform/OpenGL/Shaders/ssao_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssao_fragment.glsl @@ -1,4 +1,5 @@ -#include "Library/shader_utils.glsl" +#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" in vec2 TexCoord; out vec4 OutColor; @@ -8,12 +9,6 @@ uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - mat4 invViewProjMatrix; - mat4 viewProjMatrix; - vec3 position; -}; uniform Camera camera; uniform sampler2D noiseTex; diff --git a/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl b/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl index 6fc391dec..3bd69d544 100644 --- a/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" #include "Library/lighting.glsl" in vec2 TexCoord; @@ -8,12 +9,6 @@ uniform sampler2D normalTex; uniform sampler2D materialTex; uniform sampler2D depthTex; -struct Camera -{ - mat4 viewProjMatrix; - mat4 invViewProjMatrix; - vec3 position; -}; uniform Camera camera; uniform sampler2D inputTex; diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index a9ead8478..254e1e942 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -1,16 +1,9 @@ -#include "Library/shader_utils.glsl" +#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" in vec2 TexCoord; out vec4 OutColor; -struct Camera -{ - vec3 position; - mat4 viewProjMatrix; - mat4 invViewProjMatrix; -}; - - uniform sampler2D albedoTex; uniform sampler2D normalTex; uniform sampler2D materialTex; diff --git a/src/Platform/OpenGL/Shaders/transparent_fragment.glsl b/src/Platform/OpenGL/Shaders/transparent_fragment.glsl index 80d35bafd..d074a69bc 100644 --- a/src/Platform/OpenGL/Shaders/transparent_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/transparent_fragment.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" #include "Library/directional_light.glsl" out vec4 OutColor; @@ -30,14 +31,6 @@ uniform Material material; uniform vec2 uvMultipliers; uniform float gamma; -struct Camera -{ - vec3 position; - mat4 invProjMatrix; - mat4 invViewMatrix; - mat4 viewProjMatrix; -}; - uniform int lightCount; uniform vec3 viewportPosition; uniform sampler2D envBRDFLUT; diff --git a/src/Utilities/Parsing/ShaderPreprocessor.cpp b/src/Utilities/Parsing/ShaderPreprocessor.cpp index 611d57b60..85e489275 100644 --- a/src/Utilities/Parsing/ShaderPreprocessor.cpp +++ b/src/Utilities/Parsing/ShaderPreprocessor.cpp @@ -77,10 +77,9 @@ namespace MxEngine this->includeFilePaths.push_back(path); #endif - auto it = this->source.find(include); - if (it != this->source.npos) this->source.erase(it, include.size()); - - this->source = File::ReadAllText(filepath) + this->source; + std::regex reg(include.c_str()); + MxString context = File::ReadAllText(filepath); + this->source = std::regex_replace(this->source.c_str(), reg, context.c_str()).c_str(); } // maybe there are new includes in included files if (!paths.empty()) this->LoadIncludes(lookupPath); From ad87f7ae5a414b79e8e6fed72bfd5f3fd2819884 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 02:42:05 +0800 Subject: [PATCH 19/48] move common include into fragment --- src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl | 1 + src/Platform/OpenGL/Shaders/Library/lighting.glsl | 1 - src/Platform/OpenGL/Shaders/apply_ssgi_fragment.glsl | 1 - src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl | 1 - src/Platform/OpenGL/Shaders/dirlight_fragment.glsl | 2 +- src/Platform/OpenGL/Shaders/dof_bokeh.glsl | 1 - src/Platform/OpenGL/Shaders/dof_coc.glsl | 1 - src/Platform/OpenGL/Shaders/dof_combine.glsl | 1 - src/Platform/OpenGL/Shaders/fog_fragment.glsl | 1 - src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl | 2 +- src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl | 2 +- src/Platform/OpenGL/Shaders/god_ray_fragment.glsl | 2 +- src/Platform/OpenGL/Shaders/ibl_fragment.glsl | 2 +- src/Platform/OpenGL/Shaders/particle_transparent_fragment.glsl | 2 +- src/Platform/OpenGL/Shaders/pointlight_fragment.glsl | 2 +- src/Platform/OpenGL/Shaders/spotlight_fragment.glsl | 2 +- src/Platform/OpenGL/Shaders/ssao_fragment.glsl | 1 - src/Platform/OpenGL/Shaders/ssgi_fragment.glsl | 2 +- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 1 - src/Platform/OpenGL/Shaders/transparent_fragment.glsl | 2 +- 20 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl b/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl index 846bf820d..6606edaaf 100644 --- a/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl +++ b/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl @@ -1,3 +1,4 @@ +#include "Library/common_utils.glsl" float getTextureLodLevel(vec2 uv) { vec2 dxVtc = dFdx(uv); diff --git a/src/Platform/OpenGL/Shaders/Library/lighting.glsl b/src/Platform/OpenGL/Shaders/Library/lighting.glsl index 0e4bc9179..b1153d1be 100644 --- a/src/Platform/OpenGL/Shaders/Library/lighting.glsl +++ b/src/Platform/OpenGL/Shaders/Library/lighting.glsl @@ -1,4 +1,3 @@ -#include "Library/fragment_utils.glsl" #include "Library/pbr_lighting.glsl" vec3 calculateLighting(FragmentInfo fragment, vec3 viewDirection, vec3 lightDirection, vec3 lightColor, float ambientFactor, float shadowFactor) diff --git a/src/Platform/OpenGL/Shaders/apply_ssgi_fragment.glsl b/src/Platform/OpenGL/Shaders/apply_ssgi_fragment.glsl index 4117b4582..bc78e8c74 100644 --- a/src/Platform/OpenGL/Shaders/apply_ssgi_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/apply_ssgi_fragment.glsl @@ -1,4 +1,3 @@ -#include "Library/common_utils.glsl" #include "Library/fragment_utils.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl index 66c4d3c48..293096193 100644 --- a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl @@ -1,4 +1,3 @@ -#include "Library/common_utils.glsl" #include "Library/fragment_utils.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl index c09609fd0..c1eea98df 100644 --- a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/directional_light.glsl" out vec4 OutColor; in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/dof_bokeh.glsl b/src/Platform/OpenGL/Shaders/dof_bokeh.glsl index a336d1795..768150b52 100644 --- a/src/Platform/OpenGL/Shaders/dof_bokeh.glsl +++ b/src/Platform/OpenGL/Shaders/dof_bokeh.glsl @@ -1,4 +1,3 @@ -#include "Library/common_utils.glsl" #include "Library/fragment_utils.glsl" in vec2 TexCoord; out vec4 OutColor; diff --git a/src/Platform/OpenGL/Shaders/dof_coc.glsl b/src/Platform/OpenGL/Shaders/dof_coc.glsl index 8e49b319d..d2d3d0b33 100644 --- a/src/Platform/OpenGL/Shaders/dof_coc.glsl +++ b/src/Platform/OpenGL/Shaders/dof_coc.glsl @@ -1,4 +1,3 @@ -#include "Library/common_utils.glsl" #include "Library/fragment_utils.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/dof_combine.glsl b/src/Platform/OpenGL/Shaders/dof_combine.glsl index 7bacbb5a5..ba817066f 100644 --- a/src/Platform/OpenGL/Shaders/dof_combine.glsl +++ b/src/Platform/OpenGL/Shaders/dof_combine.glsl @@ -1,4 +1,3 @@ -#include "Library/common_utils.glsl" #include "Library/fragment_utils.glsl" in vec2 TexCoord; out vec4 OutColor; diff --git a/src/Platform/OpenGL/Shaders/fog_fragment.glsl b/src/Platform/OpenGL/Shaders/fog_fragment.glsl index c1e9510f9..9a90a0037 100644 --- a/src/Platform/OpenGL/Shaders/fog_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/fog_fragment.glsl @@ -1,4 +1,3 @@ -#include "Library/common_utils.glsl" #include "Library/fragment_utils.glsl" #include "Library/fog.glsl" diff --git a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl index 20e6f8f3f..712e5450e 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" layout(early_fragment_tests) in; in VSout diff --git a/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl index 270144879..8d10f653b 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_mask_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" in VSout { vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl b/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl index 3a959a11c..2075cc41c 100644 --- a/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/god_ray_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/directional_light.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/ibl_fragment.glsl b/src/Platform/OpenGL/Shaders/ibl_fragment.glsl index 2b7a5a8d2..d2b0c73a7 100644 --- a/src/Platform/OpenGL/Shaders/ibl_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ibl_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/ibl_lighting.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/particle_transparent_fragment.glsl b/src/Platform/OpenGL/Shaders/particle_transparent_fragment.glsl index 9da4104ad..b08b517fe 100644 --- a/src/Platform/OpenGL/Shaders/particle_transparent_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/particle_transparent_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/ibl_lighting.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl b/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl index f02f1e55f..59393492f 100644 --- a/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/pointlight_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/lighting.glsl" out vec4 OutColor; diff --git a/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl b/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl index cac235900..f600e1655 100644 --- a/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/spotlight_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/lighting.glsl" out vec4 OutColor; diff --git a/src/Platform/OpenGL/Shaders/ssao_fragment.glsl b/src/Platform/OpenGL/Shaders/ssao_fragment.glsl index f72c9fbf6..b6cbb1f26 100644 --- a/src/Platform/OpenGL/Shaders/ssao_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssao_fragment.glsl @@ -1,4 +1,3 @@ -#include "Library/common_utils.glsl" #include "Library/fragment_utils.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl b/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl index 3bd69d544..8dab08378 100644 --- a/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssgi_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/lighting.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index 254e1e942..bb354b28b 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -1,4 +1,3 @@ -#include "Library/common_utils.glsl" #include "Library/fragment_utils.glsl" in vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/transparent_fragment.glsl b/src/Platform/OpenGL/Shaders/transparent_fragment.glsl index d074a69bc..54ce1d80a 100644 --- a/src/Platform/OpenGL/Shaders/transparent_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/transparent_fragment.glsl @@ -1,4 +1,4 @@ -#include "Library/common_utils.glsl" +#include "Library/fragment_utils.glsl" #include "Library/directional_light.glsl" out vec4 OutColor; From a23f3b4a919bcb99316d181fd93980df2b1c22a4 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 03:00:32 +0800 Subject: [PATCH 20/48] fix merge issue --- src/Platform/OpenGL/Shaders/Library/common_utils.glsl | 3 +++ src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl | 2 -- src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Platform/OpenGL/Shaders/Library/common_utils.glsl b/src/Platform/OpenGL/Shaders/Library/common_utils.glsl index abd47b755..fd02a9660 100644 --- a/src/Platform/OpenGL/Shaders/Library/common_utils.glsl +++ b/src/Platform/OpenGL/Shaders/Library/common_utils.glsl @@ -3,6 +3,9 @@ struct Camera vec3 position; mat4 viewProjMatrix; mat4 invViewProjMatrix; + mat4 viewMatrix; + mat4 projectionMatrix; + mat4 invProjectionMatrix; }; vec3 reconstructWorldPosition(float depth, vec2 texcoord, mat4 invViewProjMatrix) { diff --git a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl index 4cc071778..288760ab0 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl @@ -1,8 +1,6 @@ #include "Library/fragment_utils.glsl" layout(early_fragment_tests) in; -#include "Library/shader_utils.glsl" - in VSout { vec2 TexCoord; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl index 7899bc0fc..430a7abf1 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl @@ -1,7 +1,5 @@ #include "Library/common_utils.glsl" #include "Library/displacement.glsl" -#include "Library/shader_utils.glsl" - layout(location = 0) in vec4 position; layout(location = 1) in vec2 texCoord; From d56ab0f2bcbf3f9ff9a0b740f95818671cfaa79a Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:26:55 +0800 Subject: [PATCH 21/48] add more comments --- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index dc997cdc5..5a27090c5 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -68,6 +68,7 @@ void main() vec3 viewDirection = normalize(viewDistance); vec3 reflectDirection = normalize(reflect(-viewDirection, fragment.normal)); + //0:start 1:end vec3 wp0 = fragment.position; vec3 wp1 = fragment.position + reflectDirection * rayLength; @@ -78,8 +79,8 @@ void main() vec4 ho1 = transform(camera.projectionMatrix, vec4(vp1, 1.0)); float w0 = 1.0 / ho0.w; - float w1 = 1.0 / ho1.w; - + float w1 = 1.0 / ho1.w; + //to avoid nonlinearity,project to view space vec3 vpProj0 = vp0 * w0; vec3 vpProj1 = vp1 * w1; @@ -90,7 +91,8 @@ void main() vec2 scr1 = (ndc1 + 1.0) / 2.0 * screenResolution; scr1 += distance(scr0, scr1) < 0.01 ? 0.01 : 0.0; - + //Using Line Generation Algorithm + //https://en.wikipedia.org/wiki/Digital_differential_analyzer_(graphics_algorithm) vec2 delta = scr1 - scr0; bool permute = false; if (abs(delta.x) < abs(delta.y)) @@ -106,7 +108,8 @@ void main() vec3 dVpProj = (vpProj1 - vpProj0) * invDx; float dw = (w1 - w0) * invDx; vec2 dScr = vec2(stepDir, delta.y * invDx); - + + //Start position scr0 += dScr; vpProj0 += dVpProj; w0 += dw; @@ -135,16 +138,16 @@ void main() if (result.x > screenResolution.x || result.x < 0 || result.y > screenResolution.y || result.y < 0) break; - + //reconstruct in cam space float d = sampleDepth(ivec2(result), level); vec4 normPosition = vec4(2.0f * result - vec2(1.0f), d, 1.0f); vec4 vpos = transform(camera.invProjectionMatrix, normPosition); vpos /= vpos.w; float sceneDepth = vpos.z; - + //check if near the start point if (!checkthickness && (depths.y - sceneDepth > thickness)) checkthickness = true; - + //check hit & switch depth layer float curDiff = sceneDepth - depths.y; if (checkthickness && (curDiff > 0 || curDiff < 0 && abs(curDiff) < thickness)) From 3b5a878e25114e573180d375e2100348c8f4b1d1 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:21:02 +0800 Subject: [PATCH 22/48] Merge branch 'master' of https://github.com/asc-community/MxEngine into screen_space_ray_tracing --- src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl | 2 -- src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl | 1 - 2 files changed, 3 deletions(-) diff --git a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl index 293096193..b49ba68ae 100644 --- a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl @@ -3,8 +3,6 @@ in vec2 TexCoord; out vec4 OutColor; - - uniform sampler2D albedoTex; uniform sampler2D normalTex; uniform sampler2D materialTex; diff --git a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl index ac6139008..430a7abf1 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl @@ -1,7 +1,6 @@ #include "Library/common_utils.glsl" #include "Library/displacement.glsl" - layout(location = 0) in vec4 position; layout(location = 1) in vec2 texCoord; layout(location = 2) in vec3 normal; From ce55e241107751faeb4dce3072004f284b5a5646 Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:22:29 +0800 Subject: [PATCH 23/48] Update dirlight_fragment.glsl --- src/Platform/OpenGL/Shaders/dirlight_fragment.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl index efa280ee1..a50d0a0a7 100644 --- a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl @@ -3,6 +3,7 @@ out vec4 OutColor; in vec2 TexCoord; + uniform sampler2D albedoTex; uniform sampler2D normalTex; uniform sampler2D materialTex; @@ -28,4 +29,4 @@ void main() } OutColor = vec4(totalColor, 1.0); -} \ No newline at end of file +} From 0ce84e3b979006b69986397eab3662e1f5d1c7a3 Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:23:11 +0800 Subject: [PATCH 24/48] Update dirlight_fragment.glsl From 3ed9c3e020f8e26b64a4045896f423e619dfcc5b Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:23:53 +0800 Subject: [PATCH 25/48] Update apply_ssr_fragment.glsl --- src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl index b49ba68ae..8178ceb82 100644 --- a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl @@ -3,6 +3,8 @@ in vec2 TexCoord; out vec4 OutColor; + + uniform sampler2D albedoTex; uniform sampler2D normalTex; uniform sampler2D materialTex; @@ -34,4 +36,4 @@ void main() vec3 totalColor = initialColor + F0 * ssrReflection; OutColor = vec4(totalColor, 1.0); -} \ No newline at end of file +} From bca72a34828cc2b3c470843eb87977e7cb1f78b1 Mon Sep 17 00:00:00 2001 From: Lucas <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:25:41 +0800 Subject: [PATCH 26/48] Update dirlight_fragment.glsl From 27f165152d46e4206b4a0e92a2ba5796add2455a Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:38:21 +0800 Subject: [PATCH 27/48] Update gbuffer_vertex.glsl --- src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl index 430a7abf1..ac6139008 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_vertex.glsl @@ -1,6 +1,7 @@ #include "Library/common_utils.glsl" #include "Library/displacement.glsl" + layout(location = 0) in vec4 position; layout(location = 1) in vec2 texCoord; layout(location = 2) in vec3 normal; From bd9898267bafc0312aadf9e4392ae32ae40804d6 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:39:28 +0800 Subject: [PATCH 28/48] Update dirlight_fragment.glsl --- src/Platform/OpenGL/Shaders/dirlight_fragment.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl index a50d0a0a7..c1eea98df 100644 --- a/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/dirlight_fragment.glsl @@ -29,4 +29,4 @@ void main() } OutColor = vec4(totalColor, 1.0); -} +} \ No newline at end of file From 2417abd3693911c7b87be0ccad4862d95df3ffe5 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:39:59 +0800 Subject: [PATCH 29/48] Update apply_ssr_fragment.glsl --- src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl index 8178ceb82..293096193 100644 --- a/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/apply_ssr_fragment.glsl @@ -36,4 +36,4 @@ void main() vec3 totalColor = initialColor + F0 * ssrReflection; OutColor = vec4(totalColor, 1.0); -} +} \ No newline at end of file From c93f9d375052f025c59cb672277f84737604cd93 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:44:41 +0800 Subject: [PATCH 30/48] sync master --- src/Platform/OpenGL/ComputeShader.cpp | 2 +- src/Platform/OpenGL/Shader.cpp | 2 +- src/Platform/OpenGL/ShaderBase.cpp | 8 +++----- src/Platform/OpenGL/ShaderBase.h | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Platform/OpenGL/ComputeShader.cpp b/src/Platform/OpenGL/ComputeShader.cpp index 8b2a519c4..d4d41a575 100644 --- a/src/Platform/OpenGL/ComputeShader.cpp +++ b/src/Platform/OpenGL/ComputeShader.cpp @@ -47,7 +47,7 @@ namespace MxEngine ComputeShader::BindableId ComputeShader::CreateShaderProgram(const MxString& source, const FilePath& path) { MXLOG_DEBUG("OpenGL::Shader", "compiling compute shader"); - ShaderId shaderId = ShaderBase::CreateShader(GL_COMPUTE_SHADER, source, path,"COMPUTE"); + ShaderId shaderId = ShaderBase::CreateShader(GL_COMPUTE_SHADER, source, path); BindableId program = ShaderBase::CreateProgram(&shaderId, 1); MXLOG_DEBUG("OpenGL::Shader", "created shader program with id = " + ToMxString(program)); diff --git a/src/Platform/OpenGL/Shader.cpp b/src/Platform/OpenGL/Shader.cpp index 2f82614a1..484c0c85e 100644 --- a/src/Platform/OpenGL/Shader.cpp +++ b/src/Platform/OpenGL/Shader.cpp @@ -61,7 +61,7 @@ namespace MxEngine { auto& stageInfo = stageInfos[i]; MXLOG_DEBUG("OpenGL::Shader", "compiling " + MxString(PipelineStageToString[stageInfo.Stage]) + " shader"); - ids[i] = ShaderBase::CreateShader(PipelineStageToNative[stageInfo.Stage], stageInfo.SourceCode, stageInfo.Path, PipelineStageToString[stageInfo.Stage]); + ids[i] = ShaderBase::CreateShader(PipelineStageToNative[stageInfo.Stage], stageInfo.SourceCode, stageInfo.Path); } // link stages into one shader program diff --git a/src/Platform/OpenGL/ShaderBase.cpp b/src/Platform/OpenGL/ShaderBase.cpp index c284cb6a7..538449125 100644 --- a/src/Platform/OpenGL/ShaderBase.cpp +++ b/src/Platform/OpenGL/ShaderBase.cpp @@ -136,7 +136,7 @@ namespace MxEngine } GLCALL(glLinkProgram(program)); - if (PrintErrorsToLogProgram(program, GL_LINK_STATUS)) + if(PrintErrorsToLogProgram(program, GL_LINK_STATUS)) { MXLOG_WARNING("OpenGL::Shader", "failed to link shader program with id = " + ToMxString(program)); } @@ -165,16 +165,14 @@ namespace MxEngine } template<> - ShaderBase::ShaderId ShaderBase::CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& path,MxString def) + ShaderBase::ShaderId ShaderBase::CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& path) { GLCALL(ShaderId shaderId = glCreateShader((GLenum)type)); ShaderPreprocessor preprocessor(sourceCode); - - std::transform(def.begin(), def.end(), def.begin(), [](char c) {return toupper(c); }); + auto modifiedSourceCode = preprocessor .LoadIncludes(path.parent_path()) - .EmitPrefixLine("#define " + def + "_SHADER") .EmitPrefixLine(ShaderBase::GetShaderVersionString()) .GetResult(); diff --git a/src/Platform/OpenGL/ShaderBase.h b/src/Platform/OpenGL/ShaderBase.h index 8ba112eef..7978df8f9 100644 --- a/src/Platform/OpenGL/ShaderBase.h +++ b/src/Platform/OpenGL/ShaderBase.h @@ -66,14 +66,13 @@ namespace MxEngine void FreeProgram(); protected: static BindableId CreateProgram(const ShaderId* ids, size_t shaderCount); - template static ShaderId CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& filepath,MxString def); + template static ShaderId CreateShader(ShaderTypeEnum type, const MxString& sourceCode, const FilePath& filepath); template static MxVector GetShaderIncludeFiles(const MxString& sourceCode, const FilePath& filepath); static void DeleteShader(ShaderId id); void SetNewNativeHandle(BindableId id); public: static MxString GetShaderVersionString(); - static MxString GetShaderTypeString(); ShaderBase(); ~ShaderBase(); From 344b15e4a6f271946ff61534c0b3449732e6f6fd Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Wed, 20 Mar 2024 18:47:33 +0800 Subject: [PATCH 31/48] use MxFormat --- src/Core/Components/Camera/CameraController.cpp | 3 ++- src/Core/Rendering/RenderController.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index 975e1dae8..aad05c53d 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -27,6 +27,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "CameraController.h" +#include "Utilities/Format/Format.h" #include "Core/Events/WindowResizeEvent.h" #include "Core/Config/GlobalConfig.h" #include "Core/Application/Event.h" @@ -519,7 +520,7 @@ namespace MxEngine for (int i = 0; i < this->HiZ.size(); i++) { int scale = pow(2, i+1); - MxString tag = ToMxString(fmt::format("!camera depth lv{}", i + 1)); + MxString tag = MxFormat("!camera depth lv{}", i + 1); this->HiZ[i]->Load(nullptr, width / scale, height / scale, 1, false, TextureFormat::R32F); this->HiZ[i]->SetInternalEngineTag(tag); this->HiZ[i]->SetWrapType(TextureWrap::CLAMP_TO_EDGE); diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index d685d765e..9ed66aae6 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -1067,7 +1067,7 @@ namespace MxEngine { auto& it = camera.HiZ[i]; it->Bind(startId++); - shader.SetUniform(ToMxString( fmt::format("hiZTex{}", i)), it->GetBoundId()); + shader.SetUniform(MxFormat("hiZTex{}", i), it->GetBoundId()); } } From b1d08050a268288d68bcc6159c30233d812f953d Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Wed, 20 Mar 2024 18:49:09 +0800 Subject: [PATCH 32/48] getHiz() => const reference --- src/Core/Components/Camera/CameraController.cpp | 2 +- src/Core/Components/Camera/CameraController.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index aad05c53d..5716fdaca 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -437,7 +437,7 @@ namespace MxEngine return this->renderBuffers->Depth; } - MxVector CameraController::GetHiZ() const + const MxVector& CameraController::GetHiZ() const { return this->renderBuffers->HiZ; } diff --git a/src/Core/Components/Camera/CameraController.h b/src/Core/Components/Camera/CameraController.h index 90ee2a351..cd0d3ef3d 100644 --- a/src/Core/Components/Camera/CameraController.h +++ b/src/Core/Components/Camera/CameraController.h @@ -134,7 +134,7 @@ namespace MxEngine TextureHandle GetMaterialTexture() const; TextureHandle GetSSRMask()const; TextureHandle GetDepthTexture() const; - MxVector GetHiZ() const; + const MxVector& GetHiZ() const; TextureHandle GetAverageWhiteTexture() const; TextureHandle GetHDRTexture() const; TextureHandle GetSwapHDRTexture1() const; From a086f162336dd3a556475a8eb738050268cffbea Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Wed, 20 Mar 2024 19:17:00 +0800 Subject: [PATCH 33/48] avoid memory alloc --- src/Core/Rendering/RenderController.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 9ed66aae6..e9584442f 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -358,14 +358,20 @@ namespace MxEngine { MAKE_RENDER_PASS_SCOPE("RenderController::GenerateDepthPyramid()"); auto& shader = this->Pipeline.Environment.Shaders["HIZ"_id]; - MxVector inputTex = { zBuffer }; - for (auto it : HiZ) inputTex.emplace_back(it); + + auto fGetTex = [&zBuffer, &HiZ](int layer)->TextureHandle& + { + if (layer == 0) + return zBuffer; + else + return HiZ[layer - 1]; + }; for (int i = 0; i < HiZ.size(); i++) { shader->Bind(); - inputTex[i]->Bind(0); - auto& outputTex = inputTex[i + 1]; + fGetTex(i)->Bind(0); + auto& outputTex = fGetTex(i + 1); shader->SetUniform("uPreviousLevelRes", VectorInt2(outputTex->GetWidth(), outputTex->GetHeight())); this->RenderToTexture(outputTex, shader); } From 2e7f66ff375d392ad66d4307da9e09770cb6b22b Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Wed, 20 Mar 2024 19:20:49 +0800 Subject: [PATCH 34/48] format --- src/Core/Rendering/RenderController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index e9584442f..05f2e581e 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -1663,7 +1663,7 @@ namespace MxEngine this->DrawObjects(camera, *this->Pipeline.Environment.Shaders["GBuffer"_id], this->Pipeline.OpaqueObjects); this->DrawObjects(camera, *this->Pipeline.Environment.Shaders["GBufferMask"_id], this->Pipeline.MaskedObjects); - this->GenerateDepthPyramid(camera.DepthTexture,camera.HiZ); + this->GenerateDepthPyramid(camera.DepthTexture, camera.HiZ); this->DrawParticles(camera, this->Pipeline.OpaqueParticleSystems, *this->Pipeline.Environment.Shaders["ParticleOpaque"_id]); From 5435b7b51b626596279340efb043e742abd0f8bd Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Wed, 20 Mar 2024 19:22:03 +0800 Subject: [PATCH 35/48] fomat --- src/Core/Resources/Material.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Resources/Material.h b/src/Core/Resources/Material.h index ca4e0d88a..b98735f61 100644 --- a/src/Core/Resources/Material.h +++ b/src/Core/Resources/Material.h @@ -59,7 +59,7 @@ namespace MxEngine float RoughnessFactor = 0.75f; float MetallicFactor = 0.0f; - bool ReceiveSSR{ false }; + bool ReceiveSSR = false; Vector3 BaseColor{ 1.0f }; Vector2 UVMultipliers{ 1.0f }; AlphaModeGroup AlphaMode = AlphaModeGroup::OPAQUE; From 4112903a80bcd25c5f3980da27bd04f74d899392 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Wed, 20 Mar 2024 19:25:39 +0800 Subject: [PATCH 36/48] using float for bool param pass to shader --- src/Core/Rendering/RenderController.cpp | 2 +- src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 05f2e581e..7b956e5d9 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -278,7 +278,7 @@ namespace MxEngine shader.SetUniform("parentNormal", unit.NormalMatrix); shader.SetUniform("parentColor", material.BaseColor); - shader.SetUniform("receiveSSR", material.ReceiveSSR); + shader.SetUniform("receiveSSR", static_cast(material.ReceiveSSR)); this->DrawIndices(RenderPrimitive::TRIANGLES, unit.IndexCount, unit.IndexOffset, unit.VertexOffset, instanceCount, baseInstance); } diff --git a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl index 288760ab0..16e882331 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl @@ -35,7 +35,7 @@ uniform vec2 uvMultipliers; uniform float displacement; uniform float gamma; uniform Camera camera; -uniform bool receiveSSR; +uniform float receiveSSR; vec3 calcNormal(vec2 texcoord, mat3 TBN, sampler2D normalMap) { @@ -70,5 +70,5 @@ void main() OutAlbedo = vec4(fsin.RenderColor * albedo, emmisive / (emmisive + 1.0f)); OutNormal = vec4(0.5f * normal + 0.5f, 1.0f); OutMaterial = vec4(parallaxOcclusion * occlusion, roughness, metallic, 1.0f); - OutSSRMask = vec4(float(receiveSSR),vec3(1.0)); + OutSSRMask = vec4(receiveSSR,vec3(1.0)); } \ No newline at end of file From 32420d75e2edee7a89b4add0570f577bfbf6a875 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Wed, 20 Mar 2024 19:56:24 +0800 Subject: [PATCH 37/48] add more comments --- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index 5a27090c5..18fb71a17 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -11,6 +11,7 @@ uniform sampler2D ssrMask; uniform sampler2D HDRTex; uniform sampler2D hiZTex0; uniform sampler2D hiZTex1; +//add more levels here uniform Camera camera; uniform EnvironmentInfo environment; @@ -26,7 +27,7 @@ float sampleDepth(ivec2 uv, int level) case 0:return texelFetch(depthTex, uv, 0).r; case 1:return texelFetch(hiZTex0, uv / ivec2(2), 0).r; case 2:return texelFetch(hiZTex1, uv / ivec2(4), 0).r; - //Add more levels if needed + //Add more levels here } } @@ -62,7 +63,7 @@ void main() } FragmentInfo fragment = getFragmentInfo( TexCoord, albedoTex, normalTex, materialTex, depthTex, camera.invViewProjMatrix); - float rayLength = 8000.f; + float rayLength = 8000.f;//long enough for any screen vec3 viewDistance = camera.position - fragment.position; vec3 viewDirection = normalize(viewDistance); @@ -157,12 +158,14 @@ void main() isHit = true; break; } + //stepping back TRACE_RAY(-pow(2.0, level)); level = 0; } else { level = min(maxLevel, level + 1); + //stepping forward TRACE_RAY(pow(2.0, level)); } } From fa6c9c9c783942be16e085beb72fff2f8b891613 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Tue, 26 Mar 2024 02:42:51 +0800 Subject: [PATCH 38/48] Remove intensity. Expose levels to editor. --- src/Core/Components/Camera/CameraController.cpp | 2 +- src/Core/Components/Camera/CameraSSR.cpp | 15 +++++++-------- src/Core/Components/Camera/CameraSSR.h | 6 +++--- src/Core/Rendering/RenderController.cpp | 10 ++++++++-- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 9 ++++++--- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index 5716fdaca..c4250b0f6 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -474,7 +474,7 @@ namespace MxEngine this->HDR = Factory::Create(); this->SwapHDR1 = Factory::Create(); this->SwapHDR2 = Factory::Create(); - for (int i = 0; i < 2; i++) HiZ.emplace_back(Factory::Create()); + for (int i = 0; i < 4; i++) HiZ.emplace_back(Factory::Create()); this->Resize(width, height); diff --git a/src/Core/Components/Camera/CameraSSR.cpp b/src/Core/Components/Camera/CameraSSR.cpp index dc9d085fd..e0ddbd3bd 100644 --- a/src/Core/Components/Camera/CameraSSR.cpp +++ b/src/Core/Components/Camera/CameraSSR.cpp @@ -42,15 +42,14 @@ namespace MxEngine this->thickness = Max(thickness, 0.0f); } - float CameraSSR::GetIntensity() const + int CameraSSR::GetMaxLevel() const { - return this->intensity; + return this->maxLevel; } - - void CameraSSR::SetIntensity(float intensity) + void CameraSSR::SetMaxLevel(int level) { - this->intensity = intensity; + this->maxLevel = level; } MXENGINE_REFLECT_TYPE @@ -66,11 +65,11 @@ namespace MxEngine rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1.0f, 100.0f }), rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) ) - .property("intensity", &CameraSSR::GetIntensity, &CameraSSR::SetIntensity) + .property("max level", &CameraSSR::GetMaxLevel, &CameraSSR::SetMaxLevel) ( rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), - rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1.0f, 50.0f }), - rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1, 4 }), + rttr::metadata(EditorInfo::EDIT_PRECISION, 1) ); } } \ No newline at end of file diff --git a/src/Core/Components/Camera/CameraSSR.h b/src/Core/Components/Camera/CameraSSR.h index 48524a948..366a5141c 100644 --- a/src/Core/Components/Camera/CameraSSR.h +++ b/src/Core/Components/Camera/CameraSSR.h @@ -37,16 +37,16 @@ namespace MxEngine MAKE_COMPONENT(CameraSSR); float thickness = 0.5f; - float intensity = 4.0f; + float maxLevel = 2.0f; public: CameraSSR() = default; float GetThickness() const; - float GetIntensity()const; + int GetMaxLevel()const; void SetThickness(float thickness); - void SetIntensity(float intensity); + void SetMaxLevel(int level); }; } \ No newline at end of file diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 7b956e5d9..20468a8bd 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -661,10 +661,16 @@ namespace MxEngine std::swap(input, output); } + void RenderController::ApplySSR(CameraUnit& camera, TextureHandle& input, TextureHandle& temporary, TextureHandle& output) { if (camera.SSR == nullptr ) return; - MAKE_RENDER_PASS_SCOPE("RenderController::ApplySSR()"); + + int level = camera.SSR->GetMaxLevel(); +#if defined(MXENGINE_PROFILING_ENABLED) + auto profilerTitle = MxFormat("RenderController::ApplySSR(level={})", level); + MAKE_RENDER_PASS_SCOPE(profilerTitle.c_str()); +#endif auto& SSRShader = this->Pipeline.Environment.Shaders["SSR"_id]; SSRShader->Bind(); @@ -680,7 +686,7 @@ namespace MxEngine SSRShader->SetUniform("thickness", camera.SSR->GetThickness()); SSRShader->SetUniform("screenResolution", Vector2(camera.HDRTexture->GetWidth(), camera.HDRTexture->GetHeight())); - SSRShader->SetUniform("intensity", camera.SSR->GetIntensity()); + SSRShader->SetUniform("maxLevel", level); this->RenderToTexture(temporary, SSRShader); diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index 18fb71a17..43c441b30 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -11,6 +11,8 @@ uniform sampler2D ssrMask; uniform sampler2D HDRTex; uniform sampler2D hiZTex0; uniform sampler2D hiZTex1; +uniform sampler2D hiZTex2; +uniform sampler2D hiZTex3; //add more levels here uniform Camera camera; @@ -18,7 +20,7 @@ uniform EnvironmentInfo environment; uniform float thickness; uniform vec2 screenResolution; -uniform float intensity;//For users who wanna emphasize emotion +uniform int maxLevel; float sampleDepth(ivec2 uv, int level) { @@ -27,6 +29,8 @@ float sampleDepth(ivec2 uv, int level) case 0:return texelFetch(depthTex, uv, 0).r; case 1:return texelFetch(hiZTex0, uv / ivec2(2), 0).r; case 2:return texelFetch(hiZTex1, uv / ivec2(4), 0).r; + case 3:return texelFetch(hiZTex2, uv / ivec2(8), 0).r; + case 4:return texelFetch(hiZTex3, uv / ivec2(16), 0).r; //Add more levels here } } @@ -120,7 +124,6 @@ void main() bool isHit = false; bool checkthickness = false; int level = 0; - int maxLevel = 2; float testStp = 0.0; int maxStp = int(sqrt(screenResolution.x * screenResolution.x + screenResolution.y * screenResolution.y)); //Todo: /(ㄒoㄒ)/~~ Handle diffuse lobe. Sampling more rays or using cone tracing when the BRDF lobe is fat. @@ -171,7 +174,7 @@ void main() } if (isHit) - OutColor = vec4(texelFetch(HDRTex, ivec2(result), 0).rgb * intensity, 1.0); + OutColor = vec4(texelFetch(HDRTex, ivec2(result), 0).rgb, 1.0); else OutColor = vec4(0.0); } \ No newline at end of file From 3404e4db1fece3c7581e8fd3c8d26ea2b9f6afb6 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 30 Mar 2024 01:20:34 +0800 Subject: [PATCH 39/48] Fix artefacts https://github.com/asc-community/MxEngine/pull/94#issuecomment-2025958522 --- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index 43c441b30..87f0a5722 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -153,8 +153,7 @@ void main() checkthickness = true; //check hit & switch depth layer float curDiff = sceneDepth - depths.y; - if (checkthickness && - (curDiff > 0 || curDiff < 0 && abs(curDiff) < thickness)) + if (checkthickness && curDiff >= thickness) { if (level == 0) { From cace588b341661d0e83ee9d347000cb83b9a7c42 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:41:32 +0800 Subject: [PATCH 40/48] using bit shift --- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index 87f0a5722..f09317209 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -52,11 +52,11 @@ void swapComp(inout vec2 v) } #define TRACE_RAY(stp) \ - do{\ - scr0+=dScr*int(stp);\ - vpProj0.z+=dVpProj.z*int(stp);\ - w0+=dw*int(stp);\ - }while(false); + do {\ + scr0 += dScr * stp;\ + vpProj0.z += dVpProj.z * stp;\ + w0 += dw * stp;\ + } while(false); void main() { @@ -153,6 +153,7 @@ void main() checkthickness = true; //check hit & switch depth layer float curDiff = sceneDepth - depths.y; + int stp = 1 << level; if (checkthickness && curDiff >= thickness) { if (level == 0) @@ -161,14 +162,14 @@ void main() break; } //stepping back - TRACE_RAY(-pow(2.0, level)); + TRACE_RAY(-stp); level = 0; } else { level = min(maxLevel, level + 1); //stepping forward - TRACE_RAY(pow(2.0, level)); + TRACE_RAY(stp); } } From df2411778e10041cdd221d3cfa67485698370448 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 31 Mar 2024 04:04:34 +0800 Subject: [PATCH 41/48] pack depth clips into one texture --- .../Components/Camera/CameraController.cpp | 24 ++++++++-- src/Core/Components/Camera/CameraController.h | 2 + src/Core/Components/Camera/CameraSSR.cpp | 22 +++++++-- src/Core/Components/Camera/CameraSSR.h | 7 ++- src/Core/Rendering/RenderController.cpp | 36 ++++++++++----- src/Core/Rendering/RenderController.h | 2 +- src/Core/Rendering/RenderPipeline.h | 1 + src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 45 ++++++++----------- src/Platform/OpenGL/Texture.cpp | 6 +++ src/Platform/OpenGL/Texture.h | 1 + 10 files changed, 98 insertions(+), 48 deletions(-) diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index c4250b0f6..f5a3829c0 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -442,6 +442,11 @@ namespace MxEngine return this->renderBuffers->HiZ; } + const TextureHandle& CameraController::GetPackedDepth() const + { + return this->renderBuffers->PackedDepthMap; + } + TextureHandle CameraController::GetAverageWhiteTexture() const { return this->renderBuffers->AverageWhite; @@ -474,7 +479,8 @@ namespace MxEngine this->HDR = Factory::Create(); this->SwapHDR1 = Factory::Create(); this->SwapHDR2 = Factory::Create(); - for (int i = 0; i < 4; i++) HiZ.emplace_back(Factory::Create()); + for (int i = 0; i < 4; i++) this->HiZ.emplace_back(Factory::Create()); + this->PackedDepthMap = Factory::Create(); this->Resize(width, height); @@ -517,15 +523,23 @@ namespace MxEngine this->Depth->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera depth")); this->Depth->SetWrapType(TextureWrap::CLAMP_TO_EDGE); + int packedHeight = height; for (int i = 0; i < this->HiZ.size(); i++) { - int scale = pow(2, i+1); + int scale = 1 << (i + 1); MxString tag = MxFormat("!camera depth lv{}", i + 1); - this->HiZ[i]->Load(nullptr, width / scale, height / scale, 1, false, TextureFormat::R32F); + int w = width / scale; + int h = height / scale; + packedHeight += h; + this->HiZ[i]->Load(nullptr, w, h, 1, false, TextureFormat::R32F); this->HiZ[i]->SetInternalEngineTag(tag); this->HiZ[i]->SetWrapType(TextureWrap::CLAMP_TO_EDGE); } + this->PackedDepthMap->Load(nullptr, width, packedHeight, 1, false, TextureFormat::R32F); + this->PackedDepthMap->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("packed depth map")); + this->PackedDepthMap->SetWrapType(TextureWrap::CLAMP_TO_EDGE); + this->AverageWhite->Load(nullptr, 1, 1, 3, false, TextureFormat::RGBA16F); this->AverageWhite->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera white")); this->AverageWhite->SetWrapType(TextureWrap::CLAMP_TO_EDGE); @@ -554,7 +568,9 @@ namespace MxEngine Factory::Destroy(this->HDR); Factory::Destroy(this->SwapHDR1); Factory::Destroy(this->SwapHDR2); - for(auto& it:this->HiZ)Factory::Destroy(it); + for (auto& it : this->HiZ) + Factory::Destroy(it); + Factory::Destroy(this->PackedDepthMap); } MXENGINE_REFLECT_TYPE diff --git a/src/Core/Components/Camera/CameraController.h b/src/Core/Components/Camera/CameraController.h index cd0d3ef3d..8e198fd11 100644 --- a/src/Core/Components/Camera/CameraController.h +++ b/src/Core/Components/Camera/CameraController.h @@ -51,6 +51,7 @@ namespace MxEngine TextureHandle Depth; TextureHandle SSRMask; MxVector HiZ; + TextureHandle PackedDepthMap; TextureHandle AverageWhite; TextureHandle HDR; TextureHandle SwapHDR1; @@ -135,6 +136,7 @@ namespace MxEngine TextureHandle GetSSRMask()const; TextureHandle GetDepthTexture() const; const MxVector& GetHiZ() const; + const TextureHandle& GetPackedDepth() const; TextureHandle GetAverageWhiteTexture() const; TextureHandle GetHDRTexture() const; TextureHandle GetSwapHDRTexture1() const; diff --git a/src/Core/Components/Camera/CameraSSR.cpp b/src/Core/Components/Camera/CameraSSR.cpp index e0ddbd3bd..31c2e698b 100644 --- a/src/Core/Components/Camera/CameraSSR.cpp +++ b/src/Core/Components/Camera/CameraSSR.cpp @@ -39,7 +39,7 @@ namespace MxEngine void CameraSSR::SetThickness(float thickness) { - this->thickness = Max(thickness, 0.0f); + this->thickness = Max(thickness, 1.0f); } int CameraSSR::GetMaxLevel() const @@ -49,7 +49,17 @@ namespace MxEngine void CameraSSR::SetMaxLevel(int level) { - this->maxLevel = level; + this->maxLevel = Clamp(level,1,4); + } + + int CameraSSR::GetMaxStep()const + { + return this->maxStep; + } + + void CameraSSR::SetMaxStep(int step) + { + this->maxStep = Clamp(step,150,255); } MXENGINE_REFLECT_TYPE @@ -62,7 +72,7 @@ namespace MxEngine .property("thickness", &CameraSSR::GetThickness, &CameraSSR::SetThickness) ( rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), - rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1.0f, 100.0f }), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.5f, 20.0f }), rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) ) .property("max level", &CameraSSR::GetMaxLevel, &CameraSSR::SetMaxLevel) @@ -70,6 +80,12 @@ namespace MxEngine rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1, 4 }), rttr::metadata(EditorInfo::EDIT_PRECISION, 1) + ) + .property("maxStep", &CameraSSR::GetMaxStep, &CameraSSR::SetMaxStep) + ( + rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 150, 255 }), + rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) ); } } \ No newline at end of file diff --git a/src/Core/Components/Camera/CameraSSR.h b/src/Core/Components/Camera/CameraSSR.h index 366a5141c..09d5ea80f 100644 --- a/src/Core/Components/Camera/CameraSSR.h +++ b/src/Core/Components/Camera/CameraSSR.h @@ -36,17 +36,20 @@ namespace MxEngine { MAKE_COMPONENT(CameraSSR); - float thickness = 0.5f; - float maxLevel = 2.0f; + float thickness = 1.5f; + int maxLevel = 2; + int maxStep = 150; public: CameraSSR() = default; float GetThickness() const; int GetMaxLevel()const; + int GetMaxStep()const; void SetThickness(float thickness); void SetMaxLevel(int level); + void SetMaxStep(int step); }; } \ No newline at end of file diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 20468a8bd..004e9d37e 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -354,10 +354,12 @@ namespace MxEngine std::swap(input, output); } - void RenderController::GenerateDepthPyramid(TextureHandle& zBuffer, MxVector& HiZ) + void RenderController::GenerateDepthPyramid(CameraUnit& camera) { MAKE_RENDER_PASS_SCOPE("RenderController::GenerateDepthPyramid()"); auto& shader = this->Pipeline.Environment.Shaders["HIZ"_id]; + auto& zBuffer = camera.DepthTexture; + auto& HiZ = camera.HiZ; auto fGetTex = [&zBuffer, &HiZ](int layer)->TextureHandle& { @@ -367,6 +369,9 @@ namespace MxEngine return HiZ[layer - 1]; }; + int w = zBuffer->GetWidth(); + int h = zBuffer->GetHeight(); + Texture::Copy(zBuffer->GetNativeHandle(), camera.PackedDepth->GetNativeHandle(), 0, 0, w, h); for (int i = 0; i < HiZ.size(); i++) { shader->Bind(); @@ -374,6 +379,8 @@ namespace MxEngine auto& outputTex = fGetTex(i + 1); shader->SetUniform("uPreviousLevelRes", VectorInt2(outputTex->GetWidth(), outputTex->GetHeight())); this->RenderToTexture(outputTex, shader); + Texture::Copy(outputTex->GetNativeHandle(), camera.PackedDepth->GetNativeHandle(), 0, h, outputTex->GetWidth(), outputTex->GetHeight()); + h += outputTex->GetHeight(); } } @@ -665,15 +672,14 @@ namespace MxEngine void RenderController::ApplySSR(CameraUnit& camera, TextureHandle& input, TextureHandle& temporary, TextureHandle& output) { if (camera.SSR == nullptr ) return; - + int level = camera.SSR->GetMaxLevel(); #if defined(MXENGINE_PROFILING_ENABLED) auto profilerTitle = MxFormat("RenderController::ApplySSR(level={})", level); MAKE_RENDER_PASS_SCOPE(profilerTitle.c_str()); #endif - - auto& SSRShader = this->Pipeline.Environment.Shaders["SSR"_id]; - SSRShader->Bind(); + auto& SSRShader = this->Pipeline.Environment.Shaders["SSR"_id]; + SSRShader->Bind(); SSRShader->IgnoreNonExistingUniform("albedoTex"); SSRShader->IgnoreNonExistingUniform("materialTex"); @@ -686,7 +692,8 @@ namespace MxEngine SSRShader->SetUniform("thickness", camera.SSR->GetThickness()); SSRShader->SetUniform("screenResolution", Vector2(camera.HDRTexture->GetWidth(), camera.HDRTexture->GetHeight())); - SSRShader->SetUniform("maxLevel", level); + SSRShader->SetUniform("maxLevel", level); + SSRShader->SetUniform("maxStep", camera.SSR->GetMaxStep()); this->RenderToTexture(temporary, SSRShader); @@ -1075,11 +1082,16 @@ namespace MxEngine void RenderController::BindHiZ(const CameraUnit& camera, const Shader& shader, Texture::TextureBindId& startId) { - for(int i=0;iBind(startId++); + shader.SetUniform("depthPyramid", camera.PackedDepth->GetBoundId()); + + int h = camera.DepthTexture->GetHeight(); + glm::ivec2 basePositions(0,0); + for (int i = 0; i < 5; i++) { - auto& it = camera.HiZ[i]; - it->Bind(startId++); - shader.SetUniform(MxFormat("hiZTex{}", i), it->GetBoundId()); + shader.SetUniform(MxFormat("basePositions[{}]", i), basePositions); + basePositions = basePositions + glm::ivec2(0, h); + h /= 2; } } @@ -1514,6 +1526,7 @@ namespace MxEngine camera.SSRMaskTexture = cameraController.GetSSRMask(); camera.DepthTexture = cameraController.GetDepthTexture(); camera.HiZ = cameraController.GetHiZ(); + camera.PackedDepth = cameraController.GetPackedDepth(); camera.AverageWhiteTexture = cameraController.GetAverageWhiteTexture(); camera.HDRTexture = cameraController.GetHDRTexture(); camera.SwapTexture1 = cameraController.GetSwapHDRTexture1(); @@ -1669,7 +1682,7 @@ namespace MxEngine this->DrawObjects(camera, *this->Pipeline.Environment.Shaders["GBuffer"_id], this->Pipeline.OpaqueObjects); this->DrawObjects(camera, *this->Pipeline.Environment.Shaders["GBufferMask"_id], this->Pipeline.MaskedObjects); - this->GenerateDepthPyramid(camera.DepthTexture, camera.HiZ); + this->GenerateDepthPyramid(camera); this->DrawParticles(camera, this->Pipeline.OpaqueParticleSystems, *this->Pipeline.Environment.Shaders["ParticleOpaque"_id]); @@ -1694,4 +1707,3 @@ namespace MxEngine this->AttachDefaultVAO(); } } - diff --git a/src/Core/Rendering/RenderController.h b/src/Core/Rendering/RenderController.h index 5e0cefbce..190dd0efd 100644 --- a/src/Core/Rendering/RenderController.h +++ b/src/Core/Rendering/RenderController.h @@ -62,7 +62,7 @@ namespace MxEngine void DrawObject(const RenderUnit& unit, size_t instanceCount, size_t baseInstance, const Shader& shader); void ComputeBloomEffect(CameraUnit& camera, const TextureHandle& output); TextureHandle ComputeAverageWhite(CameraUnit& camera); - void GenerateDepthPyramid(TextureHandle& zBuffer, MxVector& HiZ); + void GenerateDepthPyramid(CameraUnit& camera); void PerformPostProcessing(CameraUnit& camera); void PerformLightPass(CameraUnit& camera); void DrawTransparentObjects(CameraUnit& camera); diff --git a/src/Core/Rendering/RenderPipeline.h b/src/Core/Rendering/RenderPipeline.h index 3009b0142..002201f44 100644 --- a/src/Core/Rendering/RenderPipeline.h +++ b/src/Core/Rendering/RenderPipeline.h @@ -64,6 +64,7 @@ namespace MxEngine TextureHandle DepthTexture; TextureHandle SSRMaskTexture; MxVector< TextureHandle> HiZ; + TextureHandle PackedDepth; TextureHandle AverageWhiteTexture; TextureHandle HDRTexture; TextureHandle SwapTexture1; diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index f09317209..20c3ff860 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -1,3 +1,6 @@ + + + #include "Library/fragment_utils.glsl" in vec2 TexCoord; @@ -9,11 +12,7 @@ uniform sampler2D materialTex; uniform sampler2D depthTex; uniform sampler2D ssrMask; uniform sampler2D HDRTex; -uniform sampler2D hiZTex0; -uniform sampler2D hiZTex1; -uniform sampler2D hiZTex2; -uniform sampler2D hiZTex3; -//add more levels here +uniform sampler2D depthPyramid; uniform Camera camera; uniform EnvironmentInfo environment; @@ -21,18 +20,14 @@ uniform EnvironmentInfo environment; uniform float thickness; uniform vec2 screenResolution; uniform int maxLevel; +uniform int maxStep; +uniform ivec2 basePositions[5]; float sampleDepth(ivec2 uv, int level) { - switch (level) - { - case 0:return texelFetch(depthTex, uv, 0).r; - case 1:return texelFetch(hiZTex0, uv / ivec2(2), 0).r; - case 2:return texelFetch(hiZTex1, uv / ivec2(4), 0).r; - case 3:return texelFetch(hiZTex2, uv / ivec2(8), 0).r; - case 4:return texelFetch(hiZTex3, uv / ivec2(16), 0).r; - //Add more levels here - } + ivec2 div = ivec2(1 << level); + ivec2 base = basePositions[level]; + return texelFetch(depthPyramid, base + uv / div, 0).r; } vec3 transform(mat4 m, vec3 p) @@ -60,14 +55,14 @@ void swapComp(inout vec2 v) void main() { - if(texelFetch(ssrMask,ivec2(gl_FragCoord.xy),0).r<0.5) - { - OutColor = vec4(0.0); - return; - } + if (texelFetch(ssrMask, ivec2(gl_FragCoord.xy), 0).r < 0.5) + { + OutColor = vec4(0.0); + return; + } FragmentInfo fragment = getFragmentInfo( TexCoord, albedoTex, normalTex, materialTex, depthTex, camera.invViewProjMatrix); - float rayLength = 8000.f;//long enough for any screen + float rayLength = 1000.f;//long enough for any screen vec3 viewDistance = camera.position - fragment.position; vec3 viewDirection = normalize(viewDistance); @@ -84,7 +79,7 @@ void main() vec4 ho1 = transform(camera.projectionMatrix, vec4(vp1, 1.0)); float w0 = 1.0 / ho0.w; - float w1 = 1.0 / ho1.w; + float w1 = 1.0 / ho1.w; //to avoid nonlinearity,project to view space vec3 vpProj0 = vp0 * w0; vec3 vpProj1 = vp1 * w1; @@ -113,7 +108,7 @@ void main() vec3 dVpProj = (vpProj1 - vpProj0) * invDx; float dw = (w1 - w0) * invDx; vec2 dScr = vec2(stepDir, delta.y * invDx); - + //Start position scr0 += dScr; vpProj0 += dVpProj; @@ -124,10 +119,8 @@ void main() bool isHit = false; bool checkthickness = false; int level = 0; - float testStp = 0.0; - int maxStp = int(sqrt(screenResolution.x * screenResolution.x + screenResolution.y * screenResolution.y)); - //Todo: /(ㄒoㄒ)/~~ Handle diffuse lobe. Sampling more rays or using cone tracing when the BRDF lobe is fat. - for (int curStep = 0; curStep < maxStp; curStep++, testStp++) + //Todo: /(ㄒoㄒ)/~~ Handle diffuse lobe. Sampling more rays or using cone tracing when the BRDF lobe is fat. + for (int curStep = 0; curStep < maxStep; curStep++) { //reconstruct camera space ray depth result.xy = permute ? scr0.yx : scr0; diff --git a/src/Platform/OpenGL/Texture.cpp b/src/Platform/OpenGL/Texture.cpp index 4a6f91dea..e4e6b6830 100644 --- a/src/Platform/OpenGL/Texture.cpp +++ b/src/Platform/OpenGL/Texture.cpp @@ -243,6 +243,12 @@ namespace MxEngine this->Load(image.GetRawData(), (int)image.GetWidth(), (int)image.GetHeight(), (int)image.GetChannelCount(), image.IsFloatingPoint(), format); } + void Texture::Copy(TextureBindId src, TextureBindId dst, int x, int y, int w, int h) + { + GLCALL(glCopyImageSubData(src, GL_TEXTURE_2D, 0, 0, 0, 0, + dst, GL_TEXTURE_2D, 0, x, y, 0, w, h,1)); + } + void Texture::LoadDepth(int width, int height, TextureFormat format) { this->filepath = MXENGINE_MAKE_INTERNAL_TAG("depth"); diff --git a/src/Platform/OpenGL/Texture.h b/src/Platform/OpenGL/Texture.h index 0602fe4ce..b9e03ff06 100644 --- a/src/Platform/OpenGL/Texture.h +++ b/src/Platform/OpenGL/Texture.h @@ -110,6 +110,7 @@ namespace MxEngine void Load(RawDataPointer data, int width, int height, int channels, bool isFloating, TextureFormat format = TextureFormat::RGB); void Load(const Image& image, TextureFormat format = TextureFormat::RGB); + static void Copy(TextureBindId src, TextureBindId dst, int x, int y, int w, int h); void LoadDepth(int width, int height, TextureFormat format = TextureFormat::DEPTH); void SetMaxLOD(size_t lod); void SetMinLOD(size_t lod); From 26240b51b06cf64f826d1cbd3cab83faf0c06433 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 31 Mar 2024 04:28:13 +0800 Subject: [PATCH 42/48] remove unused header --- src/Core/Components/Camera/CameraController.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index f5a3829c0..9c28b6474 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -36,7 +36,6 @@ #include "PerspectiveCamera.h" #include "FrustrumCamera.h" #include "Core/Runtime/Reflection.h" -#include "fmt/format.h" namespace MxEngine { From 31f9980295f16600537d9711dda4a1e1f9f30fb9 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 31 Mar 2024 04:29:31 +0800 Subject: [PATCH 43/48] .f => .0 --- .../OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl b/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl index 7d8272a94..72a7c9e84 100644 --- a/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl +++ b/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl @@ -42,5 +42,5 @@ void main() maxDepth = max(maxDepth, max(row.x, row.y)); } - OutColor = vec4(maxDepth,0.f,0.f,1.f); + OutColor = vec4(maxDepth, 0.0, 0.0, 1.0); } From 674f64a9dbfbdb45206c841257834d07b4541473 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 31 Mar 2024 04:31:34 +0800 Subject: [PATCH 44/48] if else => ? : --- src/Platform/OpenGL/Texture.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Platform/OpenGL/Texture.cpp b/src/Platform/OpenGL/Texture.cpp index e4e6b6830..3ca3ef7ba 100644 --- a/src/Platform/OpenGL/Texture.cpp +++ b/src/Platform/OpenGL/Texture.cpp @@ -205,10 +205,7 @@ namespace MxEngine switch (channels) { case 1: - if (format != TextureFormat::R32F) - dataChannels = GL_RED; - else - dataChannels = GL_RED_EXT; + dataChannels = (format == TextureFormat::R32F) ? GL_RED_EXT : GL_RED; break; case 2: dataChannels = GL_RG; From 9daaa01e970ff7d5012dfddf9d1ac284ea23e004 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 31 Mar 2024 14:22:52 +0800 Subject: [PATCH 45/48] fix warnings --- src/Core/Rendering/RenderController.cpp | 37 +++++++++++++++++++++++++ src/Platform/OpenGL/Texture.cpp | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 004e9d37e..f23906fe6 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -223,6 +223,9 @@ namespace MxEngine shader.IgnoreNonExistingUniform("camera.position"); shader.IgnoreNonExistingUniform("camera.invViewProjMatrix"); shader.IgnoreNonExistingUniform("material.transparency"); + shader.IgnoreNonExistingUniform("camera.viewMatrix"); + shader.IgnoreNonExistingUniform("camera.projectionMatrix"); + shader.IgnoreNonExistingUniform("camera.invProjectionMatrix"); this->BindCameraInformation(camera, shader); shader.SetUniform("gamma", camera.Gamma); @@ -324,6 +327,9 @@ namespace MxEngine ssaoShader->IgnoreNonExistingUniform("materialTex"); ssaoShader->IgnoreNonExistingUniform("albedoTex"); ssaoShader->IgnoreNonExistingUniform("camera.position"); + ssaoShader->IgnoreNonExistingUniform("camera.viewMatrix"); + ssaoShader->IgnoreNonExistingUniform("camera.projectionMatrix"); + ssaoShader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); Texture::TextureBindId textureId = 0; this->BindGBuffer(camera, *ssaoShader, textureId); @@ -458,6 +464,9 @@ namespace MxEngine shader->IgnoreNonExistingUniform("camera.viewProjMatrix"); shader->IgnoreNonExistingUniform("camera.position"); + shader->IgnoreNonExistingUniform("camera.viewMatrix"); + shader->IgnoreNonExistingUniform("camera.projectionMatrix"); + shader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); shader->IgnoreNonExistingUniform("albedoTex"); shader->IgnoreNonExistingUniform("materialTex"); @@ -543,6 +552,9 @@ namespace MxEngine auto shader = this->Pipeline.Environment.Shaders["IBL"_id]; shader->Bind(); shader->IgnoreNonExistingUniform("camera.viewProjMatrix"); + shader->IgnoreNonExistingUniform("camera.viewMatrix"); + shader->IgnoreNonExistingUniform("camera.projectionMatrix"); + shader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); Texture::TextureBindId textureId = 0; this->BindGBuffer(camera, *shader, textureId); @@ -595,6 +607,9 @@ namespace MxEngine auto godRayShader = this->Pipeline.Environment.Shaders["GodRay"_id]; godRayShader->Bind(); godRayShader->IgnoreNonExistingUniform("camera.viewProjMatrix"); + godRayShader->IgnoreNonExistingUniform("camera.viewMatrix"); + godRayShader->IgnoreNonExistingUniform("camera.projectionMatrix"); + godRayShader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); godRayShader->IgnoreNonExistingUniform("normalTex"); godRayShader->IgnoreNonExistingUniform("albedoTex"); godRayShader->IgnoreNonExistingUniform("materialTex"); @@ -632,6 +647,9 @@ namespace MxEngine auto fogShader = this->Pipeline.Environment.Shaders["Fog"_id]; fogShader->Bind(); fogShader->IgnoreNonExistingUniform("camera.viewProjMatrix"); + fogShader->IgnoreNonExistingUniform("camera.viewMatrix"); + fogShader->IgnoreNonExistingUniform("camera.projectionMatrix"); + fogShader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); fogShader->IgnoreNonExistingUniform("normalTex"); fogShader->IgnoreNonExistingUniform("albedoTex"); fogShader->IgnoreNonExistingUniform("materialTex"); @@ -682,6 +700,7 @@ namespace MxEngine SSRShader->Bind(); SSRShader->IgnoreNonExistingUniform("albedoTex"); SSRShader->IgnoreNonExistingUniform("materialTex"); + SSRShader->IgnoreNonExistingUniform("camera.viewProjMatrix"); Texture::TextureBindId textureId = 0; this->BindGBuffer(camera, *SSRShader, textureId); @@ -726,6 +745,9 @@ namespace MxEngine SSGIShader->IgnoreNonExistingUniform("normalTex"); SSGIShader->IgnoreNonExistingUniform("materialTex"); SSGIShader->IgnoreNonExistingUniform("camera.position"); + SSGIShader->IgnoreNonExistingUniform("camera.viewMatrix"); + SSGIShader->IgnoreNonExistingUniform("camera.projectionMatrix"); + SSGIShader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); Texture::TextureBindId textureId = 0; this->BindGBuffer(camera, *SSGIShader, textureId); @@ -772,6 +794,9 @@ namespace MxEngine auto cocShader = this->Pipeline.Environment.Shaders["COC"_id]; cocShader->Bind(); + cocShader->IgnoreNonExistingUniform("camera.viewMatrix"); + cocShader->IgnoreNonExistingUniform("camera.projectionMatrix"); + cocShader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); cocShader->IgnoreNonExistingUniform("camera.viewProjMatrix"); cocShader->IgnoreNonExistingUniform("normalTex"); cocShader->IgnoreNonExistingUniform("albedoTex"); @@ -889,6 +914,9 @@ namespace MxEngine auto shader = this->Pipeline.Environment.Shaders["SpotLightShadow"_id]; shader->Bind(); shader->IgnoreNonExistingUniform("camera.position"); + shader->IgnoreNonExistingUniform("camera.viewMatrix"); + shader->IgnoreNonExistingUniform("camera.projectionMatrix"); + shader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); shader->IgnoreNonExistingUniform("albedoTex"); shader->IgnoreNonExistingUniform("materialTex"); @@ -932,6 +960,9 @@ namespace MxEngine auto shader = this->Pipeline.Environment.Shaders["PointLightShadow"_id]; shader->Bind(); shader->IgnoreNonExistingUniform("camera.position"); + shader->IgnoreNonExistingUniform("camera.viewMatrix"); + shader->IgnoreNonExistingUniform("camera.projectionMatrix"); + shader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); shader->IgnoreNonExistingUniform("albedoTex"); shader->IgnoreNonExistingUniform("materialTex"); @@ -972,6 +1003,9 @@ namespace MxEngine auto shader = this->Pipeline.Environment.Shaders["PointLightNonShadow"_id]; shader->Bind(); shader->IgnoreNonExistingUniform("camera.position"); + shader->IgnoreNonExistingUniform("camera.viewMatrix"); + shader->IgnoreNonExistingUniform("camera.projectionMatrix"); + shader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); shader->IgnoreNonExistingUniform("albedoTex"); shader->IgnoreNonExistingUniform("materialTex"); auto viewportSize = MakeVector2((float)camera.OutputTexture->GetWidth(), (float)camera.OutputTexture->GetHeight()); @@ -1002,6 +1036,9 @@ namespace MxEngine auto shader = this->Pipeline.Environment.Shaders["SpotLightNonShadow"_id]; shader->Bind(); + shader->IgnoreNonExistingUniform("camera.viewMatrix"); + shader->IgnoreNonExistingUniform("camera.projectionMatrix"); + shader->IgnoreNonExistingUniform("camera.invProjectionMatrix"); shader->IgnoreNonExistingUniform("camera.position"); shader->IgnoreNonExistingUniform("albedoTex"); shader->IgnoreNonExistingUniform("materialTex"); diff --git a/src/Platform/OpenGL/Texture.cpp b/src/Platform/OpenGL/Texture.cpp index 3ca3ef7ba..82ac81c87 100644 --- a/src/Platform/OpenGL/Texture.cpp +++ b/src/Platform/OpenGL/Texture.cpp @@ -243,7 +243,7 @@ namespace MxEngine void Texture::Copy(TextureBindId src, TextureBindId dst, int x, int y, int w, int h) { GLCALL(glCopyImageSubData(src, GL_TEXTURE_2D, 0, 0, 0, 0, - dst, GL_TEXTURE_2D, 0, x, y, 0, w, h,1)); + dst, GL_TEXTURE_2D, 0, x, y, 0, w, h, 1)); } void Texture::LoadDepth(int width, int height, TextureFormat format) From 87f009ff658478057da56e47c6c31c3d31550a73 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 31 Mar 2024 14:59:22 +0800 Subject: [PATCH 46/48] Remove unused lines --- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index 20c3ff860..042f14eb1 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -1,6 +1,3 @@ - - - #include "Library/fragment_utils.glsl" in vec2 TexCoord; From 18de0ccd9f0ea6fe70485babd1363fa4a3d6dc76 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sun, 31 Mar 2024 15:17:07 +0800 Subject: [PATCH 47/48] Fix format and adjust param --- src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl | 2 +- .../Shaders/hierarchical_depth_buffer_generator.glsl | 10 +++++----- src/Platform/OpenGL/Shaders/ssr_fragment.glsl | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl index 16e882331..9497c8013 100644 --- a/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/gbuffer_fragment.glsl @@ -70,5 +70,5 @@ void main() OutAlbedo = vec4(fsin.RenderColor * albedo, emmisive / (emmisive + 1.0f)); OutNormal = vec4(0.5f * normal + 0.5f, 1.0f); OutMaterial = vec4(parallaxOcclusion * occlusion, roughness, metallic, 1.0f); - OutSSRMask = vec4(receiveSSR,vec3(1.0)); + OutSSRMask = vec4(receiveSSR, vec3(1.0)); } \ No newline at end of file diff --git a/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl b/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl index 72a7c9e84..62dbc8065 100644 --- a/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl +++ b/src/Platform/OpenGL/Shaders/hierarchical_depth_buffer_generator.glsl @@ -9,15 +9,15 @@ void main() ivec2 lastTexCoord = 2 * currentTexCoord; vec4 depth; - depth.x = texelFetch(depthBuffer,lastTexCoord, 0).r; + depth.x = texelFetch(depthBuffer, lastTexCoord, 0).r; depth.y = texelFetch(depthBuffer, lastTexCoord + ivec2(1, 0), 0).r; - depth.z = texelFetch(depthBuffer,lastTexCoord + ivec2(1, 1),0).r; - depth.w = texelFetch(depthBuffer,lastTexCoord + ivec2(0, 1), 0).r; + depth.z = texelFetch(depthBuffer, lastTexCoord + ivec2(1, 1),0).r; + depth.w = texelFetch(depthBuffer, lastTexCoord + ivec2(0, 1), 0).r; //Depth is reversed.The closer to the object the higher depth we get. //So instead of min pooling we perform max pooling. - float maxDepth = max(max(depth.x, depth.y), - max(depth.z, depth.w)); + float maxDepth = max( max(depth.x, depth.y), + max(depth.z, depth.w)); bool extraCol = ((uPreviousLevelRes.x & 1) != 0); bool extraRow = ((uPreviousLevelRes.y & 1) != 0); diff --git a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl index 042f14eb1..4d6d41030 100644 --- a/src/Platform/OpenGL/Shaders/ssr_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/ssr_fragment.glsl @@ -59,8 +59,8 @@ void main() } FragmentInfo fragment = getFragmentInfo( TexCoord, albedoTex, normalTex, materialTex, depthTex, camera.invViewProjMatrix); - float rayLength = 1000.f;//long enough for any screen - + float rayLength = 4000.f; + vec3 viewDistance = camera.position - fragment.position; vec3 viewDirection = normalize(viewDistance); vec3 reflectDirection = normalize(reflect(-viewDirection, fragment.normal)); From 56fe9fd4b4c485f973c6ccc0298dab1602087503 Mon Sep 17 00:00:00 2001 From: fall2019 <53587145+fall2019@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:59:43 +0800 Subject: [PATCH 48/48] change depth map packing algo --- .../Components/Camera/CameraController.cpp | 4 +--- src/Core/Rendering/RenderController.cpp | 23 ++++++++++--------- src/Core/Rendering/RenderPipeline.h | 1 + 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index 9c28b6474..5c766c64d 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -522,20 +522,18 @@ namespace MxEngine this->Depth->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera depth")); this->Depth->SetWrapType(TextureWrap::CLAMP_TO_EDGE); - int packedHeight = height; for (int i = 0; i < this->HiZ.size(); i++) { int scale = 1 << (i + 1); MxString tag = MxFormat("!camera depth lv{}", i + 1); int w = width / scale; int h = height / scale; - packedHeight += h; this->HiZ[i]->Load(nullptr, w, h, 1, false, TextureFormat::R32F); this->HiZ[i]->SetInternalEngineTag(tag); this->HiZ[i]->SetWrapType(TextureWrap::CLAMP_TO_EDGE); } - this->PackedDepthMap->Load(nullptr, width, packedHeight, 1, false, TextureFormat::R32F); + this->PackedDepthMap->Load(nullptr, width, height * 1.5, 1, false, TextureFormat::R32F); this->PackedDepthMap->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("packed depth map")); this->PackedDepthMap->SetWrapType(TextureWrap::CLAMP_TO_EDGE); diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index f23906fe6..dcb3d7ce9 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -378,15 +378,22 @@ namespace MxEngine int w = zBuffer->GetWidth(); int h = zBuffer->GetHeight(); Texture::Copy(zBuffer->GetNativeHandle(), camera.PackedDepth->GetNativeHandle(), 0, 0, w, h); + w = h = 0; + camera.PackedDepthOrigins[0] = { 0.0,0.0 }; for (int i = 0; i < HiZ.size(); i++) { shader->Bind(); - fGetTex(i)->Bind(0); + auto& inputTex = fGetTex(i); + inputTex->Bind(0); auto& outputTex = fGetTex(i + 1); shader->SetUniform("uPreviousLevelRes", VectorInt2(outputTex->GetWidth(), outputTex->GetHeight())); this->RenderToTexture(outputTex, shader); - Texture::Copy(outputTex->GetNativeHandle(), camera.PackedDepth->GetNativeHandle(), 0, h, outputTex->GetWidth(), outputTex->GetHeight()); - h += outputTex->GetHeight(); + if (i & 1) + w += inputTex->GetWidth(); + else + h += inputTex->GetHeight(); + camera.PackedDepthOrigins[i + 1] = { w,h }; + Texture::Copy(outputTex->GetNativeHandle(), camera.PackedDepth->GetNativeHandle(), w, h, outputTex->GetWidth(), outputTex->GetHeight()); } } @@ -1122,14 +1129,8 @@ namespace MxEngine camera.PackedDepth->Bind(startId++); shader.SetUniform("depthPyramid", camera.PackedDepth->GetBoundId()); - int h = camera.DepthTexture->GetHeight(); - glm::ivec2 basePositions(0,0); - for (int i = 0; i < 5; i++) - { - shader.SetUniform(MxFormat("basePositions[{}]", i), basePositions); - basePositions = basePositions + glm::ivec2(0, h); - h /= 2; - } + for (int i = 0; i < camera.PackedDepthOrigins.size(); i++) + shader.SetUniform(MxFormat("basePositions[{}]", i), camera.PackedDepthOrigins[i]); } const Renderer& RenderController::GetRenderEngine() const diff --git a/src/Core/Rendering/RenderPipeline.h b/src/Core/Rendering/RenderPipeline.h index 002201f44..918a84a45 100644 --- a/src/Core/Rendering/RenderPipeline.h +++ b/src/Core/Rendering/RenderPipeline.h @@ -65,6 +65,7 @@ namespace MxEngine TextureHandle SSRMaskTexture; MxVector< TextureHandle> HiZ; TextureHandle PackedDepth; + std::array PackedDepthOrigins; TextureHandle AverageWhiteTexture; TextureHandle HDRTexture; TextureHandle SwapTexture1;