From 5a6aaf633ce217f828d981cd8c55951ada67e2df Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 27 Jun 2021 21:31:00 +0500 Subject: Moved block face model matrix transformation to CPU --- src/RendererSection.cpp | 73 +++++++++++++++++++-------------------------- src/RendererSection.hpp | 4 +-- src/RendererSectionData.cpp | 10 +++++-- src/RendererSectionData.hpp | 2 +- 4 files changed, 41 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp index d797771..1e0a1d0 100644 --- a/src/RendererSection.cpp +++ b/src/RendererSection.cpp @@ -7,16 +7,6 @@ #include "Renderer.hpp" #include "RendererSectionData.hpp" -const GLfloat vertices[] = { - 0, 0, 0, - 1, 0, 1, - 1, 0, 0, - - 0, 0, 0, - 0, 0, 1, - 1, 0, 1, -}; - const GLfloat uv_coords[] = { 0.0f, 0.0f, 1.0f, 1.0f, @@ -28,25 +18,18 @@ const GLfloat uv_coords[] = { }; const GLuint magicUniqueConstant = 88375; -GLuint RendererSection::VboVertices = magicUniqueConstant; GLuint RendererSection::VboUvs = magicUniqueConstant; RendererSection::RendererSection(const RendererSectionData &data) { OPTICK_EVENT(); - if (VboVertices == magicUniqueConstant) { - glGenBuffers(1, &VboVertices); + if (VboUvs == magicUniqueConstant) { glGenBuffers(1, &VboUvs); - //Cube vertices - glBindBuffer(GL_ARRAY_BUFFER, VboVertices); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); - //Cube UVs glBindBuffer(GL_ARRAY_BUFFER, VboUvs); glBufferData(GL_ARRAY_BUFFER, sizeof(uv_coords), uv_coords, GL_STATIC_DRAW); - LOG(INFO) << "Created VBOs with vertices (" << VboVertices << ") and UVs (" << VboUvs - << ") for faces"; + LOG(INFO) << "Created VBOs with UVs (" << VboUvs << ") for faces"; } glGenVertexArrays(1, &Vao); @@ -56,10 +39,31 @@ RendererSection::RendererSection(const RendererSectionData &data) { glBindVertexArray(Vao); { //Cube vertices - GLuint VertAttribPos = 0; - glBindBuffer(GL_ARRAY_BUFFER, VboVertices); - glVertexAttribPointer(VertAttribPos, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr); + GLuint VertAttribPos = 3; + glBindBuffer(GL_ARRAY_BUFFER, Vbo[POSITIONS]); + glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), nullptr); glEnableVertexAttribArray(VertAttribPos); + glVertexAttribDivisor(VertAttribPos, 1); + + glVertexAttribPointer(VertAttribPos + 1, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(1 * 4 * sizeof(GLfloat))); + glEnableVertexAttribArray(VertAttribPos + 1); + glVertexAttribDivisor(VertAttribPos + 1, 1); + + glVertexAttribPointer(VertAttribPos + 2, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(2 * 4 * sizeof(GLfloat))); + glEnableVertexAttribArray(VertAttribPos + 2); + glVertexAttribDivisor(VertAttribPos + 2, 1); + + glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(3 * 4 * sizeof(GLfloat))); + glEnableVertexAttribArray(VertAttribPos + 3); + glVertexAttribDivisor(VertAttribPos + 3, 1); + + glVertexAttribPointer(VertAttribPos + 4, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(4 * 4 * sizeof(GLfloat))); + glEnableVertexAttribArray(VertAttribPos + 4); + glVertexAttribDivisor(VertAttribPos + 4, 1); + + glVertexAttribPointer(VertAttribPos + 5, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(5 * 4 * sizeof(GLfloat))); + glEnableVertexAttribArray(VertAttribPos + 5); + glVertexAttribDivisor(VertAttribPos + 5, 1); //Cube UVs GLuint UvAttribPos = 2; @@ -68,7 +72,7 @@ RendererSection::RendererSection(const RendererSectionData &data) { glEnableVertexAttribArray(UvAttribPos); //Textures - GLuint textureAttribPos = 7; + GLuint textureAttribPos = 11; glBindBuffer(GL_ARRAY_BUFFER, Vbo[TEXTURES]); glVertexAttribPointer(textureAttribPos, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), nullptr); glEnableVertexAttribArray(textureAttribPos); @@ -91,23 +95,6 @@ RendererSection::RendererSection(const RendererSectionData &data) { glVertexAttribDivisor(framesAttribPos, 1); glCheckError(); - //Blocks models - GLuint matAttribPos = 8; - size_t sizeOfMat4 = 4 * 4 * sizeof(GLfloat); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[MODELS]); - glVertexAttribPointer(matAttribPos + 0, 4, GL_FLOAT, GL_FALSE, sizeOfMat4, nullptr); - glVertexAttribPointer(matAttribPos + 1, 4, GL_FLOAT, GL_FALSE, sizeOfMat4, (void *)(1 * 4 * sizeof(GLfloat))); - glVertexAttribPointer(matAttribPos + 2, 4, GL_FLOAT, GL_FALSE, sizeOfMat4, (void *)(2 * 4 * sizeof(GLfloat))); - glVertexAttribPointer(matAttribPos + 3, 4, GL_FLOAT, GL_FALSE, sizeOfMat4, (void *)(3 * 4 * sizeof(GLfloat))); - glEnableVertexAttribArray(matAttribPos + 0); - glEnableVertexAttribArray(matAttribPos + 1); - glEnableVertexAttribArray(matAttribPos + 2); - glEnableVertexAttribArray(matAttribPos + 3); - glVertexAttribDivisor(matAttribPos + 0, 1); - glVertexAttribDivisor(matAttribPos + 1, 1); - glVertexAttribDivisor(matAttribPos + 2, 1); - glVertexAttribDivisor(matAttribPos + 3, 1); - //Color GLuint colorAttribPos = 12; glBindBuffer(GL_ARRAY_BUFFER, Vbo[COLORS]); @@ -159,7 +146,7 @@ void swap(RendererSection & lhs, RendererSection & rhs) { void RendererSection::Render(RenderState &renderState) { OPTICK_EVENT(); renderState.SetActiveVao(Vao); - glDrawArraysInstanced(GL_TRIANGLES, 0, 6, numOfFaces); + glDrawArraysInstanced(GL_TRIANGLES, 0, 6, numOfFaces); glCheckError(); } @@ -182,8 +169,8 @@ void RendererSection::UpdateData(const RendererSectionData & data) { glBindBuffer(GL_ARRAY_BUFFER, Vbo[FRAMES]); glBufferData(GL_ARRAY_BUFFER, data.textureFrames.size() * 1 * sizeof(GLfloat), data.textureFrames.data(), GL_DYNAMIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[MODELS]); - glBufferData(GL_ARRAY_BUFFER, data.models.size() * sizeof(glm::mat4), data.models.data(), GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, Vbo[POSITIONS]); + glBufferData(GL_ARRAY_BUFFER, data.positions.size() * sizeof(glm::vec4), data.positions.data(), GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, Vbo[COLORS]); glBufferData(GL_ARRAY_BUFFER, data.colors.size() * sizeof(glm::vec3), data.colors.data(), GL_DYNAMIC_DRAW); diff --git a/src/RendererSection.hpp b/src/RendererSection.hpp index 29b5db1..dd01c49 100644 --- a/src/RendererSection.hpp +++ b/src/RendererSection.hpp @@ -10,7 +10,7 @@ class RendererSectionData; class RendererSection { enum Vbos { - MODELS = 0, + POSITIONS = 0, TEXTURES, LAYERS, FRAMES, @@ -21,7 +21,7 @@ class RendererSection { GLuint Vao = { 0 }; GLuint Vbo[VBOCOUNT] = { 0 }; - static GLuint VboVertices, VboUvs; + static GLuint VboUvs; size_t hash; Vector sectionPos; diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index 69ed665..cf05528 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -37,7 +37,13 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co continue; lightness = glm::vec2(light.face[faceDirection], skyLight.face[faceDirection]); } - data.models.push_back(transform * model.transform * face.transform); + glm::mat4 transformed = transform * model.transform * face.transform; + data.positions.push_back(transformed * glm::vec4(0, 0, 0, 1)); + data.positions.push_back(transformed * glm::vec4(1, 0, 1, 1)); + data.positions.push_back(transformed * glm::vec4(1, 0, 0, 1)); + data.positions.push_back(transformed * glm::vec4(0, 0, 0, 1)); + data.positions.push_back(transformed * glm::vec4(0, 0, 1, 1)); + data.positions.push_back(transformed * glm::vec4(1, 0, 1, 1)); data.textures.push_back(face.texture); data.textureLayers.push_back(face.layer); data.textureFrames.push_back(face.frames); @@ -137,7 +143,7 @@ RendererSectionData ParseSection(const SectionsData §ions) { } data.textures.shrink_to_fit(); data.textureLayers.shrink_to_fit(); - data.models.shrink_to_fit(); + data.positions.shrink_to_fit(); data.colors.shrink_to_fit(); return data; diff --git a/src/RendererSectionData.hpp b/src/RendererSectionData.hpp index cedb51b..3062d0c 100644 --- a/src/RendererSectionData.hpp +++ b/src/RendererSectionData.hpp @@ -31,7 +31,7 @@ struct SectionsData { }; struct RendererSectionData { - std::vector models; + std::vector positions; std::vector textures; std::vector textureLayers; std::vector textureFrames; -- cgit v1.2.3 From f324c49d896eae159b7499ad6467f03dbcc900ca Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 28 Jun 2021 16:25:32 +0500 Subject: More compact faces vertecies format --- src/RendererSection.cpp | 28 +++++++++------------------- src/RendererSectionData.cpp | 4 +--- 2 files changed, 10 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp index 1e0a1d0..e19043d 100644 --- a/src/RendererSection.cpp +++ b/src/RendererSection.cpp @@ -9,12 +9,10 @@ const GLfloat uv_coords[] = { 0.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f, - - 0.0f, 0.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + }; const GLuint magicUniqueConstant = 88375; @@ -41,30 +39,22 @@ RendererSection::RendererSection(const RendererSectionData &data) { //Cube vertices GLuint VertAttribPos = 3; glBindBuffer(GL_ARRAY_BUFFER, Vbo[POSITIONS]); - glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), nullptr); + glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), nullptr); glEnableVertexAttribArray(VertAttribPos); glVertexAttribDivisor(VertAttribPos, 1); - glVertexAttribPointer(VertAttribPos + 1, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(1 * 4 * sizeof(GLfloat))); + glVertexAttribPointer(VertAttribPos + 1, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(1 * 4 * sizeof(GLfloat))); glEnableVertexAttribArray(VertAttribPos + 1); glVertexAttribDivisor(VertAttribPos + 1, 1); - glVertexAttribPointer(VertAttribPos + 2, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(2 * 4 * sizeof(GLfloat))); + glVertexAttribPointer(VertAttribPos + 2, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(2 * 4 * sizeof(GLfloat))); glEnableVertexAttribArray(VertAttribPos + 2); glVertexAttribDivisor(VertAttribPos + 2, 1); - glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(3 * 4 * sizeof(GLfloat))); + glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(3 * 4 * sizeof(GLfloat))); glEnableVertexAttribArray(VertAttribPos + 3); glVertexAttribDivisor(VertAttribPos + 3, 1); - glVertexAttribPointer(VertAttribPos + 4, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(4 * 4 * sizeof(GLfloat))); - glEnableVertexAttribArray(VertAttribPos + 4); - glVertexAttribDivisor(VertAttribPos + 4, 1); - - glVertexAttribPointer(VertAttribPos + 5, 4, GL_FLOAT, GL_FALSE, 6 * 4 * sizeof(GLfloat), (void*)(5 * 4 * sizeof(GLfloat))); - glEnableVertexAttribArray(VertAttribPos + 5); - glVertexAttribDivisor(VertAttribPos + 5, 1); - //Cube UVs GLuint UvAttribPos = 2; glBindBuffer(GL_ARRAY_BUFFER, VboUvs); @@ -146,7 +136,7 @@ void swap(RendererSection & lhs, RendererSection & rhs) { void RendererSection::Render(RenderState &renderState) { OPTICK_EVENT(); renderState.SetActiveVao(Vao); - glDrawArraysInstanced(GL_TRIANGLES, 0, 6, numOfFaces); + glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, numOfFaces); glCheckError(); } diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index cf05528..eabfee2 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -39,11 +39,9 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co } glm::mat4 transformed = transform * model.transform * face.transform; data.positions.push_back(transformed * glm::vec4(0, 0, 0, 1)); - data.positions.push_back(transformed * glm::vec4(1, 0, 1, 1)); - data.positions.push_back(transformed * glm::vec4(1, 0, 0, 1)); - data.positions.push_back(transformed * glm::vec4(0, 0, 0, 1)); data.positions.push_back(transformed * glm::vec4(0, 0, 1, 1)); data.positions.push_back(transformed * glm::vec4(1, 0, 1, 1)); + data.positions.push_back(transformed * glm::vec4(1, 0, 0, 1)); data.textures.push_back(face.texture); data.textureLayers.push_back(face.layer); data.textureFrames.push_back(face.frames); -- cgit v1.2.3 From 04ad0ef50d7eb362fd13272fd1d610740b3ede5e Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 28 Jun 2021 20:20:49 +0500 Subject: Embed UV to vertex data --- src/RendererSection.cpp | 118 +++++++++++++++++++++----------------------- src/RendererSection.hpp | 8 ++- src/RendererSectionData.cpp | 29 ++++++++--- src/RendererSectionData.hpp | 10 ++-- 4 files changed, 87 insertions(+), 78 deletions(-) (limited to 'src') diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp index e19043d..df8d3c7 100644 --- a/src/RendererSection.cpp +++ b/src/RendererSection.cpp @@ -7,37 +7,17 @@ #include "Renderer.hpp" #include "RendererSectionData.hpp" -const GLfloat uv_coords[] = { - 0.0f, 0.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f, - -}; - -const GLuint magicUniqueConstant = 88375; -GLuint RendererSection::VboUvs = magicUniqueConstant; - RendererSection::RendererSection(const RendererSectionData &data) { OPTICK_EVENT(); - if (VboUvs == magicUniqueConstant) { - glGenBuffers(1, &VboUvs); - - //Cube UVs - glBindBuffer(GL_ARRAY_BUFFER, VboUvs); - glBufferData(GL_ARRAY_BUFFER, sizeof(uv_coords), uv_coords, GL_STATIC_DRAW); - - LOG(INFO) << "Created VBOs with UVs (" << VboUvs << ") for faces"; - } glGenVertexArrays(1, &Vao); - + glGenBuffers(VBOCOUNT, Vbo); glBindVertexArray(Vao); { //Cube vertices - GLuint VertAttribPos = 3; + GLuint VertAttribPos = 0; glBindBuffer(GL_ARRAY_BUFFER, Vbo[POSITIONS]); glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), nullptr); glEnableVertexAttribArray(VertAttribPos); @@ -54,50 +34,63 @@ RendererSection::RendererSection(const RendererSectionData &data) { glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(3 * 4 * sizeof(GLfloat))); glEnableVertexAttribArray(VertAttribPos + 3); glVertexAttribDivisor(VertAttribPos + 3, 1); + glCheckError(); - //Cube UVs - GLuint UvAttribPos = 2; - glBindBuffer(GL_ARRAY_BUFFER, VboUvs); - glVertexAttribPointer(UvAttribPos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr); + //Cube uvs + GLuint UvAttribPos = 4; + glBindBuffer(GL_ARRAY_BUFFER, Vbo[UVS]); + glVertexAttribPointer(UvAttribPos, 2, GL_FLOAT, GL_FALSE, 4 * 2 * sizeof(GLfloat), nullptr); glEnableVertexAttribArray(UvAttribPos); + glVertexAttribDivisor(UvAttribPos, 1); + + glVertexAttribPointer(UvAttribPos + 1, 2, GL_FLOAT, GL_FALSE, 4 * 2 * sizeof(GLfloat), (void*)(1 * 2 * sizeof(GLfloat))); + glEnableVertexAttribArray(UvAttribPos + 1); + glVertexAttribDivisor(UvAttribPos + 1, 1); + + glVertexAttribPointer(UvAttribPos + 2, 2, GL_FLOAT, GL_FALSE, 4 * 2 * sizeof(GLfloat), (void*)(2 * 2 * sizeof(GLfloat))); + glEnableVertexAttribArray(UvAttribPos + 2); + glVertexAttribDivisor(UvAttribPos + 2, 1); - //Textures - GLuint textureAttribPos = 11; - glBindBuffer(GL_ARRAY_BUFFER, Vbo[TEXTURES]); - glVertexAttribPointer(textureAttribPos, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), nullptr); - glEnableVertexAttribArray(textureAttribPos); - glVertexAttribDivisor(textureAttribPos, 1); + glVertexAttribPointer(UvAttribPos + 3, 2, GL_FLOAT, GL_FALSE, 4 * 2 * sizeof(GLfloat), (void*)(3 * 2 * sizeof(GLfloat))); + glEnableVertexAttribArray(UvAttribPos + 3); + glVertexAttribDivisor(UvAttribPos + 3, 1); glCheckError(); - //TextureLayers - GLuint layerAttribPos = 14; - glBindBuffer(GL_ARRAY_BUFFER, Vbo[LAYERS]); - glVertexAttribPointer(layerAttribPos, 1, GL_FLOAT, GL_FALSE, sizeof(GLfloat), nullptr); - glEnableVertexAttribArray(layerAttribPos); - glVertexAttribDivisor(layerAttribPos, 1); - glCheckError(); - - //TextureFrames - GLuint framesAttribPos = 15; - glBindBuffer(GL_ARRAY_BUFFER, Vbo[FRAMES]); - glVertexAttribPointer(framesAttribPos, 1, GL_FLOAT, GL_FALSE, sizeof(GLfloat), nullptr); - glEnableVertexAttribArray(framesAttribPos); - glVertexAttribDivisor(framesAttribPos, 1); - glCheckError(); + //Uv Layer + GLuint uvLayerAttribPos = 8; + glBindBuffer(GL_ARRAY_BUFFER, Vbo[UVLAYERS]); + glVertexAttribPointer(uvLayerAttribPos, 1, GL_FLOAT, GL_FALSE, sizeof(GLfloat), nullptr); + glEnableVertexAttribArray(uvLayerAttribPos); + glVertexAttribDivisor(uvLayerAttribPos, 1); + glCheckError(); + + //Animation + GLuint animationAttribPos = 9; + glCheckError(); + glBindBuffer(GL_ARRAY_BUFFER, Vbo[ANIMATIONS]); + glCheckError(); + glVertexAttribPointer(animationAttribPos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr); + glCheckError(); + glEnableVertexAttribArray(animationAttribPos); + glCheckError(); + glVertexAttribDivisor(animationAttribPos, 1); + glCheckError(); //Color - GLuint colorAttribPos = 12; + GLuint colorAttribPos = 10; glBindBuffer(GL_ARRAY_BUFFER, Vbo[COLORS]); glVertexAttribPointer(colorAttribPos, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr); glEnableVertexAttribArray(colorAttribPos); glVertexAttribDivisor(colorAttribPos, 1); + glCheckError(); //Light - GLuint lightAttribPos = 13; + GLuint lightAttribPos = 11; glBindBuffer(GL_ARRAY_BUFFER, Vbo[LIGHTS]); glVertexAttribPointer(lightAttribPos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr); glEnableVertexAttribArray(lightAttribPos); glVertexAttribDivisor(lightAttribPos, 1); + glCheckError(); glBindBuffer(GL_ARRAY_BUFFER, 0); } @@ -150,28 +143,29 @@ size_t RendererSection::GetHash() { void RendererSection::UpdateData(const RendererSectionData & data) { OPTICK_EVENT(); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[TEXTURES]); - glBufferData(GL_ARRAY_BUFFER, data.textures.size() * sizeof(glm::vec4), data.textures.data(), GL_DYNAMIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[LAYERS]); - glBufferData(GL_ARRAY_BUFFER, data.textureLayers.size() * 1* sizeof(GLfloat), data.textureLayers.data(), GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, Vbo[POSITIONS]); + glBufferData(GL_ARRAY_BUFFER, data.positions.size() * sizeof(glm::vec4), data.positions.data(), GL_DYNAMIC_DRAW); + + glBindBuffer(GL_ARRAY_BUFFER, Vbo[UVS]); + glBufferData(GL_ARRAY_BUFFER, data.uvs.size() * sizeof(glm::vec2), data.uvs.data(), GL_DYNAMIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[FRAMES]); - glBufferData(GL_ARRAY_BUFFER, data.textureFrames.size() * 1 * sizeof(GLfloat), data.textureFrames.data(), GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, Vbo[UVLAYERS]); + glBufferData(GL_ARRAY_BUFFER, data.uvLayers.size() * sizeof(GLfloat), data.uvLayers.data(), GL_DYNAMIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[POSITIONS]); - glBufferData(GL_ARRAY_BUFFER, data.positions.size() * sizeof(glm::vec4), data.positions.data(), GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, Vbo[ANIMATIONS]); + glBufferData(GL_ARRAY_BUFFER, data.animations.size() * sizeof(glm::vec2), data.animations.data(), GL_DYNAMIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[COLORS]); - glBufferData(GL_ARRAY_BUFFER, data.colors.size() * sizeof(glm::vec3), data.colors.data(), GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, Vbo[COLORS]); + glBufferData(GL_ARRAY_BUFFER, data.colors.size() * sizeof(glm::vec3), data.colors.data(), GL_DYNAMIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[LIGHTS]); - glBufferData(GL_ARRAY_BUFFER, data.lights.size() * sizeof(glm::vec2), data.lights.data(), GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, Vbo[LIGHTS]); + glBufferData(GL_ARRAY_BUFFER, data.lights.size() * sizeof(glm::vec2), data.lights.data(), GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glCheckError(); - numOfFaces = data.textures.size(); + numOfFaces = data.animations.size(); sectionPos = data.sectionPos; hash = data.hash; } diff --git a/src/RendererSection.hpp b/src/RendererSection.hpp index dd01c49..9bb55e3 100644 --- a/src/RendererSection.hpp +++ b/src/RendererSection.hpp @@ -11,9 +11,9 @@ class RendererSectionData; class RendererSection { enum Vbos { POSITIONS = 0, - TEXTURES, - LAYERS, - FRAMES, + UVS, + UVLAYERS, + ANIMATIONS, COLORS, LIGHTS, VBOCOUNT, @@ -21,8 +21,6 @@ class RendererSection { GLuint Vao = { 0 }; GLuint Vbo[VBOCOUNT] = { 0 }; - static GLuint VboUvs; - size_t hash; Vector sectionPos; diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index eabfee2..78e2239 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -15,6 +15,15 @@ inline const BlockId& GetBlockId(int x, int y, int z, const std::array positions; - std::vector textures; - std::vector textureLayers; - std::vector textureFrames; - std::vector colors; + std::vector positions; //4 per instance + std::vector uvs; //4 per instance + std::vector uvLayers; + std::vector animations; + std::vector colors; std::vector lights; size_t hash = 0; Vector sectionPos; -- cgit v1.2.3 From 7ff7b88cf66131a559ea0ee931bddce4785507a7 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 28 Jun 2021 20:55:59 +0500 Subject: Implemented vertex data iterleaving --- src/RendererSection.cpp | 76 ++++++++++++++------------------------------- src/RendererSection.hpp | 11 +------ src/RendererSectionData.cpp | 38 +++++++++++------------ src/RendererSectionData.hpp | 16 ++++++---- 4 files changed, 52 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp index df8d3c7..397a660 100644 --- a/src/RendererSection.cpp +++ b/src/RendererSection.cpp @@ -1,5 +1,7 @@ #include "RendererSection.hpp" +#include + #include #include @@ -12,85 +14,74 @@ RendererSection::RendererSection(const RendererSectionData &data) { glGenVertexArrays(1, &Vao); - glGenBuffers(VBOCOUNT, Vbo); + glGenBuffers(1, &Vbo); + glBindBuffer(GL_ARRAY_BUFFER, Vbo); glBindVertexArray(Vao); { //Cube vertices GLuint VertAttribPos = 0; - glBindBuffer(GL_ARRAY_BUFFER, Vbo[POSITIONS]); - glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), nullptr); + glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[0])); glEnableVertexAttribArray(VertAttribPos); glVertexAttribDivisor(VertAttribPos, 1); - glVertexAttribPointer(VertAttribPos + 1, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(1 * 4 * sizeof(GLfloat))); + glVertexAttribPointer(VertAttribPos + 1, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[1])); glEnableVertexAttribArray(VertAttribPos + 1); glVertexAttribDivisor(VertAttribPos + 1, 1); - glVertexAttribPointer(VertAttribPos + 2, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(2 * 4 * sizeof(GLfloat))); + glVertexAttribPointer(VertAttribPos + 2, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[2])); glEnableVertexAttribArray(VertAttribPos + 2); glVertexAttribDivisor(VertAttribPos + 2, 1); - glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, 4 * 4 * sizeof(GLfloat), (void*)(3 * 4 * sizeof(GLfloat))); + glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[3])); glEnableVertexAttribArray(VertAttribPos + 3); glVertexAttribDivisor(VertAttribPos + 3, 1); glCheckError(); //Cube uvs GLuint UvAttribPos = 4; - glBindBuffer(GL_ARRAY_BUFFER, Vbo[UVS]); - glVertexAttribPointer(UvAttribPos, 2, GL_FLOAT, GL_FALSE, 4 * 2 * sizeof(GLfloat), nullptr); + glVertexAttribPointer(UvAttribPos, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, uvs[0])); glEnableVertexAttribArray(UvAttribPos); glVertexAttribDivisor(UvAttribPos, 1); - glVertexAttribPointer(UvAttribPos + 1, 2, GL_FLOAT, GL_FALSE, 4 * 2 * sizeof(GLfloat), (void*)(1 * 2 * sizeof(GLfloat))); + glVertexAttribPointer(UvAttribPos + 1, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, uvs[1])); glEnableVertexAttribArray(UvAttribPos + 1); glVertexAttribDivisor(UvAttribPos + 1, 1); - glVertexAttribPointer(UvAttribPos + 2, 2, GL_FLOAT, GL_FALSE, 4 * 2 * sizeof(GLfloat), (void*)(2 * 2 * sizeof(GLfloat))); + glVertexAttribPointer(UvAttribPos + 2, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, uvs[2])); glEnableVertexAttribArray(UvAttribPos + 2); glVertexAttribDivisor(UvAttribPos + 2, 1); - glVertexAttribPointer(UvAttribPos + 3, 2, GL_FLOAT, GL_FALSE, 4 * 2 * sizeof(GLfloat), (void*)(3 * 2 * sizeof(GLfloat))); + glVertexAttribPointer(UvAttribPos + 3, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, uvs[3])); glEnableVertexAttribArray(UvAttribPos + 3); glVertexAttribDivisor(UvAttribPos + 3, 1); - glCheckError(); //Uv Layer GLuint uvLayerAttribPos = 8; - glBindBuffer(GL_ARRAY_BUFFER, Vbo[UVLAYERS]); - glVertexAttribPointer(uvLayerAttribPos, 1, GL_FLOAT, GL_FALSE, sizeof(GLfloat), nullptr); + glVertexAttribPointer(uvLayerAttribPos, 1, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, uvLayers)); glEnableVertexAttribArray(uvLayerAttribPos); glVertexAttribDivisor(uvLayerAttribPos, 1); - glCheckError(); //Animation GLuint animationAttribPos = 9; - glCheckError(); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[ANIMATIONS]); - glCheckError(); - glVertexAttribPointer(animationAttribPos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr); - glCheckError(); + glVertexAttribPointer(animationAttribPos, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, animations)); glEnableVertexAttribArray(animationAttribPos); - glCheckError(); glVertexAttribDivisor(animationAttribPos, 1); - glCheckError(); //Color GLuint colorAttribPos = 10; - glBindBuffer(GL_ARRAY_BUFFER, Vbo[COLORS]); - glVertexAttribPointer(colorAttribPos, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr); + glVertexAttribPointer(colorAttribPos, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, colors)); glEnableVertexAttribArray(colorAttribPos); glVertexAttribDivisor(colorAttribPos, 1); - glCheckError(); + + size_t m = sizeof(VertexData); + size_t d = offsetof(VertexData, lights); //Light GLuint lightAttribPos = 11; - glBindBuffer(GL_ARRAY_BUFFER, Vbo[LIGHTS]); - glVertexAttribPointer(lightAttribPos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr); + glVertexAttribPointer(lightAttribPos, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, lights)); glEnableVertexAttribArray(lightAttribPos); glVertexAttribDivisor(lightAttribPos, 1); - glCheckError(); glBindBuffer(GL_ARRAY_BUFFER, 0); } @@ -109,13 +100,7 @@ RendererSection::~RendererSection() { if (Vao != 0) glDeleteVertexArrays(1, &Vao); - for (int i = 0; i < VBOCOUNT; i++) - if (Vbo[i] != 0) { - glBindBuffer(GL_ARRAY_BUFFER, Vbo[i]); - glBufferData(GL_ARRAY_BUFFER, 0, 0, GL_STATIC_DRAW); - } - - glDeleteBuffers(VBOCOUNT, Vbo); + glDeleteBuffers(1, &Vbo); } void swap(RendererSection & lhs, RendererSection & rhs) { @@ -144,28 +129,13 @@ size_t RendererSection::GetHash() { void RendererSection::UpdateData(const RendererSectionData & data) { OPTICK_EVENT(); - glBindBuffer(GL_ARRAY_BUFFER, Vbo[POSITIONS]); - glBufferData(GL_ARRAY_BUFFER, data.positions.size() * sizeof(glm::vec4), data.positions.data(), GL_DYNAMIC_DRAW); - - glBindBuffer(GL_ARRAY_BUFFER, Vbo[UVS]); - glBufferData(GL_ARRAY_BUFFER, data.uvs.size() * sizeof(glm::vec2), data.uvs.data(), GL_DYNAMIC_DRAW); - - glBindBuffer(GL_ARRAY_BUFFER, Vbo[UVLAYERS]); - glBufferData(GL_ARRAY_BUFFER, data.uvLayers.size() * sizeof(GLfloat), data.uvLayers.data(), GL_DYNAMIC_DRAW); - - glBindBuffer(GL_ARRAY_BUFFER, Vbo[ANIMATIONS]); - glBufferData(GL_ARRAY_BUFFER, data.animations.size() * sizeof(glm::vec2), data.animations.data(), GL_DYNAMIC_DRAW); - - glBindBuffer(GL_ARRAY_BUFFER, Vbo[COLORS]); - glBufferData(GL_ARRAY_BUFFER, data.colors.size() * sizeof(glm::vec3), data.colors.data(), GL_DYNAMIC_DRAW); - - glBindBuffer(GL_ARRAY_BUFFER, Vbo[LIGHTS]); - glBufferData(GL_ARRAY_BUFFER, data.lights.size() * sizeof(glm::vec2), data.lights.data(), GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, Vbo); + glBufferData(GL_ARRAY_BUFFER, data.vertices.size() * sizeof(VertexData), data.vertices.data(), GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glCheckError(); - numOfFaces = data.animations.size(); + numOfFaces = data.vertices.size(); sectionPos = data.sectionPos; hash = data.hash; } diff --git a/src/RendererSection.hpp b/src/RendererSection.hpp index 9bb55e3..3ea1fec 100644 --- a/src/RendererSection.hpp +++ b/src/RendererSection.hpp @@ -9,17 +9,8 @@ class RenderState; class RendererSectionData; class RendererSection { - enum Vbos { - POSITIONS = 0, - UVS, - UVLAYERS, - ANIMATIONS, - COLORS, - LIGHTS, - VBOCOUNT, - }; GLuint Vao = { 0 }; - GLuint Vbo[VBOCOUNT] = { 0 }; + GLuint Vbo = { 0 }; size_t hash; Vector sectionPos; diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index 78e2239..e74590a 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -47,21 +47,24 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co lightness = glm::vec2(light.face[faceDirection], skyLight.face[faceDirection]); } + data.vertices.emplace_back(); + VertexData& vertexData = data.vertices.back(); + glm::mat4 transformed = transform * model.transform * face.transform; - data.positions.push_back(transformed * glm::vec4(0, 0, 0, 1)); - data.positions.push_back(transformed * glm::vec4(0, 0, 1, 1)); - data.positions.push_back(transformed * glm::vec4(1, 0, 1, 1)); - data.positions.push_back(transformed * glm::vec4(1, 0, 0, 1)); - - data.uvs.push_back(TransformTextureCoord(face.texture, glm::vec2(0, 0), face.frames)); - data.uvs.push_back(TransformTextureCoord(face.texture, glm::vec2(1, 0), face.frames)); - data.uvs.push_back(TransformTextureCoord(face.texture, glm::vec2(1, 1), face.frames)); - data.uvs.push_back(TransformTextureCoord(face.texture, glm::vec2(0, 1), face.frames)); - - data.uvLayers.push_back(face.layer); - data.animations.push_back(glm::vec2(face.texture.w / face.frames, face.frames)); - data.colors.push_back(face.color); - data.lights.push_back(lightness); + vertexData.positions[0] = transformed * glm::vec4(0, 0, 0, 1); + vertexData.positions[1] = transformed * glm::vec4(0, 0, 1, 1); + vertexData.positions[2] = transformed * glm::vec4(1, 0, 1, 1); + vertexData.positions[3] = transformed * glm::vec4(1, 0, 0, 1); + + vertexData.uvs[0] = TransformTextureCoord(face.texture, glm::vec2(0, 0), face.frames); + vertexData.uvs[1] = TransformTextureCoord(face.texture, glm::vec2(1, 0), face.frames); + vertexData.uvs[2] = TransformTextureCoord(face.texture, glm::vec2(1, 1), face.frames); + vertexData.uvs[3] = TransformTextureCoord(face.texture, glm::vec2(0, 1), face.frames); + + vertexData.uvLayers = face.layer; + vertexData.animations = glm::vec2(face.texture.w / face.frames, face.frames); + vertexData.colors = face.color; + vertexData.lights = lightness; } } @@ -154,12 +157,7 @@ RendererSectionData ParseSection(const SectionsData §ions) { } } } - data.positions.shrink_to_fit(); - data.uvs.shrink_to_fit(); - data.uvLayers.shrink_to_fit(); - data.animations.shrink_to_fit(); - data.colors.shrink_to_fit(); - data.lights.shrink_to_fit(); + data.vertices.shrink_to_fit(); return data; } diff --git a/src/RendererSectionData.hpp b/src/RendererSectionData.hpp index 7b30e44..e2fd190 100644 --- a/src/RendererSectionData.hpp +++ b/src/RendererSectionData.hpp @@ -30,13 +30,17 @@ struct SectionsData { BlockLightness GetSkyLight(const Vector &pos) const; }; +struct VertexData { + glm::vec4 positions[4]; + glm::vec2 uvs[4]; + float uvLayers; + glm::vec2 animations; + glm::vec3 colors; + glm::vec2 lights; +}; + struct RendererSectionData { - std::vector positions; //4 per instance - std::vector uvs; //4 per instance - std::vector uvLayers; - std::vector animations; - std::vector colors; - std::vector lights; + std::vector vertices; size_t hash = 0; Vector sectionPos; bool forced = false; -- cgit v1.2.3 From 08337925fe048d2e8b746bbc82493f4c2b8603d6 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 28 Jun 2021 21:31:26 +0500 Subject: Compacted vertices format --- src/RendererSection.cpp | 13 +++++-------- src/RendererSectionData.cpp | 2 +- src/RendererSectionData.hpp | 5 +++-- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp index 397a660..cc58676 100644 --- a/src/RendererSection.cpp +++ b/src/RendererSection.cpp @@ -21,19 +21,19 @@ RendererSection::RendererSection(const RendererSectionData &data) { { //Cube vertices GLuint VertAttribPos = 0; - glVertexAttribPointer(VertAttribPos, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[0])); + glVertexAttribPointer(VertAttribPos, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[0])); glEnableVertexAttribArray(VertAttribPos); glVertexAttribDivisor(VertAttribPos, 1); - glVertexAttribPointer(VertAttribPos + 1, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[1])); + glVertexAttribPointer(VertAttribPos + 1, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[1])); glEnableVertexAttribArray(VertAttribPos + 1); glVertexAttribDivisor(VertAttribPos + 1, 1); - glVertexAttribPointer(VertAttribPos + 2, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[2])); + glVertexAttribPointer(VertAttribPos + 2, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[2])); glEnableVertexAttribArray(VertAttribPos + 2); glVertexAttribDivisor(VertAttribPos + 2, 1); - glVertexAttribPointer(VertAttribPos + 3, 4, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[3])); + glVertexAttribPointer(VertAttribPos + 3, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, positions[3])); glEnableVertexAttribArray(VertAttribPos + 3); glVertexAttribDivisor(VertAttribPos + 3, 1); glCheckError(); @@ -64,7 +64,7 @@ RendererSection::RendererSection(const RendererSectionData &data) { //Animation GLuint animationAttribPos = 9; - glVertexAttribPointer(animationAttribPos, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, animations)); + glVertexAttribPointer(animationAttribPos, 1, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, animations)); glEnableVertexAttribArray(animationAttribPos); glVertexAttribDivisor(animationAttribPos, 1); @@ -74,9 +74,6 @@ RendererSection::RendererSection(const RendererSectionData &data) { glEnableVertexAttribArray(colorAttribPos); glVertexAttribDivisor(colorAttribPos, 1); - size_t m = sizeof(VertexData); - size_t d = offsetof(VertexData, lights); - //Light GLuint lightAttribPos = 11; glVertexAttribPointer(lightAttribPos, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (void*)offsetof(VertexData, lights)); diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index e74590a..2588fd6 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -62,7 +62,7 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co vertexData.uvs[3] = TransformTextureCoord(face.texture, glm::vec2(0, 1), face.frames); vertexData.uvLayers = face.layer; - vertexData.animations = glm::vec2(face.texture.w / face.frames, face.frames); + vertexData.animations = face.frames; vertexData.colors = face.color; vertexData.lights = lightness; } diff --git a/src/RendererSectionData.hpp b/src/RendererSectionData.hpp index e2fd190..edd2992 100644 --- a/src/RendererSectionData.hpp +++ b/src/RendererSectionData.hpp @@ -31,12 +31,13 @@ struct SectionsData { }; struct VertexData { - glm::vec4 positions[4]; + glm::vec3 positions[4]; glm::vec2 uvs[4]; float uvLayers; - glm::vec2 animations; + float animations; glm::vec3 colors; glm::vec2 lights; + uint8_t padding[20]; }; struct RendererSectionData { -- cgit v1.2.3 From 2db3f2a415f20f1224e277cef93e6d9bb2a1244b Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Tue, 29 Jun 2021 07:53:04 +0500 Subject: Tint calculation moved to vertex shader --- src/AssetManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp index 63dc596..5f24404 100644 --- a/src/AssetManager.cpp +++ b/src/AssetManager.cpp @@ -598,7 +598,7 @@ void ParseBlockModels() { parsedFace.layer = texture.layer; parsedFace.frames = textureFrames; if (face.second.tintIndex) - parsedFace.color = glm::vec3(0.275, 0.63, 0.1); + parsedFace.color = glm::vec3(0.486, 0.745, 0.423); else parsedFace.color = glm::vec3(0, 0, 0); -- cgit v1.2.3