Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2c6790b
temp
fall2019 Mar 7, 2024
811be9b
Merge branch 'hierarchical_z_buffer' of https://github.com/asc-commun…
fall2019 Mar 9, 2024
f300418
max pooling
fall2019 Mar 9, 2024
e9079f9
prototype
fall2019 Mar 9, 2024
bd815fe
formatting
fall2019 Mar 9, 2024
c7830c0
add intensity
fall2019 Mar 9, 2024
38042e8
add mask
fall2019 Mar 10, 2024
64a1433
Delete samples/Sponza/Engine/Models/cube_2.obj
fall2019 Mar 10, 2024
f0739ec
Delete samples/Sponza/Engine/Models/plane_2.obj
fall2019 Mar 10, 2024
37d54d0
Delete samples/Sponza/Engine/Models/sphere_4.obj
fall2019 Mar 10, 2024
abda4e1
Delete samples/Sponza/sponza2.json
fall2019 Mar 10, 2024
f648672
edit user input and MD
fall2019 Mar 10, 2024
bb77182
Update MxApplication.cpp
fall2019 Mar 10, 2024
880399d
Update MxApplication.cpp
fall2019 Mar 10, 2024
e69efab
Update MxApplication.cpp
fall2019 Mar 10, 2024
4dc13a5
Update ShaderBase.cpp
fall2019 Mar 10, 2024
ad91f57
move Camera to header file
fall2019 Mar 10, 2024
f580e27
Refactoring of shader compilation
fall2019 Mar 15, 2024
ad87f7a
move common include into fragment
fall2019 Mar 15, 2024
5bfe176
Merge branch 'shader_compilation_refactoring' of https://github.com/a…
fall2019 Mar 15, 2024
a23f3b4
fix merge issue
fall2019 Mar 15, 2024
d56ab0f
add more comments
fall2019 Mar 16, 2024
3a2b54e
Merge branch 'master' of https://github.com/asc-community/MxEngine in…
fall2019 Mar 16, 2024
3b5a878
Merge branch 'master' of https://github.com/asc-community/MxEngine in…
fall2019 Mar 16, 2024
ce55e24
Update dirlight_fragment.glsl
fall2019 Mar 16, 2024
0ce84e3
Update dirlight_fragment.glsl
fall2019 Mar 16, 2024
3ed9c3e
Update apply_ssr_fragment.glsl
fall2019 Mar 16, 2024
bca72a3
Update dirlight_fragment.glsl
fall2019 Mar 16, 2024
27f1651
Update gbuffer_vertex.glsl
fall2019 Mar 16, 2024
bd98982
Update dirlight_fragment.glsl
fall2019 Mar 16, 2024
2417abd
Update apply_ssr_fragment.glsl
fall2019 Mar 16, 2024
c93f9d3
sync master
fall2019 Mar 16, 2024
344b15e
use MxFormat
fall2019 Mar 20, 2024
b1d0805
getHiz() => const reference
fall2019 Mar 20, 2024
a086f16
avoid memory alloc
fall2019 Mar 20, 2024
2e7f66f
format
fall2019 Mar 20, 2024
5435b7b
fomat
fall2019 Mar 20, 2024
4112903
using float for bool param pass to shader
fall2019 Mar 20, 2024
32420d7
add more comments
fall2019 Mar 20, 2024
fa6c9c9
Remove intensity. Expose levels to editor.
fall2019 Mar 25, 2024
3404e4d
Fix artefacts
fall2019 Mar 29, 2024
cace588
using bit shift
fall2019 Mar 30, 2024
df24117
pack depth clips into one texture
fall2019 Mar 30, 2024
26240b5
remove unused header
fall2019 Mar 30, 2024
31f9980
.f => .0
fall2019 Mar 30, 2024
674f64a
if else => ? :
fall2019 Mar 30, 2024
9daaa01
fix warnings
fall2019 Mar 31, 2024
87f009f
Remove unused lines
fall2019 Mar 31, 2024
18de0cc
Fix format and adjust param
fall2019 Mar 31, 2024
56fe9fd
change depth map packing algo
fall2019 Apr 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- soon! [![Documentation](https://codedocs.xyz/MomoDeve/MxEngine.svg)](https://codedocs.xyz/MomoDeve/MxEngine/) -->

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)*
Expand Down Expand Up @@ -292,9 +292,8 @@ If you are interesed in libraries MxEngine depend on, consider reading [dependen
<i>shadow casting from dynamic lights, screen-space reflections</i>
</p>

## Special thanks
#### God Ray Effect by [#Fall2019](https://github.com/fall2019)
<img src="preview_images/readme_god_ray.PNG">
<i>god ray effect</i>
</p>

## Projects based on MxEngine
Expand Down
44 changes: 44 additions & 0 deletions src/Core/Components/Camera/CameraController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -425,11 +426,26 @@ namespace MxEngine
return this->renderBuffers->Material;
}

TextureHandle CameraController::GetSSRMask()const
{
return this->renderBuffers->SSRMask;
}

TextureHandle CameraController::GetDepthTexture() const
{
return this->renderBuffers->Depth;
}

const MxVector<TextureHandle>& CameraController::GetHiZ() const
{
return this->renderBuffers->HiZ;
}

const TextureHandle& CameraController::GetPackedDepth() const
{
return this->renderBuffers->PackedDepthMap;
}

TextureHandle CameraController::GetAverageWhiteTexture() const
{
return this->renderBuffers->AverageWhite;
Expand All @@ -456,23 +472,28 @@ namespace MxEngine
this->Albedo = Factory<Texture>::Create();
this->Normal = Factory<Texture>::Create();
this->Material = Factory<Texture>::Create();
this->SSRMask = Factory<Texture>::Create();
this->Depth = Factory<Texture>::Create();
this->AverageWhite = Factory<Texture>::Create();
this->HDR = Factory<Texture>::Create();
this->SwapHDR1 = Factory<Texture>::Create();
this->SwapHDR2 = Factory<Texture>::Create();
for (int i = 0; i < 4; i++) this->HiZ.emplace_back(Factory<Texture>::Create());
this->PackedDepthMap = Factory<Texture>::Create();

this->Resize(width, height);

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();
Expand All @@ -493,10 +514,29 @@ 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);

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;
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, height * 1.5, 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);
Expand All @@ -520,10 +560,14 @@ namespace MxEngine
Factory<Texture>::Destroy(this->Albedo);
Factory<Texture>::Destroy(this->Normal);
Factory<Texture>::Destroy(this->Material);
Factory<Texture>::Destroy(this->SSRMask);
Factory<Texture>::Destroy(this->Depth);
Factory<Texture>::Destroy(this->HDR);
Factory<Texture>::Destroy(this->SwapHDR1);
Factory<Texture>::Destroy(this->SwapHDR2);
for (auto& it : this->HiZ)
Factory<Texture>::Destroy(it);
Factory<Texture>::Destroy(this->PackedDepthMap);
}

