summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-11-21 13:49:23 +0100
committerLaG1924 <lag1924@gmail.com>2021-11-21 15:23:37 +0100
commit0ca11f9bee1cd918acf6ce8247a495442009fec9 (patch)
treed1e791cf44770660eca6783bc3e9c0a2470b7efb /src
parentAdded normals to faces (diff)
downloadAltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.gz
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.bz2
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.lz
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.xz
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.zst
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.zip
Diffstat (limited to 'src')
-rw-r--r--src/GalOgl.cpp5
-rw-r--r--src/Render.cpp4
-rw-r--r--src/RenderConfigs.cpp27
-rw-r--r--src/RenderConfigs.hpp10
-rw-r--r--src/RendererWorld.cpp1
-rw-r--r--src/RendererWorld.hpp2
6 files changed, 44 insertions, 5 deletions
diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp
index c250539..75369ab 100644
--- a/src/GalOgl.cpp
+++ b/src/GalOgl.cpp
@@ -1256,6 +1256,11 @@ struct ImplOgl : public Impl {
size_t attribSize = GalTypeGetSize(type);
for (size_t i = 0; i < count; i++) {
+ if (location < 0) {
+ vertexSize += attribSize;
+ continue;
+ }
+
pipeline->vertexBindCmds.push_back({
bufferId,
static_cast<size_t>(location + i),
diff --git a/src/Render.cpp b/src/Render.cpp
index 96c1ed8..48114b0 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -209,8 +209,10 @@ void Render::RenderFrame() {
if (isWireframe)
Gal::GetImplementation()->SetWireframe(true);
- if (renderWorld)
+ if (renderWorld) {
world->Render(static_cast<float>(windowWidth) / static_cast<float>(windowHeight));
+ gbuffer->SetDayTime(world->shaderDayTime);
+ }
if (isWireframe)
Gal::GetImplementation()->SetWireframe(false);
diff --git a/src/RenderConfigs.cpp b/src/RenderConfigs.cpp
index ebdbaef..86418c2 100644
--- a/src/RenderConfigs.cpp
+++ b/src/RenderConfigs.cpp
@@ -5,24 +5,44 @@
Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH) {
auto gal = Gal::GetImplementation();
- auto colorConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8A8);
+ auto colorConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8);
+ colorConf->SetMinFilter(Gal::Filtering::Bilinear);
+ colorConf->SetMaxFilter(Gal::Filtering::Bilinear);
color = gal->BuildTexture(colorConf);
- auto normalConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8A8);
+ auto normalConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8);
+ normalConf->SetMinFilter(Gal::Filtering::Bilinear);
+ normalConf->SetMaxFilter(Gal::Filtering::Bilinear);
normal = gal->BuildTexture(normalConf);
+ auto addColorConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8);
+ addColorConf->SetMinFilter(Gal::Filtering::Bilinear);
+ addColorConf->SetMaxFilter(Gal::Filtering::Bilinear);
+ addColor = gal->BuildTexture(addColorConf);
+
+ auto lightConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8);
+ lightConf->SetMinFilter(Gal::Filtering::Bilinear);
+ lightConf->SetMaxFilter(Gal::Filtering::Bilinear);
+ light = gal->BuildTexture(lightConf);
+
auto dsConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::D24S8);
+ dsConf->SetMinFilter(Gal::Filtering::Bilinear);
+ dsConf->SetMaxFilter(Gal::Filtering::Bilinear);
depthStencil = gal->BuildTexture(dsConf);
auto geomFbConf = gal->CreateFramebufferConfig();
geomFbConf->SetTexture(0, color);
geomFbConf->SetTexture(1, normal);
+ geomFbConf->SetTexture(2, addColor);
+ geomFbConf->SetTexture(3, light);
geomFbConf->SetDepthStencil(depthStencil);
geomFramebuffer = gal->BuildFramebuffer(geomFbConf);
geomFramebuffer->SetViewport(0, 0, geomW, geomH);
auto finalColorConf = gal->CreateTexture2DConfig(lightW, lightH, Gal::Format::R8G8B8A8);
+ finalColorConf->SetMinFilter(Gal::Filtering::Bilinear);
+ finalColorConf->SetMaxFilter(Gal::Filtering::Bilinear);
finalColor = gal->BuildTexture(finalColorConf);
auto lightFbConf = gal->CreateFramebufferConfig();
@@ -43,8 +63,11 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH) {
auto lightPPC = gal->CreatePipelineConfig();
lightPPC->SetTarget(lightFramebuffer);
lightPPC->AddStaticTexture("color", color);
+ lightPPC->AddStaticTexture("addColor", addColor);
lightPPC->AddStaticTexture("normal", normal);
+ lightPPC->AddStaticTexture("light", light);
lightPPC->AddStaticTexture("depthStencil", depthStencil);
+ lightPPC->AddShaderParameter("dayTime", Gal::Type::Float);
lightPPC->SetVertexShader(gal->LoadVertexShader(vertexSource));
lightPPC->SetPixelShader(gal->LoadPixelShader(pixelSource));
diff --git a/src/RenderConfigs.hpp b/src/RenderConfigs.hpp
index 6279169..94e96bb 100644
--- a/src/RenderConfigs.hpp
+++ b/src/RenderConfigs.hpp
@@ -7,8 +7,10 @@ class Gbuffer {
std::shared_ptr<Gal::Buffer> lightBuffer;
std::shared_ptr<Gal::Pipeline> lightPipeline;
std::shared_ptr<Gal::PipelineInstance> lightPipelineInstance;
- std::shared_ptr<Gal::Texture> color;
- std::shared_ptr<Gal::Texture> normal;
+ std::shared_ptr<Gal::Texture> color; //RGB - color
+ std::shared_ptr<Gal::Texture> normal; //RGB - normal
+ std::shared_ptr<Gal::Texture> addColor; //RGB - addColor
+ std::shared_ptr<Gal::Texture> light; //R - faceLight, G - skyLight, B - unused
std::shared_ptr<Gal::Texture> depthStencil;
std::shared_ptr<Gal::Framebuffer> geomFramebuffer;
@@ -35,4 +37,8 @@ public:
geomFramebuffer->Clear();
lightFramebuffer->Clear();
}
+
+ void SetDayTime(float dayTime) {
+ lightPipeline->SetShaderParameter("dayTime", dayTime);
+ }
};
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index 9055729..d2c69fd 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -366,6 +366,7 @@ void RendererWorld::Render(float screenRatio) {
float timePassed = (dayTime - moonriseMin);
mixLevel = 1.0 - (timePassed / moonriseLength);
}
+ shaderDayTime = mixLevel;
skyPipeline->Activate();
skyPipeline->SetShaderParameter("projView", projView);
diff --git a/src/RendererWorld.hpp b/src/RendererWorld.hpp
index e645b30..a6fca06 100644
--- a/src/RendererWorld.hpp
+++ b/src/RendererWorld.hpp
@@ -63,6 +63,8 @@ public:
double MaxRenderingDistance;
+ float shaderDayTime;
+
void Update(double timeToUpdate);
};