Thursday, March 24, 2011

New Vertex Buffer Controller..

Quick update for tonight.  I've written a controller that can handle multiple vertex buffers.  I wanted to stress test it, so I ran it until I ran out of memory.  I have a pretty shitty video card, but I topped out at ~3 million cubes, a little over 3 million vertices and 531 chunks (each chunk is 16x16x128).  The first screenshot is from the first stress test while the 2nd one is the test where I ran out of memory.

 The other awesome part is I was still averaging 63fps :]

Roadmaps and roadtrips...

I wanted to add a crosshair to the screen, so I thought it'd be as simple as using a sprite and just drawing it to the screen.  After doing that, all of my primitives were transparent and messed up.  I researched and couldn't find much, so I resorted to the forums and they led me to a blog post that explained it all.  I should've realized it because it makes sense, but basically when you draw 2d to the screen after you draw 3d, GraphicsDevice resets a bunch of parameters.  Primarily these:
1:        GraphicsDevice.BlendState = BlendState.Opaque;  
2:        GraphicsDevice.DepthStencilState = DepthStencilState.Default;  
3:        GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;   

After resetting them back to their previous state, I have the following:

Nothing fancy but at least now it's easy to see the FPS and player position.  I've also created a tumblr account to upload some more screenshots to. is the address.

Lastly, if you look to the right, you'll notice a new box showing the current version and its planned roadmap.  I might add/remove stuff as I go along but that's the current plan.

No major updates besides that.  Lots of reading about HLSL and as you can see, a decent shader is going to be required before I can move onto the next version.

Sunday, March 20, 2011

Magically, a YouTube video. Also I really need to learn HLSL.

Made some great progress these last few days.  First off, the obligatory pictures:

As you can see, I've been toying around with my world gen algorithm.  It finally looks somewhat presentable.  It's very heavy on the top side and I'm not generating any caves yet, but it's still really fun to toy around in.
On the technical side, I'm finally generating the mesh more efficiently.  I'm using indexes so I only have to use 4 vertex points instead of 6 to create 2 triangles.  I also had an issue before with generating faces at the edges of chunks.  I was only checking for cubes inside the current chunk, so when I got to the edge the algorithm thought that there were no cubes on the other side and built a face there.  This wasted a lot of memory if there was a cube in another chunk there, so I'm now checking outside of the chunk when I hit the edge.  Before I threw that in there, for 9 chunks with seed 1143 (my test seed) I was drawing 348,552 triangles with 116,184 indexes.  After I fixed that glitch, my triangles went down to 190,812 and indexes down to 63,604.  This lets me add a lot more chunks before running out of memory.

I also fixed a glitch I had with my textures.  Nothing fancy but at least it doesn't look as crappy.  As my title says, though, I really need to learn HLSL.

Until next time..