eVoid Development Weblog Burn The Land And Boil The Sea But You Can't Take The Sky From Me

28Jul/102

LOD Octtree Implementation

Just a few not much saying ;) screenshots from the debugging of a work-in-progress level-of-detail based implementation of the octtree algorithm I've presented a few weeks ago:

Anyone who can guess what screenshot #3 precisely shows..? Winner is gonna receive a cookie :P Anyway, took me 'bout 48 hours to figure out that **** to work properly. A Grooveshark playlist mostly dominated by blink-182, Offspring and good ole Milk Inc. mixed up by some rock classics from Queen & Co. playing looped for a damn long time did a great service ;) So now the sun is arising I can finally go to sleep after a -finally- very successful day of work.

  • Share/Bookmark
23Jul/100

Alpha 2 & Resource Organization

Today I finished the last tasks I had queued for alpha 2. Furthermore I've put a snapshot of the recent version online accomplished by some documentation. By doing so I decided to share some thoughts on the organization of resources by contexts and I'd like to draw your attention to it: What's your opinion on my solution, how do you handle it?

I've also written a roadmap for the project:

  • Alpha 1 (5. February 2010)
    • First usable version with a basic implementation of all the most important features, those are:
      • Post Processing Pipeline: Satisfying the demand on being easy to use, effects like blooming can be activated by up to three lines of code.
      • Object oriented encapsulation of most important OpenGL elements like textures, frame buffer objects and many more, providing the paradigm of orthogonality while satisfying the demand on being flexible & robust.
  • Alpha 2 (23. July 2010)
    • Countless bug-fixes & increased robustness
    • Widely improved GL encapsulation
    • Straightforward user-oriented design
    • API completely re-organized by layers

      ← Here we are
  • Alpha 3
    • Implementation of per-object motion- & usual blurring
    • Material property for specular highlighting
    • GL/gl.h dependency removal from vertexbuffer.hpp
    • Lazy state changes to avoid redundancy
    • Major API changes
      • Renderer class merged into RenderTarget
      • Materials organized by resource contexts
      • Potentially some kind of a shader abstraction:
        - Stack-like organization of shader states
        - Automatized shader generation
  • Share/Bookmark
22Jul/102

Z-Fighting Problem Solved

Thanks to an user named kRogue on the OpenGL forums the problem mentioned here is finally solved:

glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_ALPHA );

is not part of GL3 core... though it is there in a compatible context. Try taking that call out and use the .r component of the depth texture in your shader... this should NOT make a difference, but you never know.

- kRogue

Furthermore I've been notified that the problem didn't occur on a GF GTX260.

One more important aspect to notice that you should check if you should ever happen to run into the same problem as I did: The GL_MIN_FILTER and GL_MAG_FILTER properties of the depth texture object must be set to GL_NEAREST. At least they are not allowed to be set to GL_LINEAR. Don't ask me for the reason. Otherwise you will experience the same Z-Fighting as I did.

  • Share/Bookmark
21Jul/100

C++0x, Lambda Expressions and Visitors

I know there are thousands and millions of articles out there dealing with the new features that are being introduced by the new C++ ISO standard commonly known as C++0x. Today I read that on Code Project and got very enthusiastic about the part that described the lambda expressions. I know that is damn geeky but I almost went bananas :D when I read what they are and what kinda stuff you can do with them. Countless situations came immediately on my mind in which I could take advantage of them. Usually I tend to make very extensive use of the Visitor pattern. Most of my classes that encapsulate some kind of an 1 -to- n>1 association do offer a function like VisitObjects( :UnaryFunction ). I like it that much because I believe it's the most short and abstract way to offer an interface for the traversal of associated objects. No matter how the data is internally organized - whether it's a tree or maybe a flat structure like a linked list or an array - the interface stays all the same. Up to now I had to do the following to make use of that kind of interfaces:

namespace impl
{
 
class MyFunctor
{
public:
 
    int i;
 
    MyFunctor( int i )
        : i( i )
    {
    }
 
    bool operator() ( const MyElement& e )
    {
        std::cout << ( i++ ) << " - " << e << std::endl;
        return true;  //< continue traversal
    }
 
};
 
}  // namespace impl
 
 
void MyClass::MyFunction()
{
    impl::MyFunctor visitor( 0 );
 
    MySet.VisitMyElements( visitor );
 
    std::cout << "We've vistited " << visitor.i << " elements" << std::endl;
}

