Hi,

I am currently working on a Shader that is supposed to color fragments 
approaching the camera red and fragments departing the camera green.
So for example, if an object in the scene is traveling towards the camera, it 
should be rendered red, otherwise green.

For that, my basic idea was to compute the distance of each fragment to the 
camera, and then subtract the distance of the same fragment from the previous 
frame. If the result is negative, the fragment would approach the camera and 
therefore be red, otherwise green.

The challenge here is to get the fragment position from the previous frame 
though.
>From my understanding, the fragments position relative to the camera (0,0,0,1) 
>is calculated by interpolating
gl_Vertex * gl_ModelViewMatrix, where ModelViewMatrix is calculated as 
(viewmatrix * modelmatrix).

So, what I would need is something like "gl_ModelViewMatrixPreviousFrame".
While it is relatively easy to pass the previous viewmatrix to the shader by 
setting a uniform on the parent camera in OSG and updating it in the program 
render loop, how would one go about passing the old modelMatrix? The model 
matrix can be different for every primitive in the scene, so wouldn't I need a 
million uniforms for that? How would that even work?

Thank you!

Cheers,
Philipp

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to