summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-11-19 07:48:37 +0100
committerLaG1924 <lag1924@gmail.com>2021-11-19 08:28:15 +0100
commit8ab6abaae252050bf0ee03cd2a988c0e4e502718 (patch)
tree6c96eb7314da49db1d2ac5a142623bc443e3ee33
parentOptimized entities rendering (diff)
downloadAltCraft-8ab6abaae252050bf0ee03cd2a988c0e4e502718.tar
AltCraft-8ab6abaae252050bf0ee03cd2a988c0e4e502718.tar.gz
AltCraft-8ab6abaae252050bf0ee03cd2a988c0e4e502718.tar.bz2
AltCraft-8ab6abaae252050bf0ee03cd2a988c0e4e502718.tar.lz
AltCraft-8ab6abaae252050bf0ee03cd2a988c0e4e502718.tar.xz
AltCraft-8ab6abaae252050bf0ee03cd2a988c0e4e502718.tar.zst
AltCraft-8ab6abaae252050bf0ee03cd2a988c0e4e502718.zip
Diffstat (limited to '')
-rw-r--r--cwd/assets/altcraft/shaders/frag/sky.fs23
-rw-r--r--cwd/assets/altcraft/shaders/sky.json3
-rw-r--r--cwd/assets/altcraft/shaders/vert/sky.vs18
-rw-r--r--src/RendererSky.cpp144
-rw-r--r--src/RendererSky.hpp13
-rw-r--r--src/RendererWorld.cpp192
-rw-r--r--src/RendererWorld.hpp34
7 files changed, 173 insertions, 254 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs
index 2f51267..53e0cf4 100644
--- a/cwd/assets/altcraft/shaders/frag/sky.fs
+++ b/cwd/assets/altcraft/shaders/frag/sky.fs
@@ -1,6 +1,5 @@
#version 330 core
-in vec2 uvPos;
in vec3 pos;
out vec4 fragColor;
@@ -12,11 +11,11 @@ uniform float sunTextureLayer;
uniform vec4 moonTexture;
uniform float moonTextureLayer;
-const vec4 DaySkyColor = vec4(0.49,0.66,1, 1);
+const vec4 DaySkyColor = vec4(0.49, 0.66, 1, 1);
-const vec3 SunPos = vec3(0,0.1,0.5);
+const vec3 SunPos = vec3(0, 0.1, 0.5);
-const vec3 MoonPos = vec3(0,0.1,-0.5);
+const vec3 MoonPos = vec3(0, 0.1, -0.5);
vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) {
float x = TextureAtlasCoords.x;
@@ -25,23 +24,23 @@ vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer)
float h = TextureAtlasCoords.w;
vec2 A = vec2(x, 1 - y - h);
vec2 B = vec2(x + w, 1 - y);
- vec2 transformed = A + UvCoords * (B - A);
+ vec2 transformed = A + UvCoords * (B - A);
return vec3(transformed.x, transformed.y, Layer);
}
vec4 Sun() {
- vec3 sunDelta = (pos - SunPos)*3.0f;
+ vec3 sunDelta = (pos - SunPos) * 3.0f;
float distanceToSun = length(sunDelta);
- vec4 sunColor = texture(textureAtlas,TransformTextureCoord(sunTexture,(vec2(sunDelta.xy)+0.5f),sunTextureLayer));
- vec4 sun = mix(vec4(0,0,0,1),sunColor,clamp(1-distanceToSun*2.0f,0,1));
+ vec4 sunColor = texture(textureAtlas, TransformTextureCoord(sunTexture, (vec2(sunDelta.xy) + 0.5f), sunTextureLayer));
+ vec4 sun = mix(vec4(0, 0, 0, 1), sunColor, clamp(1 - distanceToSun * 2.0f, 0, 1));
return sun;
}
vec4 Moon() {
- vec3 moonDelta = (pos - MoonPos)*4.5f;
+ vec3 moonDelta = (pos - MoonPos) * 4.5f;
float distanceToMoon = length(moonDelta);
- vec4 moonColor = texture(textureAtlas,TransformTextureCoord(moonTexture,(vec2(moonDelta.xy)+0.5f),moonTextureLayer));
- vec4 moon = mix(vec4(0,0,0,1),moonColor,clamp(1-distanceToMoon*2.0f,0,1));
+ vec4 moonColor = texture(textureAtlas, TransformTextureCoord(moonTexture, (vec2(moonDelta.xy) + 0.5f), moonTextureLayer));
+ vec4 moon = mix(vec4(0, 0, 0, 1),moonColor, clamp(1 - distanceToMoon * 2.0f, 0, 1));
return moon;
}
@@ -50,4 +49,4 @@ void main() {
fragColor = mix(starColor, DaySkyColor, DayTime);
fragColor += Sun();
fragColor += Moon();
-} \ No newline at end of file
+}
diff --git a/cwd/assets/altcraft/shaders/sky.json b/cwd/assets/altcraft/shaders/sky.json
index 6e53db6..f4c8813 100644
--- a/cwd/assets/altcraft/shaders/sky.json
+++ b/cwd/assets/altcraft/shaders/sky.json
@@ -2,8 +2,7 @@
"vert": "/altcraft/shaders/vert/sky",
"frag": "/altcraft/shaders/frag/sky",
"uniforms": [
- "view",
- "projection",
+ "projView",
"model",
"textureAtlas",
"DayTime",
diff --git a/cwd/assets/altcraft/shaders/vert/sky.vs b/cwd/assets/altcraft/shaders/vert/sky.vs
index 983e1f3..0ab261c 100644
--- a/cwd/assets/altcraft/shaders/vert/sky.vs
+++ b/cwd/assets/altcraft/shaders/vert/sky.vs
@@ -1,17 +1,13 @@
#version 330 core
-uniform mat4 view;
-uniform mat4 projection;
-uniform mat4 model;
+in vec3 position;
-layout (location = 0) in vec3 position;
-layout (location = 1) in vec2 uvPosition;
-
-out vec2 uvPos;
out vec3 pos;
-void main(){
- uvPos = uvPosition;
+uniform mat4 projView;
+uniform mat4 model;
+
+void main() {
pos = position;
- gl_Position = projection*view*model*vec4(position,1);
-} \ No newline at end of file
+ gl_Position = projView * model * vec4(position, 1);
+}
diff --git a/src/RendererSky.cpp b/src/RendererSky.cpp
deleted file mode 100644
index 1eab369..0000000
--- a/src/RendererSky.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-#include "RendererSky.hpp"
-
-#include <optick.h>
-
-#include "Renderer.hpp"
-#include "Utility.hpp"
-
-const GLfloat vertices[] = {
- //Z+ edge
- -0.5f, -0.5f, 0.5f,
- -0.5f, 0.5f, 0.5f,
- 0.5f, -0.5f, 0.5f,
- 0.5f, -0.5f, 0.5f,
- -0.5f, 0.5f, 0.5f,
- 0.5f, 0.5f, 0.5f,
-
- //Z- edge
- -0.5f, 0.5f, -0.5f,
- -0.5f, -0.5f, -0.5f,
- 0.5f, -0.5f, -0.5f,
- -0.5f, 0.5f, -0.5f,
- 0.5f, -0.5f, -0.5f,
- 0.5f, 0.5f, -0.5f,
-
- //X+ edge
- -0.5f, -0.5f, 0.5f,
- -0.5f, -0.5f, -0.5f,
- -0.5f, 0.5f, -0.5f,
- -0.5f, -0.5f, 0.5f,
- -0.5f, 0.5f, -0.5f,
- -0.5f, 0.5f, 0.5f,
-
- //X- edge
- 0.5f, 0.5f, -0.5f,
- 0.5f, -0.5f, 0.5f,
- 0.5f, 0.5f, 0.5f,
- 0.5f, -0.5f, -0.5f,
- 0.5f, -0.5f, 0.5f,
- 0.5f, 0.5f, -0.5f,
-
- //Y+ edge
- -0.5f, 0.5f, 0.5f,
- 0.5f, 0.5f, -0.5f,
- 0.5f, 0.5f, 0.5f,
- -0.5f, 0.5f, -0.5f,
- 0.5f, 0.5f, -0.5f,
- -0.5f, 0.5f, 0.5f,
-
- //Y- edge
- 0.5f, -0.5f, -0.5f,
- -0.5f, -0.5f, 0.5f,
- 0.5f, -0.5f, 0.5f,
- 0.5f, -0.5f, -0.5f,
- -0.5f, -0.5f, -0.5f,
- -0.5f, -0.5f, 0.5f,
-};
-
-const GLfloat uv_coords[] = {
- //Z+
- 0.0f, 1.0f,
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- 0.0f, 1.0f,
- 1.0f, 0.0f,
- 1.0f, 1.0f,
-
- //Z-
- 1.0f, 0.0f,
- 1.0f, 1.0f,
- 0.0f, 0.0f,
- 0.0f, 0.0f,
- 1.0f, 1.0f,
- 0.0f, 1.0f,
-
- //X+
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- 0.0f, 1.0f,
- 0.0f, 1.0f,
- 1.0f, 0.0f,
- 1.0f, 1.0f,
-
- //X-
- 0.0f, 0.0f,
- 1.0f, 1.0f,
- 0.0f, 1.0f,
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- 1.0f, 1.0f,
-
- //Y+
- 0.0f, 0.0f,
- 1.0f, 1.0f,
- 0.0f, 1.0f,
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- 1.0f, 1.0f,
-
- //Y-
- 1.0f, 0.0f,
- 0.0f, 1.0f,
- 0.0f, 0.0f,
- 1.0f, 1.0f,
- 0.0f, 1.0f,
- 1.0f, 0.0f,
-};
-
-RendererSky::RendererSky() {
- glGenBuffers(1, &VboVert);
- glBindBuffer(GL_ARRAY_BUFFER, VboVert);
- glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
-
- glGenBuffers(1, &VboUv);
- glBindBuffer(GL_ARRAY_BUFFER, VboUv);
- glBufferData(GL_ARRAY_BUFFER, sizeof(uv_coords), uv_coords, GL_STATIC_DRAW);
- glGenVertexArrays(1, &Vao);
-
- glBindVertexArray(Vao);
- {
- glBindBuffer(GL_ARRAY_BUFFER, VboVert);
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
- glEnableVertexAttribArray(0);
-
- glBindBuffer(GL_ARRAY_BUFFER, VboUv);
- glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), (GLvoid*)0);
- glEnableVertexAttribArray(1);
- }
- glBindVertexArray(0);
- glCheckError();
-}
-
-RendererSky::~RendererSky() {
- glDeleteBuffers(1, &VboVert);
- glDeleteBuffers(1, &VboUv);
- glDeleteVertexArrays(1, &Vao);
- //glCheckError();
-}
-
-void RendererSky::Render(RenderState &renderState) {
- OPTICK_EVENT();
- renderState.SetActiveVao(Vao);
- glDrawArrays(GL_TRIANGLES, 0, 36);
- glCheckError();
-}
diff --git a/src/RendererSky.hpp b/src/RendererSky.hpp
deleted file mode 100644
index 8c6a409..0000000
--- a/src/RendererSky.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-
-#include <GL/glew.h>
-
-class RenderState;
-
-class RendererSky {
- GLuint VboVert, VboUv, Vao;
-public:
- RendererSky();
- ~RendererSky();
- void Render(RenderState &renderState);
-}; \ No newline at end of file
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index 4bec197..cadad3f 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -337,51 +337,48 @@ void RendererWorld::Render(RenderState & renderState) {
//Render sky
renderState.TimeOfDay = GetGameState()->GetTimeStatus().timeOfDay;
- Shader *skyShader = AssetManager::GetAsset<AssetShader>("/altcraft/shaders/sky")->shader.get();
- skyShader->Activate();
- skyShader->SetUniform("projection", projection);
- skyShader->SetUniform("view", view);
- glm::mat4 model = glm::mat4(1.0);
- model = glm::translate(model, GetGameState()->GetPlayer()->pos.glm());
- const float scale = 1000000.0f;
- model = glm::scale(model, glm::vec3(scale, scale, scale));
- float shift = GetGameState()->GetTimeStatus().interpolatedTimeOfDay / 24000.0f;
- if (shift < 0)
- shift *= -1.0f;
- model = glm::rotate(model, glm::radians(90.0f), glm::vec3(0, 1.0f, 0.0f));
- model = glm::rotate(model, glm::radians(360.0f * shift), glm::vec3(-1.0f, 0.0f, 0.0f));
- skyShader->SetUniform("model", model);
-
- glCheckError();
-
- const int sunriseMin = 22000;
- const int sunriseMax = 23500;
- const int moonriseMin = 12000;
- const int moonriseMax = 13500;
- const float sunriseLength = sunriseMax - sunriseMin;
- const float moonriseLength = moonriseMax - moonriseMin;
-
- float mixLevel = 0;
- float dayTime = GetGameState()->GetTimeStatus().interpolatedTimeOfDay;
- if (dayTime < 0)
- dayTime *= -1;
- while (dayTime > 24000)
- dayTime -= 24000;
- if (dayTime > 0 && dayTime < moonriseMin || dayTime > sunriseMax) //day
- mixLevel = 1.0;
- if (dayTime > moonriseMax && dayTime < sunriseMin) //night
- mixLevel = 0.0;
- if (dayTime >= sunriseMin && dayTime <= sunriseMax) //sunrise
- mixLevel = (dayTime - sunriseMin) / sunriseLength;
- if (dayTime >= moonriseMin && dayTime <= moonriseMax) { //moonrise
- float timePassed = (dayTime - moonriseMin);
- mixLevel = 1.0 - (timePassed / moonriseLength);
- }
- skyShader->SetUniform("DayTime", mixLevel);
+ glm::mat4 model = glm::mat4(1.0);
+ model = glm::translate(model, GetGameState()->GetPlayer()->pos.glm());
+ const float scale = 1000000.0f;
+ model = glm::scale(model, glm::vec3(scale, scale, scale));
+ float shift = GetGameState()->GetTimeStatus().interpolatedTimeOfDay / 24000.0f;
+ if (shift < 0)
+ shift *= -1.0f;
+ model = glm::rotate(model, glm::radians(90.0f), glm::vec3(0, 1.0f, 0.0f));
+ model = glm::rotate(model, glm::radians(360.0f * shift), glm::vec3(-1.0f, 0.0f, 0.0f));
+
+ const int sunriseMin = 22000;
+ const int sunriseMax = 23500;
+ const int moonriseMin = 12000;
+ const int moonriseMax = 13500;
+ const float sunriseLength = sunriseMax - sunriseMin;
+ const float moonriseLength = moonriseMax - moonriseMin;
+
+ float mixLevel = 0;
+ float dayTime = GetGameState()->GetTimeStatus().interpolatedTimeOfDay;
+ if (dayTime < 0)
+ dayTime *= -1;
+ while (dayTime > 24000)
+ dayTime -= 24000;
+ if (dayTime > 0 && dayTime < moonriseMin || dayTime > sunriseMax) //day
+ mixLevel = 1.0;
+ if (dayTime > moonriseMax && dayTime < sunriseMin) //night
+ mixLevel = 0.0;
+ if (dayTime >= sunriseMin && dayTime <= sunriseMax) //sunrise
+ mixLevel = (dayTime - sunriseMin) / sunriseLength;
+ if (dayTime >= moonriseMin && dayTime <= moonriseMax) { //moonrise
+ float timePassed = (dayTime - moonriseMin);
+ mixLevel = 1.0 - (timePassed / moonriseLength);
+ }
+
+ skyPipeline->Activate();
+ skyPipeline->SetShaderParameter("projView", projView);
+ skyPipeline->SetShaderParameter("model", model);
+ skyPipeline->SetShaderParameter("DayTime", mixLevel);
+ skyPipelineInstance->Activate();
+ skyPipelineInstance->Render(0, 36);
- rendererSky.Render(renderState);
- glCheckError();
//Render sections
auto rawGlobalTime = (std::chrono::high_resolution_clock::now() - globalTimeStart);
@@ -433,6 +430,15 @@ void RendererWorld::PrepareRender() {
entitiesPixelSource = std::string((char*)pixelAsset->data.data(), (char*)pixelAsset->data.data() + pixelAsset->data.size());
}
+ std::string skyVertexSource, skyPixelSource;
+ {
+ auto vertAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/vert/sky");
+ skyVertexSource = std::string((char*)vertAsset->data.data(), (char*)vertAsset->data.data() + vertAsset->data.size());
+
+ auto pixelAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/frag/sky");
+ skyPixelSource = std::string((char*)pixelAsset->data.data(), (char*)pixelAsset->data.data() + pixelAsset->data.size());
+ }
+
auto gal = Gal::GetImplementation();
{
auto sectionsPLC = gal->CreatePipelineConfig();
@@ -623,18 +629,94 @@ void RendererWorld::PrepareRender() {
});
}
- TextureCoord sunTexture = AssetManager::GetTexture("/minecraft/textures/environment/sun");
- TextureCoord moonTexture = AssetManager::GetTexture("/minecraft/textures/environment/moon_phases");
- moonTexture.w /= 4.0f; //First phase will be fine for now
- moonTexture.h /= 2.0f;
-
- Shader *sky = AssetManager::GetAsset<AssetShader>("/altcraft/shaders/sky")->shader.get();
- sky->Activate();
- sky->SetUniform("textureAtlas", 0);
- sky->SetUniform("sunTexture", glm::vec4(sunTexture.x, sunTexture.y, sunTexture.w, sunTexture.h));
- sky->SetUniform("sunTextureLayer", (float)sunTexture.layer);
- sky->SetUniform("moonTexture", glm::vec4(moonTexture.x, moonTexture.y, moonTexture.w, moonTexture.h));
- sky->SetUniform("moonTextureLayer", (float)moonTexture.layer);
+ {
+ auto skyPPC = gal->CreatePipelineConfig();
+ skyPPC->SetTarget(gal->GetDefaultFramebuffer());
+ skyPPC->AddShaderParameter("textureAtlas", Gal::Type::Int32);
+ skyPPC->AddShaderParameter("sunTexture", Gal::Type::Vec4);
+ skyPPC->AddShaderParameter("sunTextureLayer", Gal::Type::Float);
+ skyPPC->AddShaderParameter("moonTexture", Gal::Type::Vec4);
+ skyPPC->AddShaderParameter("moonTextureLayer", Gal::Type::Float);
+ skyPPC->AddShaderParameter("DayTime", Gal::Type::Float);
+ skyPPC->AddShaderParameter("projView", Gal::Type::Mat4);
+ skyPPC->AddShaderParameter("model", Gal::Type::Mat4);
+ skyPPC->SetVertexShader(gal->LoadVertexShader(skyVertexSource));
+ skyPPC->SetPixelShader(gal->LoadPixelShader(skyPixelSource));
+ auto skyPosUvBB = skyPPC->BindVertexBuffer({
+ {"position", Gal::Type::Vec3},
+ {"", Gal::Type::Vec2},
+ });
+
+ constexpr float vertices[] = {
+ //Z+ Positions UVs
+ -0.5f, -0.5f, 0.5f, 0.0f, 1.0f,
+ -0.5f, 0.5f, 0.5f, 0.0f, 0.0f,
+ 0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
+ 0.5f, -0.5f, 0.5f, 0.0f, 1.0f,
+ -0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
+ 0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
+
+ //Z-
+ -0.5f, 0.5f, -0.5f, 1.0f, 0.0f,
+ -0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
+ 0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
+ -0.5f, 0.5f, -0.5f, 0.0f, 0.0f,
+ 0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
+ 0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
+
+ //X+
+ -0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
+ -0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
+ -0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
+ -0.5f, -0.5f, 0.5f, 0.0f, 1.0f,
+ -0.5f, 0.5f, -0.5f, 1.0f, 0.0f,
+ -0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
+
+ //X-
+ 0.5f, 0.5f, -0.5f, 0.0f, 0.0f,
+ 0.5f, -0.5f, 0.5f, 1.0f, 1.0f,
+ 0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
+ 0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
+ 0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
+ 0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
+
+ //Y+
+ -0.5f, 0.5f, 0.5f, 0.0f, 0.0f,
+ 0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
+ 0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
+ -0.5f, 0.5f, -0.5f, 0.0f, 0.0f,
+ 0.5f, 0.5f, -0.5f, 1.0f, 0.0f,
+ -0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
+
+ //Y-
+ 0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
+ -0.5f, -0.5f, 0.5f, 0.0f, 1.0f,
+ 0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
+ 0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
+ -0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
+ -0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
+ };
+
+ TextureCoord sunTexture = AssetManager::GetTexture("/minecraft/textures/environment/sun");
+ TextureCoord moonTexture = AssetManager::GetTexture("/minecraft/textures/environment/moon_phases");
+ moonTexture.w /= 4.0f; // First phase will be fine for now
+ moonTexture.h /= 2.0f;
+
+ skyPipeline = gal->BuildPipeline(skyPPC);
+ skyPipeline->Activate();
+ skyPipeline->SetShaderParameter("textureAtlas", 0);
+ skyPipeline->SetShaderParameter("sunTexture", glm::vec4(sunTexture.x, sunTexture.y, sunTexture.w, sunTexture.h));
+ skyPipeline->SetShaderParameter("sunTextureLayer", static_cast<float>(sunTexture.layer));
+ skyPipeline->SetShaderParameter("moonTexture", glm::vec4(moonTexture.x, moonTexture.y, moonTexture.w, moonTexture.h));
+ skyPipeline->SetShaderParameter("moonTextureLayer", static_cast<float>(moonTexture.layer));
+
+ skyBuffer = gal->CreateBuffer();
+ skyBuffer->SetData({ reinterpret_cast<const std::byte*>(vertices), reinterpret_cast<const std::byte*>(vertices) + sizeof(vertices) });
+
+ skyPipelineInstance = skyPipeline->CreateInstance({
+ {skyPosUvBB, skyBuffer}
+ });
+ }
}
void RendererWorld::Update(double timeToUpdate) {
diff --git a/src/RendererWorld.hpp b/src/RendererWorld.hpp
index f26abda..706af68 100644
--- a/src/RendererWorld.hpp
+++ b/src/RendererWorld.hpp
@@ -9,7 +9,6 @@
#include "RendererSection.hpp"
#include "RendererEntity.hpp"
-#include "RendererSky.hpp"
#include "RendererSectionData.hpp"
class Frustum;
@@ -20,11 +19,11 @@ class EventListener;
class RenderState;
class RendererWorld {
- struct SectionParsing {
- SectionsData data;
- RendererSectionData renderer;
- bool parsing = false;
- };
+ struct SectionParsing {
+ SectionsData data;
+ RendererSectionData renderer;
+ bool parsing = false;
+ };
//General
std::unique_ptr<EventListener> listener;
@@ -33,17 +32,17 @@ class RendererWorld {
std::vector<std::thread> workers;
void WorkerFunction(size_t WorkerId);
bool isRunning = true;
- const static size_t parsingBufferSize = 64;
- SectionParsing parsing[parsingBufferSize];
- std::queue<Vector> parseQueue;
- bool parseQueueNeedRemoveUnnecessary = false;
- void ParseQueueUpdate();
- void ParseQeueueRemoveUnnecessary();
+ const static size_t parsingBufferSize = 64;
+ SectionParsing parsing[parsingBufferSize];
+ std::queue<Vector> parseQueue;
+ bool parseQueueNeedRemoveUnnecessary = false;
+ void ParseQueueUpdate();
+ void ParseQeueueRemoveUnnecessary();
//Blocks
std::vector<Vector> renderList;
std::map<Vector, RendererSection> sections;
void UpdateAllSections(VectorF playerPos);
- std::chrono::time_point<std::chrono::high_resolution_clock> globalTimeStart;
+ std::chrono::time_point<std::chrono::high_resolution_clock> globalTimeStart;
std::shared_ptr<Gal::Pipeline> sectionsPipeline;
std::shared_ptr<Gal::BufferBinding> sectionsBufferBinding;
//Entities
@@ -52,11 +51,12 @@ class RendererWorld {
std::shared_ptr<Gal::PipelineInstance> entitiesPipelineInstance;
std::shared_ptr<Gal::Buffer> entitiesPosBuffer, entitiesIndexBuffer;
//Sky
- Texture *skyTexture;
- RendererSky rendererSky;
+ std::shared_ptr<Gal::Pipeline> skyPipeline;
+ std::shared_ptr<Gal::PipelineInstance> skyPipelineInstance;
+ std::shared_ptr<Gal::Buffer> skyBuffer;
public:
- RendererWorld();
- ~RendererWorld();
+ RendererWorld();
+ ~RendererWorld();
void Render(RenderState& renderState);
void PrepareRender();