[osg-users] Get current Billboard ModelView matrix?

Philipp Meyer philipp.meyer at fh-bielefeld.de
Thu Jun 30 01:44:51 PDT 2016


My goal is to create a fragment shader that computes the delta distance to each fragment compared to the previous frame.

In the shader, I can easily calculate the current distance to a fragment by using built in functions, the problem is that I also need access to the fragment position in the PREVIOUS frame in order to compute the delta and generate the output.

As the vertex and fragment shaders have no native access to data of the previous frame my idea was to use uniform variables to pass the viewMatrix and the modelMatrix of the PREVIOUS frame to the vertex shader.

I can easily retrieve old viewMatrix by setting a uniform variable in the program main render loop after the current frame completed.
However, it is very difficult to obtain the old modelMatrix because the modelMatrix is unique to every primitive in the scene (or in other words, there are many modelView matrices and not just one).

So, the only solution I found was to attach a uniform to every transform node in my scene graph and store the previous modelMatrix in it.
This is very CPU intensive but works okay, unfortunately I do not yet take Billboards into account and this is why I need to calculate the modelMatrix of a Billboard.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=67926#67926








More information about the osg-users mailing list