Texture Atlas repeating texture in Greedy Mesh

I am adding Greedy Meshing a Voxel game. But atlasing does not work well, I tried look that topic “Greedy Meshing is complex voxel data” but did not help much.

I think these two methods can make you understand well:

        private static void writeTextureCoords(ArrayList<Vector2f> textureCoords, TextureLocation textureLocation, int w, int h) {
		textureCoords.add(getTextureCoordinates(textureLocation, 0, 0));
		textureCoords.add(getTextureCoordinates(textureLocation, w, 0));
		textureCoords.add(getTextureCoordinates(textureLocation, 0, h));
		textureCoords.add(getTextureCoordinates(textureLocation, w, h));
	}
	
        private static Vector2f getTextureCoordinates(TextureLocation textureLocation, float width, float height) {
		float x = (textureLocation.getColumn() + width) * VoxelTest.TILE_SIZE; // TILE_SIZE is 1f / 16f
		float y = (-textureLocation.getRow() + (height - 1) * VoxelTest.TILE_SIZE) + 1;
		return new Vector2f(x, y);
	}

Result:

Greedy meshing requires textures to repeat… so you can’t really use a texture atlas without some serious shader tricks. …but then a texture array might be a better bet.

Ok, and texture array can fix my ParticleEmmiter problems. :smile:

TextureArray only work on modern PCs, and this is not an option for me, there’s something else I can do to achieve the same result?

Learn shader programming and write a custom shader that deals with custom mesh attributes.

I’m still just a beginner in jMonkeyEngine and know not to where to start to make shaders, do not talk to me “start with something easier than Voxel,” I need to make this game as quickly as possible, and all I want know is how to make my Mesher repeat textures without OpenGL, something like code examples help more than “learn shaders”.

If you’d like me to work for you then I can quote you some consulting rates. I’m kind of expensive, though.

6 Likes

http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:jme3_shaders

http://i.gifntext.com/41923-brutal-savage-rekt.gif

1 Like

I wasn’t trying to be rude. He suggested that I personally write code for him… so I wanted to be sure he understood what that meant.

Why? Just change the u,v coords and let OpenGL repeat the texture for you. You could divide your mega-mesh by type of texture (so that fewer texture switches occur in your scene). No atlas, not the best performance, but works for now.

If you really need to optimize later, you can pass another vertex attribute and try to make your own shader using an atlas (which should boost your performance).

It’s a common wisdome that “time equals money”. Either you buy some pspeed-hours like he suggested - in that case you can save time. Or you try to get where pspeed is today - in that case you can save money.

Just because you need something to be done as quickly as possible, there is no reason why others should do that work for you.

Because he’s using an atlas and openGL will pull in whatever is next.

Is that greedy meshing so important? I mean, why not just disable that - a few triangles more and buffers a little bit bigger should not hurt the performance?

Could be wrong on that, but when either not using greedy mesh or not using atlas could still have quite okay performance? I would try sacrifice the greedy meshing first and if it doesn’t work, then sacrifice the atlas and keep the greedy meshing. If both fails, custom shaders seem to be the only way left.

How many frames per second do you gain from greedy meshing when compared to not using it, @Dimalenus?

Yeah, I got that problem. That’s why I added this sentence.

My cubes clone uses the z-coordinate of the texture as tile index for the texture atlas:
https://github.com/etherblood/Ethercubes/tree/master/assets/Shaders/Cubes
https://github.com/etherblood/Ethercubes/blob/master/src/ethercubes/display/meshing/CubesMaterial.java