Ok. I managed to get lights correctly on the screen. (Thanks Michael.)
I used cull callback to update the light position uniform. It works 
excellently in single threaded environments. But if I want to use 
multithreaded rendering models of OSG?

I guess, I have few choices:

- cull callbacks
   - it works, but I am not sure whether the uniform is "shared" and it can be 
updated by cull thread and rendered at the same time from rendering thread, 
leading to visual artifacts

- update callbacks
  - the same as above. Moreover, the registering of update callbacks disables 
ON_DEMAND rendering, e.g. the scene is continually redrawn. In my opinion, 
ON_DEMAND rendering should not be disabled by update callbacks (bug?). Or, if 
this is desired behaviour, maybe a function can be introduced to allow both 
behaviours.

- to modify Uniform to carry modelView matrix with it
  - is there a way to do it? As there could be several cameras doing the cull 
in parallel and few graphics contexts doing the rendering at the same time.

Thanks for explanation, or few hints that would clarify the things of 
multithreaded use of dynamically changing scene graph.
John


On Friday 03 of February 2012 01:37:55 Michael Guerrero wrote:
> Hi John,
> 
> A few things come to mind that might help:
> 
> 1) Make sure when you do your calculations, everything is in the same space.
>  For example, if you wanna get the direction from the vertex to the light
> in view space (lightPos - vertex) then both the light position and the
> vertex need to already be in view space before you take the difference.
> 
> 2) View space is characterized by having the camera centered at the origin
> and facing down the -z axis (in OpenGL).  This means that the vector (0.0,
> 0.0, -1.0) is your forward vector in view space.
> 
> 3) It helps to be familiar with the characteristics of coordinate systems at
> each transformation stage: local/world/view/clip (after
> projection)/NDC(normalized device coordinates), and finally screen
> coordinates.  I'm sure there's a ton of good information about this on the
> web or one of the many 3d graphics books.
> 
> Good luck,
> Michael
> 
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=45201#45201
> 
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to