The problem Im having is I have to store all those vertices in tables, and that takes up around 500-800 mb for only about 216 chunks!

Is there any way I can store vertices in a more efficient way? This seems like way too much memory usage.

This is what I use to draw models

Code: Select all

```
-- go through all models in modelList and draw them
for i=1, #self.modelList do
local model = self.modelList[i]
if model ~= nil and model.visible and #model.verts > 0 then
self.threeShader:send("model_matrix", model.transform)
self.threeShader:send("model_matrix_inverse", TransposeMatrix(InvertMatrix(model.transform)))
love.graphics.setWireframe(model.wireframe)
if model.culling then
love.graphics.setMeshCullMode("back")
end
love.graphics.draw(model.mesh, -self.renderWidth/2, -self.renderHeight/2)
love.graphics.setMeshCullMode("none")
love.graphics.setWireframe(false)
end
end
```

Code: Select all

```
-- define the shaders used in rendering the scene
scene.threeShader = love.graphics.newShader[[
uniform mat4 view;
uniform mat4 model_matrix;
uniform mat4 model_matrix_inverse;
uniform float ambientLight;
uniform vec3 ambientVector;
varying mat4 modelView;
varying mat4 modelViewProjection;
varying vec3 normal;
varying vec3 vposition;
#ifdef VERTEX
attribute vec4 VertexNormal;
vec4 position(mat4 transform_projection, vec4 vertex_position) {
modelView = view * model_matrix;
modelViewProjection = view * model_matrix * transform_projection;
normal = vec3(model_matrix_inverse * vec4(VertexNormal));
vposition = vec3(model_matrix * vertex_position);
return view * model_matrix * vertex_position;
}
#endif
#ifdef PIXEL
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
vec4 texturecolor = Texel(texture, texture_coords);
// if the alpha here is zero just don't draw anything here
// otherwise alpha values of zero will render as black pixels
if (texturecolor.a == 0.0)
{
discard;
}
float light = max(dot(normalize(ambientVector), normal), 0);
texturecolor.rgb *= max(light, ambientLight);
return color*texturecolor;
}
#endif
]]
```