Saturday, June 29, 2013

Introduction Part3 - Some small Examples

In the last Post i promised some Pictures, here they are. I have nothing fancy to show yet, but i think i can show some of my Testprograms.

The first one started as a Testcase for a general Voxelchunk, and then i used it to test out some Random Generators and Geometry Shaders.

I intended to make some Minecraftlike Terrain Generator, but this is not even near to be done... At the moment it just generates one 42x42x42 Chunk of Voxels and set their Values according to one of ten Random Generators, the Standard is Worley Noise - the others are more Primitive. To Render those Voxels, i can choose between the Old OpenGL1.0 Method (Intermediate Mode) where i draw a Cube out of six Quads for each Voxel, or a Geometry Shader where i just send the Voxeldata as Pointcloud to the Graphics Card (in Intermediate Mode, or as Vertex Array, Display List or Vertex Buffer) and the Shader then Draws a Cube for each Point. As i started this Program while still learning about modern OpenGL it was very useful to see the differences between those techniques... The Key-difference is Speed! When drawing everything in OpenGL 1.0 Mode, it needs to be heavily optimized to get Framerates above 10fps, while with VBO and Shaders it goes easily over 200fps even without optimization.

This Project helped me a lot, figuring out how to use VBOs and Shaders, so the initial purpose (to create anice working VoxelchunkObject) was dropped. But i will get back to it later.
Oh, and in the Background you can see a Part of my Compile Script at Work ;).



In this next Program i tried to create an Terrain patch Object which should select a LOD (Level of Detail) depending on the Distance to the Viewpoint.
I am using a QuadTree here to store the Patches and select the proper LOD. I did not test Heightmap and Textures yet, but the Code is already clumsy and ugly... so i think i will start this from scratch before adding Features
This Sphere is composed of six seperated Terrain Objects which are deformed to form a Sphere by this simple formula (in Pseudocode):

for each Vector v:
    v = (((v - CenterOfSphere)/DistanceToCenter)*Radius)+Height;

Altough "Height" is not used yet (as there is no heightmap or something similar). To have some Visual clue about what is going on until i add Textures, i colored the edges according to X/Y Values. So i can see where the Patches divide.

As i said, nothing fancy yet. Maybe if i get some Readers on this Blog, it would motivate me to produce something better-looking ;). I have many more Testprograms but those two i think are best suited to show what i am up to, and how i work on this. But if someone is interested i will show more, and i could also go into more detail on how i do certain things...

No comments:

Post a Comment