Compare commits
1 Commits
main
...
vram-reduc
Author | SHA1 | Date |
---|---|---|
EmaMaker | 32b9c3e8ca |
|
@ -17,9 +17,9 @@ namespace chunkmesher{
|
||||||
Chunk::Chunk* chunk;
|
Chunk::Chunk* chunk;
|
||||||
GLuint numVertices{0};
|
GLuint numVertices{0};
|
||||||
|
|
||||||
std::vector<GLfloat> vertices;
|
std::vector<GLubyte> vertices;
|
||||||
std::vector<GLfloat> extents;
|
std::vector<GLubyte> extents;
|
||||||
std::vector<GLfloat> texinfo;
|
std::vector<GLubyte> texinfo;
|
||||||
};
|
};
|
||||||
oneapi::tbb::concurrent_queue<MeshData*>& getMeshDataQueue();
|
oneapi::tbb::concurrent_queue<MeshData*>& getMeshDataQueue();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
layout (location = 0) in vec3 aPos;
|
layout (location = 0) in uvec3 aPos;
|
||||||
layout (location = 1) in vec3 aExtents;
|
layout (location = 1) in uvec3 aExtents;
|
||||||
layout (location = 2) in vec2 aInfo;
|
layout (location = 2) in uvec2 aInfo;
|
||||||
|
|
||||||
uniform mat4 model;
|
uniform mat4 model;
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ void main()
|
||||||
vs_out.Extents = aExtents;
|
vs_out.Extents = aExtents;
|
||||||
vs_out.BlockType = aInfo.y;
|
vs_out.BlockType = aInfo.y;
|
||||||
|
|
||||||
if(aExtents.x == 0) vs_out.Normal = vec3(1.0 - 2*aInfo.x, 0.0, 0.0);
|
if(aExtents.x == 0.0) vs_out.Normal = vec3(1.0 - 2.0*aInfo.x, 0.0, 0.0);
|
||||||
else if(aExtents.y == 0) vs_out.Normal = vec3(0.0, 1.0 - 2*aInfo.x, 0.0);
|
else if(aExtents.y == 0.0) vs_out.Normal = vec3(0.0, 1.0 - 2.0*aInfo.x, 0.0);
|
||||||
else vs_out.Normal = vec3(0.0, 0.0, 1.0 - 2*aInfo.x);
|
else vs_out.Normal = vec3(0.0, 0.0, 1.0 - 2.0*aInfo.x);
|
||||||
vs_out.Normal = mat3(transpose(inverse(model))) * vs_out.Normal;
|
vs_out.Normal = mat3(transpose(inverse(model))) * vs_out.Normal;
|
||||||
|
|
||||||
gl_Position = model * vec4(aPos, 1.0);
|
gl_Position = model * vec4(aPos, 1.0);
|
||||||
|
|
|
@ -236,21 +236,21 @@ void sendtogpu(MeshData* mesh_data)
|
||||||
|
|
||||||
// position attribute
|
// position attribute
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mesh_data->chunk->VBO);
|
glBindBuffer(GL_ARRAY_BUFFER, mesh_data->chunk->VBO);
|
||||||
glBufferData(GL_ARRAY_BUFFER, mesh_data->vertices.size() * sizeof(GLfloat), &(mesh_data->vertices[0]), GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, mesh_data->vertices.size() * sizeof(GLubyte), &(mesh_data->vertices[0]), GL_STATIC_DRAW);
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void *)0);
|
glVertexAttribIPointer(0, 3, GL_UNSIGNED_BYTE, 3 * sizeof(GLubyte), (void *)0);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
|
|
||||||
// normal attribute
|
// normal attribute
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mesh_data->chunk->extentsBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, mesh_data->chunk->extentsBuffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, mesh_data->extents.size() * sizeof(GLfloat), &(mesh_data->extents[0]), GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, mesh_data->extents.size() * sizeof(GLubyte), &(mesh_data->extents[0]), GL_STATIC_DRAW);
|
||||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void *)(0));
|
glVertexAttribIPointer(1, 3, GL_UNSIGNED_BYTE, 3 * sizeof(GLubyte), (void *)0);
|
||||||
glEnableVertexAttribArray(1);
|
glEnableVertexAttribArray(1);
|
||||||
|
|
||||||
// texcoords attribute
|
// texcoords attribute
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mesh_data->chunk->texinfoBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, mesh_data->chunk->texinfoBuffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, mesh_data->texinfo.size() * sizeof(GLfloat), &(mesh_data->texinfo[0]), GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, mesh_data->texinfo.size() * sizeof(GLubyte), &(mesh_data->texinfo[0]), GL_STATIC_DRAW);
|
||||||
glEnableVertexAttribArray(2);
|
glEnableVertexAttribArray(2);
|
||||||
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void *)0);
|
glVertexAttribIPointer(2, 2, GL_UNSIGNED_BYTE, 2 * sizeof(GLubyte), (void *)0);
|
||||||
|
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue