Hey guys and gals, I wanted to update on my progress into the realm of voxels, with screenshots again! So, picking up from two blogs ago…
I had to switch graphics libraries because Irrlicht wasn't the best fit. While I knew exactly how I could implement the texturing I want in OpenGL, Irrlicht had no obvious method for implementing texture arrays without hijacking the gl context and running amok. I figured if I was gonna go the GL route I might as well switch to a library that's more GL-friendly from the start. I've experimented with OpenSceneGraph in the past but never paid it right, but it really stuck out to me when I noticed it had texture array support built right in. So, deciding to give it another whirl, I ported what little I had over to OSG. After getting my geometry loaded and displayed, I fidgeted with the texture until I got close to the effect I'm going for:You can see now my intention is to use large textures but span them over several blocks, retaining the pixellated look of minecraft while subtly breaking up the repetition (at least to an extent). I also played around with the filtering so that it would magnify textures using nearest neighbor (pixellated) and minimize them using a linear filter (blurry), which makes the far away blocks look better:Satisfied for the time being, I began my descent into the realm of texture arrays. Now, a better way to think of texture arrays is as a 3D texture (well technically that's all they are). You can define their coordinates in the X (U) and Y (V) like a normal 2D texture, but you can also specify a Z (W) which indicates which "layer" you're referring to. The only trick is you can't just go using a 3D texture willy nilly, you have to pass them to a shader and render them there. So I loaded up a couple textures into an array and started figuring out the shader code, which turned out to be as simple as:#version 120
#extension GL_EXT_gpu_shader4 : enable
uniform sampler2DArray textures;
void main() {
gl_FragColor = texture2DArray(textures, vec3(gl_TexCoord[0].xy, gl_TexCoord[0].z));
}
Very cool. I'm jealous.
yippee, more minecraft-like engines :3
is it really "voxels" if the world isn't filled with it? this is really nothing more than a cubic 2d plane with added height. I maybe wrong, but i got the idea that a voxel engine, means the game is made up entirely of voxels, so to use Minecraft as an example, digging up the ground, you will see more ground underneath that! and so on. of course, i realize this is in an early stage :Di made a similar project before, only i filled the whole world with columns, that had adjustable height, it actually makes digging more realistic in a sense. if digging, it doesn't remove a whole chunk, instead it simply decreases the columns height until it reaches a certain low height, in which you hit stone. (of course i had no cave system at all…)They're actual voxels, I just didn't do anything fancy with the level generation other than a height check, so it looks like it's just a heightmap. This old screenshot shows off the capability a bit better.
Tangent, since I'm already planning on integrating Lua into the game, I intend to offload the level generator to Lua as well, which should speed up its design as I don't like waiting on the compiler just to dial a single parameter in for the level >_> I feel like the compiler takes extra long since I switched to static libraries, perhaps just because it forces me to link a lot more… maybe I'll switch back to dlls just for my sanity's sake :P