Improving Voxel Performance in 3079

Hey guys,

I’m trying to improve the rendering performance of my 3079 game, especially for low-end graphics cards.

Right now, I create at least one face of a voxel for every visible voxel. What I want to do, is if I have a string of the same visible voxels, I’d like to just create one long quad to cover all the visible voxel faces. This would save lots of vertices compared to having a new face for every voxel along that string. However, the problem I have is in texturing… if I have one long quad, my texture would get stretched out… I’m using a texture atlas, so I’m not sure how to do tiling with that. Would I need to use a different material for these quads, which means it couldn’t be part of the same mesh? Any suggestions?


  • Jeremy

General issue for texture atlases and repeating textures, if you find a good solution tell us :slight_smile:

I’m wondering if this could be solved with a custom shader somehow…

Well it would certainly be best to do it at the shader level, some other mode like “wrap” but you need the texture coords, have only the four vertices etc etc, I think its not so trivial.

Before you go too far down this path, you might analyze some of your data to see if it’s even worth it.

While I can only guess at how you are doing your lighting, etc. generally losing vertexes makes that a bunch harder and saving a few vertexes here and there is likely not worth the trouble.

Well if you use TextureArray isntead of a textureatlas you can repeat textures, however I’m not sure if textureatlas works on low end graficcards well.

Do you mean something like this?

Voxels are now rendered as surfaces, rather than complete cubes. This lets me cull a lot of unnecessary geometry.

You could always shoot him an e-mail to see if he'd be willing to share some insights.

That voxel engine looks pretty neat! However, I already do surfaces instead of boxes (and all of his other applicable optimizations)… I’m trying to reduce surface count by combining surfaces into one extended quad. For example, instead of having 3 surfaces for 3 lengths of a voxel floor, I’d have 1 quad extended 3 lengths. I’d need to have the texture repeat 3 times to do this, and I use a texture atlas… hence the difficulty :frowning:

Welp, to revive a dead thread – I found some shader code that appears to resolve the repeating texture problem with texture atlases:

[java]void main(void) {

vec2 texCoord = gl_TexCoord[0].xy;

vec2 paramU = gl_TexCoord[1].xy;

vec2 paramV = gl_TexCoord[2].xy;

texCoord.x = fract(texCoord.x) * paramU.x + paramU.y;

texCoord.y = fract(texCoord.y) * paramV.x + paramV.y;

gl_FragColor = gl_Color * texture2D(texture, texCoord);

} [/java]

From here:

However, all my geometry renders black when I try to use this in my .frag shader file. Do I need to be doing something more in my .vert and .j3md files too? Should this work…?

  • Jeremy