From 6a1ae5fac8b34750eed4bf9335abd66227219b14 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Mon, 20 Mar 2023 00:37:46 +0800 Subject: [PATCH] SSAO shader looks better on racoon now It still looks a little off but its better than before --- Assets/Shaders/SSAO_CS.glsl | 2 +- Assets/Shaders/SSAO_CS.shshaderb | Bin 6141 -> 6141 bytes .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 8 ++--- .../MiddleEnd/PostProcessing/SHSSAO.cpp | 33 +++++++++--------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Assets/Shaders/SSAO_CS.glsl b/Assets/Shaders/SSAO_CS.glsl index 42ab220c..7e818141 100644 --- a/Assets/Shaders/SSAO_CS.glsl +++ b/Assets/Shaders/SSAO_CS.glsl @@ -8,7 +8,7 @@ const int ROTATION_KERNEL_W = 4; const int ROTATION_KERNEL_H = 4; // can perhaps pass in as push constant. -const float RADIUS = 0.2f; +const float RADIUS = 0.35f; const float BIAS = 0.0025f; layout(local_size_x = 16, local_size_y = 16) in; diff --git a/Assets/Shaders/SSAO_CS.shshaderb b/Assets/Shaders/SSAO_CS.shshaderb index 36e627d6a0b8e6d8cca6f1d3a8ad43f81b987952..06438d5813d4d91106485135a01770dc3da1d9f3 100644 GIT binary patch delta 16 YcmeyX|5ty*UUp_<(VS_DEFAULT); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/PostProcessing/SHSSAO.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/PostProcessing/SHSSAO.cpp index db5b08c3..f71c3f93 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/PostProcessing/SHSSAO.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/PostProcessing/SHSSAO.cpp @@ -19,15 +19,16 @@ namespace SHADE // generate samples for (uint32_t i = 0; i < NUM_SAMPLES; ++i) { - //SHVec3 temp - //{ - // distrib(generator) * 2.0f - 1.0f, // -1.0f - 1.0f - // distrib(generator) * 2.0f - 1.0f, // -1.0f - 1.0f - // distrib(generator), // 0.0f - 1.0f so that sample space is a hemisphere - //}; + SHVec3 temp + { + distrib(generator) * 2.0f - 1.0f, // -1.0f - 1.0f + distrib(generator) * 2.0f - 1.0f, // -1.0f - 1.0f + distrib(generator), // 0.0f - 1.0f so that sample space is a hemisphere + }; - //temp = SHVec3::Normalise(temp); - //temp *= distrib(generator); + temp = SHVec3::Normalise(temp); + temp *= distrib(generator); + samples[i] = SHVec4 (temp.x, temp.y, temp.z, 0.0f); //// This makes sure that most points are closer to fragment's position //float scale = 1.0f / static_cast(NUM_SAMPLES); @@ -36,16 +37,16 @@ namespace SHADE //samples[i] = SHVec4 (temp.x, temp.y, temp.z, 0.0f); - samples[i] = SHVec4 - { - distrib(generator) * 2.0f - 1.0f, // -1.0f - 1.0f - distrib(generator) * 2.0f - 1.0f, // -1.0f - 1.0f - distrib(generator), // 0.0f - 1.0f so that sample space is a hemisphere - 0.0f - }; + //samples[i] = SHVec4 + //{ + // distrib(generator) * 2.0f - 1.0f, // -1.0f - 1.0f + // distrib(generator) * 2.0f - 1.0f, // -1.0f - 1.0f + // distrib(generator), // 0.0f - 1.0f so that sample space is a hemisphere + // 0.0f + //}; // This makes sure that most points are closer to fragment's position - float scale = 1.0f / static_cast(NUM_SAMPLES); + float scale = static_cast(i) / static_cast(NUM_SAMPLES); scale = std::lerp(0.1f, 1.0f, scale * scale); samples[i] *= scale; }