C/C++, Study

GPU Gems 3: Rigid Body Solver

As mentioned in my last post in Rendering abstract data in OpenGL I was working for my final project of an practical course in my Masters program on implementing a GPU based Rigid Body Solver, described in this GPU Gems 3 article.

Sadly, it did not work out quite well. I still have some problems in the calculations of the particle/ rigid body forces and visualizing the bodies was difficult because the fell out of the screen so quickly.

But I wanted to share the project anyway since I think some part of it may be useful to others – especially rendering into the force and position textures.

The code may be found on my Github Account: Project RigidSolver.

Maybe someone would even help an finish the project.

As I already mentioned on the Github repository: This project was successfully submitted in the Practical Course Visual Computing at the University of Stuttgart and is not allowed to be used or submitted as whole or in parts at any other educational facility!
You may use the code as inspiration and use it for any ungraded work. But be aware that this is neither production ready, nor a performance oriented implementation!

Picture taken from: https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch29.html

Rendering abstract data in OpenGL

I am currently implementing a GPU Rigid Solver with OpenGL for a project at my university and I struggled for a long time to implement the rendering of abstract data to textures – a task which i needed a lot for the several solver passes.

I want to share which code I  am working with right now to render output data to certain texels. This was adapted from the JavaScript Code of Christopher Wellons in his WebGL Game of Life implementation.

Imagine having a texture inData which is the one a shader should work on, and a texture outData which should be written to.  After generating the framebuffer and generating the textures with a certain width and height and a VertexArray with a window quad, I would render doing the following:

  1. Setting the viewport with glViewport(0, 0, width, height)
  2. Clearing the color and depth buffer
  3. Creating an orthographic projection with GLM’s glm::ortho(0.f, 1.f, 0.f, 1.f) and passing it as uniform to the shader: glUniformMatrix4fv(location, 1, GL_FALSE, glm::value_ptr(orthoMX))
  4. Then Binding the shader
  5. Render the quad
  6. Release the shader

The vertex shader would then just pass through the position (The position will then match the output texture). It could look something like

#version 330

layout(location = 0) in vec2  in_position;

uniform mat4 projMX;
void main() {

    gl_Position = projMX * vec4(in_position, 0, 1);}

In the fragment shader – which would do the actual calculations – the current output position can be queried through the fragments coordinates gl_FragCoord. One thing is important to mention: The coordinates are centered in the texel, which means either (0.5, 0.5) needs to be substracted from the coordinates or the location parameter pixel_center_integer can be used. Example fragment shader would look something like:

#version 330

layout(pixel_center_integer) in vec4 gl_FragCoord;
layout(location=0) out vec4 outData;

uniform sampler2D inData;

