[osg-users] Get current Billboard ModelView matrix?

Julien Valentin julienvalentin51 at gmail.com
Thu Jun 30 02:19:34 PDT 2016


Hi Milles25
If I understand you correctly you want to compute differences between fragment props. Your approach seams very CPU intensive and GPU redondant (you compute 2 times interpolants of your VS out attrib).
You should use pingpong Render2Texture in order to store previous frame fragment props and then access it throught texture sampling in the current frame.
It would be a lot more efficient.

attach tex1 to main camera
sample tex2 in your FS
swap(tex1,tex2)



mille25 wrote:
> 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. Then I could simply compute the old vertex position and pass it as varying variable to the fragment 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. (Calculate the total modelMatrix by multiplying all parent matrix transforms on the CPU)
> 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=67927#67927








More information about the osg-users mailing list