diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Gal.hpp | 3 | ||||
-rw-r--r-- | src/GalOgl.cpp | 30 | ||||
-rw-r--r-- | src/RenderConfigs.cpp | 19 |
3 files changed, 42 insertions, 10 deletions
diff --git a/src/Gal.hpp b/src/Gal.hpp index 0aa61c7..ed0b559 100644 --- a/src/Gal.hpp +++ b/src/Gal.hpp @@ -61,7 +61,10 @@ namespace Gal { enum class Format { D24S8, + R8, + R8G8, R8G8B8, + R8G8B8SN, R8G8B8A8, R32G32B32A32F, }; diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp index 94c2146..b046d4b 100644 --- a/src/GalOgl.cpp +++ b/src/GalOgl.cpp @@ -358,8 +358,14 @@ size_t GalFormatGetSize(Format format) { switch (format) { case Format::D24S8: return 4; + case Format::R8: + return 1; + case Format::R8G8: + return 2; case Format::R8G8B8: return 3; + case Format::R8G8B8SN: + return 3; case Format::R8G8B8A8: return 4; case Format::R32G32B32A32F: @@ -374,8 +380,14 @@ GLenum GalFormatGetGlLinearInternalFormat(Format format) { switch (format) { case Format::D24S8: return GL_DEPTH24_STENCIL8; + case Format::R8: + return GL_R8; + case Format::R8G8: + return GL_RG8; case Format::R8G8B8: return GL_RGB8; + case Format::R8G8B8SN: + return GL_RGB8_SNORM; case Format::R8G8B8A8: return GL_RGBA8; case Format::R32G32B32A32F: @@ -390,8 +402,14 @@ GLenum GalFormatGetGlInternalFormat(Format format) { switch (format) { case Format::D24S8: return 0; + case Format::R8: + return 0; + case Format::R8G8: + return 0; case Format::R8G8B8: return GL_SRGB; + case Format::R8G8B8SN: + return 0; case Format::R8G8B8A8: return GL_SRGB_ALPHA; case Format::R32G32B32A32F: @@ -406,8 +424,14 @@ GLenum GalFormatGetGlFormat(Format format) { switch (format) { case Format::D24S8: return GL_DEPTH_STENCIL; + case Format::R8: + return GL_RED; + case Format::R8G8: + return GL_RG; case Format::R8G8B8: return GL_RGB; + case Format::R8G8B8SN: + return GL_RGB; case Format::R8G8B8A8: return GL_RGBA; case Format::R32G32B32A32F: @@ -422,8 +446,14 @@ GLenum GalFormatGetGlType(Format format) { switch (format) { case Format::D24S8: return GL_UNSIGNED_INT_24_8; + case Format::R8: + return GL_UNSIGNED_BYTE; + case Format::R8G8: + return GL_UNSIGNED_BYTE; case Format::R8G8B8: return GL_UNSIGNED_BYTE; + case Format::R8G8B8SN: + return GL_BYTE; case Format::R8G8B8A8: return GL_UNSIGNED_BYTE; case Format::R32G32B32A32F: diff --git a/src/RenderConfigs.cpp b/src/RenderConfigs.cpp index 8cc4ee1..43342bb 100644 --- a/src/RenderConfigs.cpp +++ b/src/RenderConfigs.cpp @@ -178,12 +178,12 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int s colorConf->SetMaxFilter(Gal::Filtering::Bilinear); color = gal->BuildTexture(colorConf); - auto normalConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R32G32B32A32F); + auto normalConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8SN); normalConf->SetMinFilter(Gal::Filtering::Bilinear); normalConf->SetMaxFilter(Gal::Filtering::Bilinear); normal = gal->BuildTexture(normalConf); - auto lightConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8); + auto lightConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8); lightConf->SetMinFilter(Gal::Filtering::Bilinear); lightConf->SetMaxFilter(Gal::Filtering::Bilinear); light = gal->BuildTexture(lightConf); @@ -203,7 +203,7 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int s geomFramebuffer->SetViewport(0, 0, geomW, geomH); if (ssaoSamples > 0) { - auto noiseConf = gal->CreateTexture2DConfig(4, 4, Gal::Format::R32G32B32A32F); + auto noiseConf = gal->CreateTexture2DConfig(4, 4, Gal::Format::R8G8B8SN); noiseConf->SetWrapping(Gal::Wrapping::Repeat); noiseConf->SetMinFilter(Gal::Filtering::Bilinear); noiseConf->SetMaxFilter(Gal::Filtering::Bilinear); @@ -211,12 +211,11 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int s std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count()); std::uniform_real_distribution<> dis(-1.0f, 1.0f); - std::vector<glm::vec4> noiseTexData(16); + std::vector<glm::i8vec3> noiseTexData(16); for (auto& vec : noiseTexData) { - vec.x = dis(rng); - vec.y = dis(rng); + vec.x = static_cast<int8_t>(dis(rng) * 128.0f); + vec.y = static_cast<int8_t>(dis(rng) * 128.0f); vec.z = 0.0f; - vec.w = 0.0f; } ssaoNoise->SetData({ reinterpret_cast<std::byte*>(noiseTexData.data()), reinterpret_cast<std::byte*>(noiseTexData.data() + noiseTexData.size()) }); @@ -235,7 +234,7 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int s ssaoParameters, ssaoW, ssaoH, - Gal::Format::R8G8B8A8, + Gal::Format::R8, Gal::Filtering::Bilinear); ssaoPass->SetShaderParameter("ssaoSamples", ssaoSamples); @@ -253,7 +252,7 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int s ssaoBlurParameters, ssaoW, ssaoH, - Gal::Format::R8G8B8A8, + Gal::Format::R8, Gal::Filtering::Bilinear); ssaoBlurPass->SetShaderParameter("blurScale", 2); @@ -279,7 +278,7 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int s lightingParameters, lightW, lightH, - Gal::Format::R8G8B8A8, + Gal::Format::R8G8B8, Gal::Filtering::Bilinear); lightingPass->SetShaderParameter("applySsao", ssaoSamples); |