void main() {

    ivec2 texelCoords = ivec2(gl_FragCoord.xy);
    vec4 inDataValue = texelFetch(inData, texelCoords, 0);

    // Do something with the data

    outData= inDataValue;


This should do the trick. It is always good to turn interpolation off in the textures to prevent data from “leaking”. Of course if the input dimensions of the data differ from the output ones you may have to calculate the values according to the current texel you are on.


Up and downs with the FRITZBox 6490 Cable

This issue might be only useful for people living in Germany. My internet provider is UnityMedia and for some time now users are able to use the router they want and do not have to rely on the on by UM – a hard to work with Technicolor router. I had my problems with the router as well:

  • It has 2,4 and 5 Ghz support but not in dual mode
  • Port Forwarding is a real hassle
  • It looses connection without any apparent reason

So it has plenty of reasons to switch to another one. I always liked the ones by Fritz! and so I looked into buying the 6490 cable version. But it is 250 € new and 110-150€ used. So a scrimper as I am I bought a used one on a german “craigs list” and got it for incredible 50€.

But then I discovered that it is difficult to reuse a device that somebody else already registered with UM. BUT – for me it worked. I had to convince the person in the service hotline to try it anyway and surprisingly for her it worked! I cannot promise anything for people buying used ones as well – but there is hope.

Then there came the down

Ok so I got the router, registered it with UM, changed some settings and then: I had the glorious idea to try to remove the KDG branding that was on it by logging into the Adam2 FTP account and change the firmware_version env to the avm firmware. But careful: Since there apparently no avm firmware available on the device it will get stuck into a bootloop. 

The solution: So what this post is actually about! I tried hard to get back onto the box and try to change it back

  • Regular FTP did not work
  • Safety Access IP via did not work
  • Safety Access IP via did not work

But, if you have the same problem, try using the firmware recovery of the Fritzbox 7390. This will of course not be able to recover anything but it will lead you with an IP that you can use to access the system again. Just FTP to the IP the recovery tool gives you.



Creating Windows 10 User Accounts after Upgrade

Apparently there is a problem with upgraded Windows 10 systems which has a corrupted default user file. Creating a new user works fine but a logon leads to a “User cannot be loaded” Error.

Windows tries to create the new user profile by copying the necessary files from the default profile (which is corrupted) and fails doing so.

This can be solved by overwriting the Default Users’ NTUSER.DAT under C:/Users/default as shown in other tutorials. My Problem was to obtain a non-corrupted user file.
So to help everyone with the same problem, one can find an working default user file HERE!


Repetico Flashcards

I am currently preparing for several exams this semester and I am using a flashcard service, called “Repetico”, for the first time. I am using it to help me prepare on three modules which a high amount of slide and a wide variety of subjects which must be learned by heart. The modules are:

Up until now I am happy with the solution even though the final success of this study approach will only be judged after my exam result.

But for now everybody that has the same modules can apply for learning with those flashcard sets. You can write an request by clicking on the links above.
Maybe it helps some of you as well.

Please not that I am not solely relying on those cards especially because there are a lot of exercise on those topics, but rather to know definitions, principals or procedures.
Especially in distributed systems and Infovis it is crucial to know the protocols, procedures, algorithms and to have created so lattices, serialization-graphs and visualizations by hand.



I am strongly relying on Todoist for organizing all my todo’s – freelancing work, privat as well as my studies. So far I am happy with the workflow even though I haven’t tried Wunderlist yet. I am using the pro version since it offers you to add reminders

But I noticed that it takes some time to get to know all the little tricks and shortcuts which help you to just “get there faster” when creating, updating or managing tasks in the app. I just wanted to give a quick reference guide for features I found very helpful (and sometimes had a hard time to find out about)

Quick Task Assignments

When creating new tasks (Hint: Shortcut is Q) you can use short codes:

  • To set a due date you can use task descriptions like: today, tomorrow, every friday, next month
  • To add a label (which are just tags for tasks) use the @ symbol for that. I use labels for categorizing my tasks into Collaboration (where I have to do phone calls or write an email) or sort my work into coding or administration tasks
  • To assign a task to a project use the #-symbol: Do laundry #Household, Code something #Work. Note: If you don’t specify a project it will be created in the project where you are right now or in your inbox
  • For a quick priorisation of tasks use the double exclamation mark. So for example “!!1” gives the task priority 1.

Note: Some of the quick assignment “short codes” are not available in the android app yet. I filed in a feature request about that since I predominantly use the app to create tasks.

Hierarchical Tasks

With Todoist you are able to create subtasks. This is very helpful when making list for things to buy or for packing lists. The parent task won’t be marked as finished until all its subtasks are finished as well.
So I use such sub tasks for example when packing for a holiday: I create a task “Holiday Packing” under my “Private” project and assign subtasks for each item I want to take (you can intend a subtask with the arrow on top of the text edit line)

So that’s it for now. I’ll try to extend this guide if I find more interesting tricks.

PySide/ PyQt

PySide/ PyQt Statusbar with colored Popup

I recently wrote an PySide UI where I needed Feedback for the user when an exception occured. I did not catch the underlying functions in any special way and just let them propagate to the top. But since the command line was hidden I looked for a way to make those exceptions visible to the user – and especially in a readable and noticable way.

So I implemented this Statusbar. Nothing fancy and coded real quick but maybe it helps someone else

<pre>from PySide import QtGui, QtCore

class ExceptionStatusBar(QtGui.QStatusBar):
    EXCEPTION_COLOR = QtGui.QColor("red")

    def __init__(self, level, **kwargs):
        super(ExceptionStatusBar, self).__init__(**kwargs)

        # Prepare background

        # Insert exception hook
        import sys
        sys.excepthook = self.create_excepthook(sys.excepthook)

    # Background Property
    # -----------------

    def set_color(self, color):
        self.setStyleSheet("background-color: rgb({0}, {1}, {2});"
                           .format(color.red(), color.green(), color.blue()))

    def get_color(self):
        # Will not be used
        return self.palette().color(QtGui.QPalette.Background)

    backgroundColor = QtCore.Property(QtGui.QColor, get_color, set_color)

    def create_excepthook(self, sys_hook):
        def custom_hook(exc_type, exc_value, tb):
            self.handle_exception(exc_type, exc_value)
            return sys_hook(exc_type, exc_value, tb)

        return custom_hook

    def handle_exception(self, exc_type, msg):
        # Need to make it a property of the instance instead it is garbage collected
        self._anim = QtCore.QPropertyAnimation(self, "backgroundColor")

        # Actually showing the message
        self.showMessage("{0}: {1}".format(exc_type.__name__, msg), timeout=2000)


By inserting my own excepthook in the sys.excepthook I get access to all Exceptions that will eventually happen. The QPropertyAnimation animates the Background Color.