Everyone will admit that is kinda ugly. Now, thanks to lambda expressions, I could just inline the whole logic into the one really necessary function:

void MyClass::MyFunction()
{
    int i = 0;
    MySet.VisitMyElements( [&]( const MyElement& e )->bool
            {
                std::cout << ( i++ ) << " - " << e << std::endl;
                return true;  //< continue traversal
            } );
 
    std::cout << "We've vistited " << i << " elements" << std::endl;
}

Though I haven't tested it, to me lambda expressions and the visitor pattern seem like made for each other :D

  • Share/Bookmark
20Jul/100

WordPress 3.0 & SFTP

WordPress 3.0 has a nice feature that does all the platform and plugin updating for you by just clicking an 'Update' button at the admin console. In order to do so it needs to connect to the server the blog is hosted. By the default configuration of my (and I guess almost any) server only FTP and FTPS (FTP via SSL) are available here. Since my server doesn't run a FTP server module for security reasons I looked for a way to teach SFTP (kinda FTP tunneled via SSH) to the platform and stumbled over a blog post by Raditha Dissanayake from June 2009 that described the required procedure for a Fedora box. Since I'm running Ubuntu Hardy Heron LTS I'll sum up what I had to do on that specific system:

aptitude install libssh2-1-dev php-pear php5-dev
pecl install -f ssh2
echo "extension=ssh2.so" > /etc/php5/conf.d/ssh2.ini
/etc/init.d/apache2 restart

This procedure will enable the SSH2 extension for PHP. Afterwards there will immediately be a 'SSH2' option beside FTP and FTPS located in WordPress' update dialog.

  • Share/Bookmark
19Jul/100

Living in Aachen

So, mir ist gerade langweilig, also schreib ich einfach mal, was die meiner Meinung nach besten Lebensmittel-Produkte sind, die man in Aachen als armer Student kaufen kann, vom Preis-Leistungsverhältnis her.

Bier: Das 5,0er respektive Pils, Weizen oder Radler beim REWE. Kostet nur 0,78 der Liter und schmeckt in dem Preissegment am besten. Der Billigmarke vom Plus (Schloss) meilenweit überlegen.

Hackfleisch: Beim REWE gibt es öfter mal Sonderangebote der etwas gehobeneren Marken. Zu den Ja-Produkten greife ich an dieser Stelle nicht mehr, seit ich mal eine Lebensmittelvergiftung davon getragen habe ;) Und sonst beim Aldi.

Pfannengyros: Beim Aldi, etwas um die 2,50 für eine 500g Packung, finde ich mehr als fair. Schmeckt super.

Pizza: Dreifachpackung Salami für nur knapp 2,50 oder Margarita für knapp 2,00 beim Plus.

Schinken: Auf jeden Fall das Ja-Produkt von REWE.

Schokolade: Ganz klar die Ja-Produkte beim REWE, in verschiedenen Sorten.

Schwarzbrot: Weltmeisterbrot beim Plus, etwas über 1,00 für 750g.

Wasser: In verschiedenen Sorten bei REWE und beim Plus.

Die Liste wird bei Gelgenheit weiter ergänzt werden.

Ein tolles Angebot gibt es von der belgischen Bahn: Ab Eupen kommt man mit dem GoPass 1 für nur 6,50 pro Person oder 5,00 beim Kauf von mindestens 10 Tickets nach Oostende an die Nordsee. Nach Eupen kommt man z.B. mit der Linie 14, und als Student sogar kostenlos.

  • Share/Bookmark
18Jul/100

Update to WordPress 3.0

I have just upgraded my blog from WordPress 2.3 to 3.0.

I really like the new administrative interface and all the other new features.

Update went absolutely smoothly.

I will spend some more time on working out a suitable design the next days.

  • Share/Bookmark
18Jul/100

Update: Mess with depth textures

I've been stuck at a problem for a week now without making any progress. My goal was to draw some cubes into a framebuffer object, draw the result back into the default framebuffer and finally draw something more (a single quad) into the default framebuffer that correctly overlaps with the stuff drawn before. In order to achieve this I need to re-use the z-data from the framebuffer object. I have a depth-texture attached to the framebuffer object and when drawing back to the default framebuffer, I'm using a simple shader to write the z-data.

The following screenshot shows the result:

Depth Texture Problem #1

As you can see, the overlapping doesn't work properly.

I have written a minimal application which reproduces the problem, more on that later. Yesterday I've been playing around with the code and noticed that if I make the range between the near clipping plane and the far clipping plane smaller, the 'effect' shown above becomes smaller. The following screenshot shows the same scene with the near clipping plane moved from 0.1f to 1.f and the the far clipping plane from 100.f to 50.f:

Depth Texture Problem #2

So I believe the depth values are somehow quantized far too much. But why? It cannot be the precision of my depth texture which is 24 bit since if I change it to 32 bit the 'effect' stays exactly the same. If it would be caused by a too low precision of the depth texture, I would have expected the 'effect' to become less.

I can think of two possible reasons though I'm not able to explain either of them. So either the projection matrix is getting messed up somehow so that the quotient of the clipping planes becomes superdimensional. Or the quantization is caused by the "gl_FragDepth = texture2D( depthtex, gl_TexCoord[0].xy ).a" instruction in the fragment shader.

Vertex shader:

void main()
{
    gl_Position = ftransform();
    gl_TexCoord[0] = gl_MultiTexCoord0;
}

Fragment shader:

#version 120
 
uniform sampler2D texture0;
uniform sampler2D depthtex;
 
void main()
{
    gl_FragColor = vec4( texture2D( texture0, gl_TexCoord[0].xy ).xyz, 1.0 );
    gl_FragDepth = texture2D( depthtex, gl_TexCoord[0].xy ).a;
}

The minimal application can be found here:
http://pastebin.com/UctqYW33

If you have SFML2, you can use the following code for running the application:
http://pastebin.com/yJgvQpnK

Otherwise you could use the library of your choice for creating the GL context, like glut or freeglut or whatever.

I've already posted on several forums without getting any further leading advices.

  • Share/Bookmark
5Jul/102

Update + Thoughts of Quad- & Octtrees

Even though I didn't update that blog during the past few months, the work proceeded quite well. A countless amount of bugs has been fixed, the abstraction from OpenGL improved a lot and the API itself completely revised. I've outlined a road map of what still has to be done 'til Alpha 2 and it's not that much:

  1. Implement DefaultMesh::CreateSphere
  2. Implement DefaultMesh::CreateCylinder
  3. Implement DefaultMesh::CreateCone
  4. Solve Bloom-zBuffer-Problem
  5. Clean up some header files

So #1 was an ease and now I'm still almost done with #4 which is the last greater task. The problem here was that rendering with bloom worked like a charm but when rendering in combination with objects that should have been not affected by the bloom effect, the depth-buffer information messed up. The bad thing about it is that I finally reached the limits of the possibilities of my GeForce 6600 and am not able to proceed right now, for I also don't have the money to buy me a new card. So it's fairly probable that I won't continue work on this task until September, when I expect to get a new notebook bought by the institute I will start working at, namely the Institute for Medical Engineering as an appliance.

So I spent a few thoughts on the later organization of the world data in octtrees recently when I was bored. The following short article will describe a way of organizing the nodes of a quadtree (for the sake of clarity) in a certain way which allows a very easy and straightforward traversal of the tree. It is trivial to expend this technique to work with octtrees.

  • Share/Bookmark
31Jan/100

Debug Features & Fixed Bump Mapping

The recently published screenshots of my bump mapping implementation contained some bugs caused by wrong computation of texture coordinates:

Bump-Mapping Bug

It was an ease to solve them after finishing the implementation of some debug-features. These mainly include the visualization of texture coordinates, face tangents and face normals, but also the visualization of per-pixel normals, realized by false-color rendering.

A scene rendered with some extra mesh debugging information:

Debug Features 1

The yellow line represents the first tangent space base vector, whereas the bold blue line represents the second one and the tiny blue line represents the second tangent space base vector multiplied by -1. The numbers show the texture coordinates for every vertex. The red line in the face's center stands for the face's normal and the green line for it's tangent. Of course it is possible to toggle all the different debug modes during the application is running.

The same scene with the normal vectors of the G-buffer rendered to the color channel for every fragment:

Debug Features 2

Of course it is also possible to visualize only a certain normal vector component, as shown here for the x-component:

Debug Features 3

  • Share/Bookmark