summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-11-27 17:08:58 +0100
committerLaG1924 <lag1924@gmail.com>2021-11-27 17:08:58 +0100
commitc905ede556c892d39fd69d3945026ba244567ce9 (patch)
tree86b0d1f5f3ba47358bfb3a89c1dba9ae9a344a39
parentAdded ShaderParametersBuffer to GalOgl (diff)
downloadAltCraft-c905ede556c892d39fd69d3945026ba244567ce9.tar
AltCraft-c905ede556c892d39fd69d3945026ba244567ce9.tar.gz
AltCraft-c905ede556c892d39fd69d3945026ba244567ce9.tar.bz2
AltCraft-c905ede556c892d39fd69d3945026ba244567ce9.tar.lz
AltCraft-c905ede556c892d39fd69d3945026ba244567ce9.tar.xz
AltCraft-c905ede556c892d39fd69d3945026ba244567ce9.tar.zst
AltCraft-c905ede556c892d39fd69d3945026ba244567ce9.zip
Diffstat (limited to '')
-rw-r--r--cwd/assets/altcraft/shaders/frag/entity.fs12
-rw-r--r--cwd/assets/altcraft/shaders/frag/face.fs4
-rw-r--r--cwd/assets/altcraft/shaders/frag/fbo.fs12
-rw-r--r--cwd/assets/altcraft/shaders/frag/light.fs8
-rw-r--r--cwd/assets/altcraft/shaders/frag/rml.fs8
-rw-r--r--cwd/assets/altcraft/shaders/frag/rmltex.fs12
-rw-r--r--cwd/assets/altcraft/shaders/frag/sky.fs10
-rw-r--r--cwd/assets/altcraft/shaders/vert/entity.vs12
-rw-r--r--cwd/assets/altcraft/shaders/vert/face.vs15
-rw-r--r--cwd/assets/altcraft/shaders/vert/fbo.vs23
-rw-r--r--cwd/assets/altcraft/shaders/vert/light.vs7
-rw-r--r--cwd/assets/altcraft/shaders/vert/pp.vs7
-rw-r--r--cwd/assets/altcraft/shaders/vert/rml.vs27
-rw-r--r--cwd/assets/altcraft/shaders/vert/sky.vs16
-rw-r--r--src/GalOgl.cpp2
-rw-r--r--src/Render.cpp7
-rw-r--r--src/RenderConfigs.cpp1
-rw-r--r--src/RenderConfigs.hpp7
-rw-r--r--src/RendererEntity.cpp2
-rw-r--r--src/RendererWorld.cpp43
-rw-r--r--src/Rml.cpp11
21 files changed, 140 insertions, 106 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/entity.fs b/cwd/assets/altcraft/shaders/frag/entity.fs
index 06d5759..be4da09 100644
--- a/cwd/assets/altcraft/shaders/frag/entity.fs
+++ b/cwd/assets/altcraft/shaders/frag/entity.fs
@@ -1,9 +1,15 @@
#version 330 core
-out vec4 fragColor;
+layout (location = 0) out vec4 color;
+layout (location = 1) out vec4 normal;
+layout (location = 2) out vec4 addColor;
+layout (location = 3) out vec4 light;
-uniform vec3 color;
+uniform vec3 entityColor;
void main() {
- fragColor = vec4(color, 1);
+ color = vec4(entityColor, 1.0f);
+ normal = vec4(0.0f, 0.0f, 0.0f, 1.0f);
+ addColor = vec4(0.0f, 0.0f, 0.0f, 1.0f);
+ light = vec4(1.0f, 1.0f, 0.0f, 1.0f);
}
diff --git a/cwd/assets/altcraft/shaders/frag/face.fs b/cwd/assets/altcraft/shaders/frag/face.fs
index 57ea0ec..ebda304 100644
--- a/cwd/assets/altcraft/shaders/frag/face.fs
+++ b/cwd/assets/altcraft/shaders/frag/face.fs
@@ -1,6 +1,6 @@
#version 330 core
-in vec3 faceTexture;
+in vec3 faceTextureUv;
in vec3 faceAddColor;
in vec3 faceNormal;
in vec2 faceLight;
@@ -13,7 +13,7 @@ layout (location = 3) out vec4 light;
uniform sampler2DArray textureAtlas;
void main() {
- vec4 col = texture(textureAtlas, faceTexture);
+ vec4 col = texture(textureAtlas, faceTextureUv);
if (col.a < 0.3)
discard;
diff --git a/cwd/assets/altcraft/shaders/frag/fbo.fs b/cwd/assets/altcraft/shaders/frag/fbo.fs
index df624b3..a5a7a2b 100644
--- a/cwd/assets/altcraft/shaders/frag/fbo.fs
+++ b/cwd/assets/altcraft/shaders/frag/fbo.fs
@@ -1,11 +1,11 @@
#version 330 core
-out vec4 FragColor;
-in vec2 TexCoords;
+in vec2 uv;
+
+out vec4 fragColor;
uniform sampler2D inputTexture;
-void main()
-{
- FragColor = texture(inputTexture, TexCoords);
-} \ No newline at end of file
+void main() {
+ fragColor = texture(inputTexture, uv);
+}
diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs
index 6d05884..07eb3ec 100644
--- a/cwd/assets/altcraft/shaders/frag/light.fs
+++ b/cwd/assets/altcraft/shaders/frag/light.fs
@@ -10,9 +10,15 @@ uniform sampler2D addColor;
uniform sampler2D light;
uniform sampler2D depthStencil;
-uniform float dayTime;
uniform int renderBuff;
+layout (std140) uniform Globals {
+ mat4 projView;
+ uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
+};
+
void main() {
vec4 c = texture(color, uv);
vec4 n = texture(normal, uv);
diff --git a/cwd/assets/altcraft/shaders/frag/rml.fs b/cwd/assets/altcraft/shaders/frag/rml.fs
index 54c3f36..fa1c596 100644
--- a/cwd/assets/altcraft/shaders/frag/rml.fs
+++ b/cwd/assets/altcraft/shaders/frag/rml.fs
@@ -1,12 +1,10 @@
#version 330 core
-in VS_OUT {
- vec4 color;
- vec2 tex_coord;
-} fs_in;
+in vec4 color;
+in vec2 uv;
out vec4 fragColor;
void main() {
- fragColor = fs_in.color;
+ fragColor = color;
}
diff --git a/cwd/assets/altcraft/shaders/frag/rmltex.fs b/cwd/assets/altcraft/shaders/frag/rmltex.fs
index d885b3b..af86b5b 100644
--- a/cwd/assets/altcraft/shaders/frag/rmltex.fs
+++ b/cwd/assets/altcraft/shaders/frag/rmltex.fs
@@ -1,14 +1,12 @@
#version 330 core
-uniform sampler2D fontTexture;
-
-in VS_OUT {
- vec4 color;
- vec2 tex_coord;
-} fs_in;
+in vec4 color;
+in vec2 uv;
out vec4 fragColor;
+uniform sampler2D fontTexture;
+
void main() {
- fragColor = fs_in.color * texture(fontTexture, fs_in.tex_coord);
+ fragColor = color * texture(fontTexture, uv);
}
diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs
index 3763bdb..32b7da0 100644
--- a/cwd/assets/altcraft/shaders/frag/sky.fs
+++ b/cwd/assets/altcraft/shaders/frag/sky.fs
@@ -7,8 +7,14 @@ layout (location = 1) out vec4 normal;
layout (location = 2) out vec4 addColor;
layout (location = 3) out vec4 light;
+layout (std140) uniform Globals {
+ mat4 projView;
+ uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
+};
+
uniform sampler2DArray textureAtlas;
-uniform float DayTime;
uniform vec4 sunTexture;
uniform float sunTextureLayer;
uniform vec4 moonTexture;
@@ -49,7 +55,7 @@ vec4 Moon() {
void main() {
vec4 starColor = vec4(0.0f, 0.04f, 0.06f, 1.0f);
- color = vec4(mix(starColor, DaySkyColor, DayTime).rgb, 1.0f);
+ color = vec4(mix(starColor, DaySkyColor, dayTime).rgb, 1.0f);
color += vec4(Sun().rgb, 1.0f);
color += vec4(Moon().rgb, 1.0f);
normal = vec4(0.0f, 0.0f, 0.0f, 1.0f);
diff --git a/cwd/assets/altcraft/shaders/vert/entity.vs b/cwd/assets/altcraft/shaders/vert/entity.vs
index e38c54c..b2f1db6 100644
--- a/cwd/assets/altcraft/shaders/vert/entity.vs
+++ b/cwd/assets/altcraft/shaders/vert/entity.vs
@@ -1,10 +1,16 @@
#version 330 core
-in vec3 position;
+in vec3 pos;
-uniform mat4 projView;
uniform mat4 model;
+layout (std140) uniform Globals {
+ mat4 projView;
+ uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
+};
+
void main() {
- gl_Position = projView * model * vec4(position, 1);
+ gl_Position = projView * model * vec4(pos, 1);
}
diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs
index d73e164..5fb9357 100644
--- a/cwd/assets/altcraft/shaders/vert/face.vs
+++ b/cwd/assets/altcraft/shaders/vert/face.vs
@@ -1,6 +1,6 @@
#version 330 core
-in vec3 position[4];
+in vec3 pos[4];
in vec3 normal;
in vec2 uv[4];
in float uvLayer;
@@ -8,22 +8,23 @@ in float animation;
in vec3 color;
in vec2 light;
-out vec3 faceTexture;
+out vec3 faceTextureUv;
out vec3 faceNormal;
out vec3 faceAddColor;
out vec2 faceLight;
-uniform float GlobalTime;
-
layout (std140) uniform Globals {
mat4 projView;
+ uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
};
void main() {
- gl_Position = projView * vec4(position[gl_VertexID], 1.0f);
+ gl_Position = projView * vec4(pos[gl_VertexID], 1.0f);
- faceTexture = vec3(uv[gl_VertexID], uvLayer);
- faceTexture.y -= (uv[2].y - uv[0].y) * trunc(mod(GlobalTime * 4.0f, animation));
+ faceTextureUv = vec3(uv[gl_VertexID], uvLayer);
+ faceTextureUv.y -= (uv[2].y - uv[0].y) * trunc(mod(globalTime * 4.0f, animation));
faceNormal = normal;
faceAddColor = color;
diff --git a/cwd/assets/altcraft/shaders/vert/fbo.vs b/cwd/assets/altcraft/shaders/vert/fbo.vs
index e1e8966..e490da5 100644
--- a/cwd/assets/altcraft/shaders/vert/fbo.vs
+++ b/cwd/assets/altcraft/shaders/vert/fbo.vs
@@ -1,11 +1,18 @@
#version 330 core
-layout (location = 0) in vec2 Pos;
-layout (location = 1) in vec2 TextureCoords;
-out vec2 TexCoords;
+in vec2 pos;
+in vec2 uvPos;
-void main()
-{
- gl_Position = vec4(Pos.x, Pos.y, 0.0, 1.0);
- TexCoords = TextureCoords;
-} \ No newline at end of file
+out vec2 uv;
+
+layout (std140) uniform Globals {
+ mat4 projView;
+ uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
+};
+
+void main() {
+ gl_Position = vec4(pos.x, pos.y, 0.0, 1.0);
+ uv = uvPos;
+}
diff --git a/cwd/assets/altcraft/shaders/vert/light.vs b/cwd/assets/altcraft/shaders/vert/light.vs
index f837ebe..0033107 100644
--- a/cwd/assets/altcraft/shaders/vert/light.vs
+++ b/cwd/assets/altcraft/shaders/vert/light.vs
@@ -5,6 +5,13 @@ in vec2 uvPos;
out vec2 uv;
+layout (std140) uniform Globals {
+ mat4 projView;
+ uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
+};
+
void main() {
gl_Position = vec4(pos.x, pos.y, 0.0, 1.0);
uv = uvPos;
diff --git a/cwd/assets/altcraft/shaders/vert/pp.vs b/cwd/assets/altcraft/shaders/vert/pp.vs
index f837ebe..0033107 100644
--- a/cwd/assets/altcraft/shaders/vert/pp.vs
+++ b/cwd/assets/altcraft/shaders/vert/pp.vs
@@ -5,6 +5,13 @@ in vec2 uvPos;
out vec2 uv;
+layout (std140) uniform Globals {
+ mat4 projView;
+ uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
+};
+
void main() {
gl_Position = vec4(pos.x, pos.y, 0.0, 1.0);
uv = uvPos;
diff --git a/cwd/assets/altcraft/shaders/vert/rml.vs b/cwd/assets/altcraft/shaders/vert/rml.vs
index bdd3b71..d82308e 100644
--- a/cwd/assets/altcraft/shaders/vert/rml.vs
+++ b/cwd/assets/altcraft/shaders/vert/rml.vs
@@ -1,22 +1,25 @@
#version 330 core
-uniform uvec2 viewportSize;
-uniform vec2 translation;
-uniform mat4 rotationMat;
+in vec2 pos;
+in uvec4 col;
+in vec2 uvPos;
+
+out vec4 color;
+out vec2 uv;
-layout (location = 0) in vec2 pos;
-layout (location = 1) in uvec4 color;
-layout (location = 2) in vec2 tex_coord;
+uniform vec2 translation;
-out VS_OUT {
- vec4 color;
- vec2 tex_coord;
-} vs_out;
+layout (std140) uniform Globals {
+ mat4 projView;
+ uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
+};
void main() {
float x = ((pos.x + translation.x) / viewportSize.x) * 2.0f - 1.0f;
float y = ((pos.y + translation.y) / viewportSize.y) * 2.0f - 1.0f;
gl_Position = vec4(x, -y, -1.0f, 1.0f);
- vs_out.color = vec4(float(color.x) / 255.0f, float(color.y) / 255.0f, float(color.z) / 255.0f, float(color.w) / 255.0f);
- vs_out.tex_coord = tex_coord;
+ color = vec4(float(col.x) / 255.0f, float(col.y) / 255.0f, float(col.z) / 255.0f, float(col.w) / 255.0f);
+ uv = uvPos;
}
diff --git a/cwd/assets/altcraft/shaders/vert/sky.vs b/cwd/assets/altcraft/shaders/vert/sky.vs
index 0ab261c..e580843 100644
--- a/cwd/assets/altcraft/shaders/vert/sky.vs
+++ b/cwd/assets/altcraft/shaders/vert/sky.vs
@@ -1,13 +1,19 @@
#version 330 core
-in vec3 position;
+in vec3 pos;
-out vec3 pos;
+out vec3 facePos;
-uniform mat4 projView;
uniform mat4 model;
+layout (std140) uniform Globals {
+ mat4 projView;
+ uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
+};
+
void main() {
- pos = position;
- gl_Position = projView * model * vec4(position, 1);
+ facePos = pos;
+ gl_Position = projView * model * vec4(pos, 1);
}
diff --git a/src/GalOgl.cpp b/src/GalOgl.cpp
index 854ab40..961c6ef 100644
--- a/src/GalOgl.cpp
+++ b/src/GalOgl.cpp
@@ -1049,6 +1049,8 @@ struct ImplOgl : public Impl {
throw std::runtime_error("GLEW initialization failed with unknown reason");
}
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
GLint flags;
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
diff --git a/src/Render.cpp b/src/Render.cpp
index 8a5253c..682b60a 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -172,8 +172,8 @@ void Render::PrepareToRendering() {
fbPPC->SetPixelShader(gal->LoadPixelShader(pixelSource));
fbPPC->AddStaticTexture("inputTexture", gbuffer->GetFinalTexture());
auto fbColorBB = fbPPC->BindVertexBuffer({
- {"Pos", Gal::Type::Vec2},
- {"TextureCoords", Gal::Type::Vec2}
+ {"pos", Gal::Type::Vec2},
+ {"uvPos", Gal::Type::Vec2}
});
fbPipeline = gal->BuildPipeline(fbPPC);
@@ -213,7 +213,6 @@ void Render::RenderFrame() {
Gal::GetImplementation()->SetWireframe(true);
if (renderWorld) {
world->Render(static_cast<float>(windowWidth) / static_cast<float>(windowHeight));
- gbuffer->SetDayTime(world->shaderDayTime);
}
if (isWireframe)
Gal::GetImplementation()->SetWireframe(false);
@@ -256,6 +255,7 @@ void Render::HandleEvents() {
windowHeight = height;
rmlRender->Update(width, height);
rmlContext->SetDimensions(Rml::Vector2i(width, height));
+ Gal::GetImplementation()->GetGlobalShaderParameters()->Get<GlobalShaderParameters>()->viewportSize = glm::uvec2(width, height);
PrepareToRendering();
break;
}
@@ -613,6 +613,7 @@ void Render::InitRml() {
rmlRender = std::make_unique<RmlRenderInterface>();
Rml::SetRenderInterface(rmlRender.get());
rmlRender->Update(windowWidth, windowHeight);
+ Gal::GetImplementation()->GetGlobalShaderParameters()->Get<GlobalShaderParameters>()->viewportSize = glm::uvec2(windowWidth, windowHeight);
rmlFile = std::make_unique<RmlFileInterface>();
Rml::SetFileInterface(rmlFile.get());
diff --git a/src/RenderConfigs.cpp b/src/RenderConfigs.cpp
index d62d204..aad2c59 100644
--- a/src/RenderConfigs.cpp
+++ b/src/RenderConfigs.cpp
@@ -124,7 +124,6 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH) {
};
std::vector<std::pair<std::string_view, Gal::Type>> lightingParameters = {
- {"dayTime", Gal::Type::Float},
{"renderBuff", Gal::Type::Int32},
};
diff --git a/src/RenderConfigs.hpp b/src/RenderConfigs.hpp
index a9d6c00..da7fd96 100644
--- a/src/RenderConfigs.hpp
+++ b/src/RenderConfigs.hpp
@@ -4,6 +4,9 @@
struct GlobalShaderParameters {
glm::mat4 projView;
+ glm::uvec2 viewportSize;
+ float globalTime;
+ float dayTime;
};
std::shared_ptr<Gal::Shader> LoadVertexShader(std::string_view assetPath);
@@ -76,10 +79,6 @@ public:
lightingPass->Clear();
}
- void SetDayTime(float dayTime) {
- lightingPass->SetShaderParameter("dayTime", dayTime);
- }
-
int GetMaxRenderBuffers() {
return 5;
}
diff --git a/src/RendererEntity.cpp b/src/RendererEntity.cpp
index 02a5f54..d014bdb 100644
--- a/src/RendererEntity.cpp
+++ b/src/RendererEntity.cpp
@@ -18,5 +18,5 @@ void RendererEntity::Render(std::shared_ptr<Gal::Pipeline> pipeline, const World
model = glm::scale(model, glm::vec3(entity.width, entity.height, entity.width));
pipeline->SetShaderParameter("model", model);
- pipeline->SetShaderParameter("color", entity.renderColor);
+ pipeline->SetShaderParameter("entityColor", entity.renderColor);
}
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index 2434ed1..c6d490a 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -256,10 +256,9 @@ RendererWorld::RendererWorld(std::shared_ptr<Gal::Framebuffer> target) {
sections.erase(it);
});
- listener->RegisterHandler("SetMinLightLevel", [this](const Event& eventData) {
- auto value = eventData.get<float>();
- sectionsPipeline->SetShaderParameter("MinLightLevel", value);
- });
+ listener->RegisterHandler("SetMinLightLevel", [this](const Event& eventData) {
+
+ });
for (int i = 0; i < numOfWorkers; i++)
workers.push_back(std::thread(&RendererWorld::WorkerFunction, this, i));
@@ -290,13 +289,12 @@ void RendererWorld::Render(float screenRatio) {
glm::mat4 view = GetGameState()->GetViewMatrix();
glm::mat4 projView = projection * view;
- Gal::GetImplementation()->GetGlobalShaderParameters()->Get<GlobalShaderParameters>()->projView = projView;
+ auto globalSpb = Gal::GetImplementation()->GetGlobalShaderParameters();
+ globalSpb->Get<GlobalShaderParameters>()->projView = projView;
//Render Entities
constexpr size_t entitiesVerticesCount = 240;
entitiesPipeline->Activate();
- entitiesPipeline->SetShaderParameter("projView", projView);
-
entitiesPipelineInstance->Activate();
for (auto& it : entities) {
it.Render(entitiesPipeline, &GetGameState()->GetWorld());
@@ -312,7 +310,7 @@ void RendererWorld::Render(float screenRatio) {
model = glm::translate(model,glm::vec3(0.5f,0.5f,0.5f));
model = glm::scale(model,glm::vec3(1.01f,1.01f,1.01f));
entitiesPipeline->SetShaderParameter("model", model);
- entitiesPipeline->SetShaderParameter("color", glm::vec3(0, 0, 0));
+ entitiesPipeline->SetShaderParameter("entityColor", glm::vec3(0, 0, 0));
entitiesPipelineInstance->Render(0, entitiesVerticesCount);
}
}
@@ -328,9 +326,9 @@ void RendererWorld::Render(float screenRatio) {
//entityShader->SetUniform("model", model);
entitiesPipeline->SetShaderParameter("model", model);
if (selectedBlock == Vector())
- entitiesPipeline->SetShaderParameter("color", glm::vec3(0.7f, 0.0f, 0.0f));
+ entitiesPipeline->SetShaderParameter("entityColor", glm::vec3(0.7f, 0.0f, 0.0f));
else
- entitiesPipeline->SetShaderParameter("color", glm::vec3(0.0f, 0.0f, 0.7f));
+ entitiesPipeline->SetShaderParameter("entityColor", glm::vec3(0.0f, 0.0f, 0.7f));
entitiesPipelineInstance->Render(0, entitiesVerticesCount);
}
}
@@ -369,12 +367,11 @@ void RendererWorld::Render(float screenRatio) {
float timePassed = (dayTime - moonriseMin);
mixLevel = 1.0 - (timePassed / moonriseLength);
}
- shaderDayTime = mixLevel;
+
+ globalSpb->Get<GlobalShaderParameters>()->dayTime = mixLevel;
skyPipeline->Activate();
- skyPipeline->SetShaderParameter("projView", projView);
skyPipeline->SetShaderParameter("model", model);
- skyPipeline->SetShaderParameter("DayTime", mixLevel);
skyPipelineInstance->Activate();
skyPipelineInstance->Render(0, 36);
@@ -382,10 +379,8 @@ void RendererWorld::Render(float screenRatio) {
//Render sections
auto rawGlobalTime = (std::chrono::high_resolution_clock::now() - globalTimeStart);
float globalTime = rawGlobalTime.count() / 1000000000.0f;
+ globalSpb->Get<GlobalShaderParameters>()->globalTime = globalTime;
sectionsPipeline->Activate();
- sectionsPipeline->SetShaderParameter("DayTime", mixLevel);
- sectionsPipeline->SetShaderParameter("projView", projView);
- sectionsPipeline->SetShaderParameter("GlobalTime", globalTime);
Frustum frustum(projView);
@@ -443,16 +438,12 @@ void RendererWorld::PrepareRender(std::shared_ptr<Gal::Framebuffer> target) {
{
auto sectionsPLC = gal->CreatePipelineConfig();
sectionsPLC->SetTarget(target);
- sectionsPLC->AddShaderParameter("projView", Gal::Type::Mat4);
- sectionsPLC->AddShaderParameter("DayTime", Gal::Type::Float);
- sectionsPLC->AddShaderParameter("GlobalTime", Gal::Type::Float);
- sectionsPLC->AddShaderParameter("MinLightLevel", Gal::Type::Float);
sectionsPLC->AddStaticTexture("textureAtlas", AssetManager::GetTextureAtlas());
sectionsPLC->SetVertexShader(gal->LoadVertexShader(sectionVertexSource));
sectionsPLC->SetPixelShader(gal->LoadPixelShader(sectionPixelSource));
sectionsPLC->SetPrimitive(Gal::Primitive::TriangleFan);
sectionsBufferBinding = sectionsPLC->BindVertexBuffer({
- {"position", Gal::Type::Vec3, 4, 1},
+ {"pos", Gal::Type::Vec3, 4, 1},
{"normal", Gal::Type::Vec3, 1, 1},
{"uv", Gal::Type::Vec2, 4, 1},
{"uvLayer", Gal::Type::Float, 1, 1},
@@ -462,20 +453,18 @@ void RendererWorld::PrepareRender(std::shared_ptr<Gal::Framebuffer> target) {
{"", Gal::Type::Uint8, 8, 1}
});
sectionsPipeline = gal->BuildPipeline(sectionsPLC);
- sectionsPipeline->SetShaderParameter("MinLightLevel", 0.2f);
}
{
auto entitiesPLC = gal->CreatePipelineConfig();
entitiesPLC->SetTarget(target);
- entitiesPLC->AddShaderParameter("projView", Gal::Type::Mat4);
entitiesPLC->AddShaderParameter("model", Gal::Type::Mat4);
- entitiesPLC->AddShaderParameter("color", Gal::Type::Vec3);
+ entitiesPLC->AddShaderParameter("entityColor", Gal::Type::Vec3);
entitiesPLC->SetVertexShader(gal->LoadVertexShader(entitiesVertexSource));
entitiesPLC->SetPixelShader(gal->LoadPixelShader(entitiesPixelSource));
entitiesPLC->SetPrimitive(Gal::Primitive::Triangle);
auto entitiesPosBB = entitiesPLC->BindVertexBuffer({
- {"position", Gal::Type::Vec3},
+ {"pos", Gal::Type::Vec3},
});
auto entitiesIndicesBB = entitiesPLC->BindIndexBuffer();
@@ -636,14 +625,12 @@ void RendererWorld::PrepareRender(std::shared_ptr<Gal::Framebuffer> target) {
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->AddStaticTexture("textureAtlas", AssetManager::GetTextureAtlas());
skyPPC->SetVertexShader(gal->LoadVertexShader(skyVertexSource));
skyPPC->SetPixelShader(gal->LoadPixelShader(skyPixelSource));
auto skyPosUvBB = skyPPC->BindVertexBuffer({
- {"position", Gal::Type::Vec3},
+ {"pos", Gal::Type::Vec3},
{"", Gal::Type::Vec2},
});
diff --git a/src/Rml.cpp b/src/Rml.cpp
index fa2d4e7..746f6a4 100644
--- a/src/Rml.cpp
+++ b/src/Rml.cpp
@@ -64,7 +64,6 @@ RmlRenderInterface::RmlRenderInterface() {
{
auto pipelineConfig = gal->CreatePipelineConfig();
- pipelineConfig->AddShaderParameter("viewportSize", Gal::Type::Vec2u32);
pipelineConfig->AddShaderParameter("translation", Gal::Type::Vec2);
pipelineConfig->SetTarget(gal->GetDefaultFramebuffer());
pipelineConfig->SetVertexShader(gal->LoadVertexShader(vertexSource));
@@ -72,7 +71,7 @@ RmlRenderInterface::RmlRenderInterface() {
auto vertBuffBind = pipelineConfig->BindVertexBuffer({
{"pos", Gal::Type::Vec2},
- {"color", Gal::Type::Vec4u8},
+ {"col", Gal::Type::Vec4u8},
{"", Gal::Type::Vec2}, //it's not used in shader, so driver optimizes it away
});
@@ -88,7 +87,6 @@ RmlRenderInterface::RmlRenderInterface() {
{
auto texPipelineConfig = gal->CreatePipelineConfig();
- texPipelineConfig->AddShaderParameter("viewportSize", Gal::Type::Vec2u32);
texPipelineConfig->AddShaderParameter("translation", Gal::Type::Vec2);
texPipelineConfig->AddShaderParameter("fontTexture", Gal::Type::Int32);
texPipelineConfig->SetTarget(gal->GetDefaultFramebuffer());
@@ -97,8 +95,8 @@ RmlRenderInterface::RmlRenderInterface() {
auto texVertBuffBind = texPipelineConfig->BindVertexBuffer({
{"pos", Gal::Type::Vec2},
- {"color", Gal::Type::Vec4u8},
- {"tex_coord", Gal::Type::Vec2},
+ {"col", Gal::Type::Vec4u8},
+ {"uvPos", Gal::Type::Vec2},
});
auto texIndexBuffBind = texPipelineConfig->BindIndexBuffer();
@@ -165,9 +163,6 @@ void RmlRenderInterface::ReleaseTexture(Rml::TextureHandle texture) {
}
void RmlRenderInterface::Update(unsigned int windowWidth, unsigned int windowHeight) {
- pipeline->SetShaderParameter("viewportSize", glm::uvec2(windowWidth, windowHeight));
- texPipeline->SetShaderParameter("viewportSize", glm::uvec2(windowWidth, windowHeight));
-
vpWidth = windowWidth;
vpHeight = windowHeight;
}