MXENGINE_REFLECT_TYPE
Expand Down
6 changes: 6 additions & 0 deletions src/Core/Components/Camera/CameraController.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ namespace MxEngine
TextureHandle Normal;
TextureHandle Material;
TextureHandle Depth;
TextureHandle SSRMask;
MxVector<TextureHandle> HiZ;
TextureHandle PackedDepthMap;
TextureHandle AverageWhite;
TextureHandle HDR;
TextureHandle SwapHDR1;
Expand Down Expand Up @@ -130,7 +133,10 @@ namespace MxEngine
TextureHandle GetAlbedoTexture() const;
TextureHandle GetNormalTexture() const;
TextureHandle GetMaterialTexture() const;
TextureHandle GetSSRMask()const;
TextureHandle GetDepthTexture() const;
const MxVector<TextureHandle>& GetHiZ() const;
const TextureHandle& GetPackedDepth() const;
TextureHandle GetAverageWhiteTexture() const;
TextureHandle GetHDRTexture() const;
TextureHandle GetSwapHDRTexture1() const;
Expand Down
34 changes: 17 additions & 17 deletions src/Core/Components/Camera/CameraSSR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ namespace MxEngine
return this->thickness;
}

size_t CameraSSR::GetSteps() const
void CameraSSR::SetThickness(float thickness)
{
return this->steps;
this->thickness = Max(thickness, 1.0f);
}

float CameraSSR::GetStartDistance() const
int CameraSSR::GetMaxLevel() const
{
return this->startDistance;
return this->maxLevel;
}

void CameraSSR::SetThickness(float thickness)
void CameraSSR::SetMaxLevel(int level)
{
this->thickness = Max(thickness, 0.0f);
this->maxLevel = Clamp(level,1,4);
}

void CameraSSR::SetSteps(size_t steps)
int CameraSSR::GetMaxStep()const
{
this->steps = steps;
return this->maxStep;
}

void CameraSSR::SetStartDistance(float distance)
void CameraSSR::SetMaxStep(int step)
{
this->startDistance = Max(distance, 0.0f);
this->maxStep = Clamp(step,150,255);
}

MXENGINE_REFLECT_TYPE
{
rttr::registration::class_<CameraSSR>("CameraSSR")
Expand All @@ -72,19 +72,19 @@ 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 { 0.5f, 20.0f }),
rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f)
)
.property("steps", &CameraSSR::GetSteps, &CameraSSR::SetSteps)
.property("max level", &CameraSSR::GetMaxLevel, &CameraSSR::SetMaxLevel)
(
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)
rttr::metadata(EditorInfo::EDIT_RANGE, Range { 1, 4 }),
rttr::metadata(EditorInfo::EDIT_PRECISION, 1)
)
.property("start distance", &CameraSSR::GetStartDistance, &CameraSSR::SetStartDistance)
.property("maxStep", &CameraSSR::GetMaxStep, &CameraSSR::SetMaxStep)
(
rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE),
rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 10000000.0f }),
rttr::metadata(EditorInfo::EDIT_RANGE, Range { 150, 255 }),
rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f)
);
}
Expand Down
16 changes: 9 additions & 7 deletions src/Core/Components/Camera/CameraSSR.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ namespace MxEngine
{
MAKE_COMPONENT(CameraSSR);

float thickness = 0.5f;
size_t steps = 10;
float startDistance = 2.0f;
float thickness = 1.5f;
int maxLevel = 2;
int maxStep = 150;

public:
CameraSSR() = default;

float GetThickness() const;
size_t GetSteps() const;
float GetStartDistance() const;
int GetMaxLevel()const;
int GetMaxStep()const;

void SetThickness(float thickness);
void SetSteps(size_t steps);
void SetStartDistance(float distance);
void SetMaxLevel(int level);
void SetMaxStep(int step);

};
}
5 changes: 5 additions & 0 deletions src/Core/Rendering/RenderAdaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading