[osg-users] How to force reloading the texture in the shader

2011-08-29 Thread Fred Maulir
Hello to All,

I'm having a very specific issue using OpenSceneGraph. While using a texture 
shader I developped, I need to attach a texture to my object. But my texture 
need to be changed at each frame. However, I noticed that my texture is not 
updated in the next viewer.update() if my computer is very fast. If I slow down 
my computer it is correctly synchronized.

In other word, I'm looking for a way to way for a texture object to be 
propagated in the gpu buffer before rendering the frame.

As I'm using OpenSceneGraph for simulation purpose even 1 frame offset is not 
acceptable for me.


Basically the code can be summed up this way:

Code:

osg::Image IMAGE;
IMAGE-setImage(..., imageData, osg::Image::AllocationMode::NO_DELETE);

osg::StateSet *mystate = new osg::StateSet();
osg::Texture2D *texture = new osg::Texture2D();
texture-setImage(IMAGE);

(...)

for(int i=0;i!viewer-done();++i)
{
IMAGE-setImage(..., ImageData[i], osg::Image::AllocationMode::NO_DELETE);


viewer-frame(ctime);
}



In this example when rendering the scene OSG sometimes uses the ImageData of 
index i-1 instead of index i


If anyone can help me I would be very happy.
Regards.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to force reloading the texture in the shader

2011-08-29 Thread Fred Maulir
Sergey.

Thanks really A LOT for your fast and VERY EFFICIENT help. This problem drove 
me crazy for a while.

The setting texture-setDataVariance(osg::Object::DYNAMIC) did not help but the 
viewer-setThreadingModel(osgViewer::ViewerBase::SingleThreaded) worked very 
well.

Thanks again for your help.
Regards.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Windows of the viewer freezing when in a separate thread (Boost)

2011-08-26 Thread Fred Maulir
Hey.

Thanks Robert for your help.

I just figured out what was the problem. In fact I was calling the constructor 
of the osgViewer in a different thread that the viewer.frame() function. This 
cause a quite strange issue as the viewer correctly render the scene but does 
not response to any manipulator. I guess this is due to the fact that the 
windows handlers are linked to the creation thread and not the execution thread.

Thanks any way for your help.
Have a great day.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Windows of the viewer freezing when in a separate thread (Boost)

2011-08-25 Thread Fred Maulir
Hello to All,

I recently wanted to use OSG in a separate thread (a thread created with the 
Boost library) although I encounter a new issue. When I run the viewer  in this 
separate thread the window that is created is completely frozen.

The scene is correctly rendered in the window (and the scene is animated also) 
but the window is frozen meaning that I can't move/reduced/maximize the window. 
Also I can't anymore use the mouse to navigate in my scene (i have a camera 
manipulator). 
Of course I tested everything outside of this thread (in the main thread) and 
all the bugs disappeared. Can anyone help me about this problem ?

I'm sure that I'm not the only one to face this problem but I couldn't find a 
post related in the forum. Feel free to redirect me to any pre-existing post if 
you know any.

Thanks a lot for any answer.
Have a good day.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Retrieving value from a shader

2011-07-23 Thread Fred Maulir
Hey Paul.

Thanks for your answer no mater it is late or not. I'll test this during the 
week end and see whether I can achieve what I want. Your idea seems good 
although a bit tricky as I thought previously that it may an easy way to do 
this.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Depth texture for Pixel/Fragment Shader

2011-07-23 Thread Fred Maulir
I may not have been clear enough.
In few words I'd like to know how I can retrieve the depth texture 
corresponding to a spot light so I could implement light occlusion and light 
focusing.

Any ideas ?

Thanks.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Retrieving value from a shader

2011-07-22 Thread Fred Maulir
Hello,

I developped a texture projective mapping (TPM) using vertex and fragment 
shader and what I would like to do now is to get the information whether an 
object has been lit or not by the TPM.

I was thinking of setting a uniform value to 0 in osg through the setUniform 
function and change it to 1 in the pixel shader if any of the pixel has been 
lit by the tpm shader.
Setting the value to 0 is not complicate but I can't retrieve the value of the 
uniform modified by my shader. Is it possible ? Or is what I'm doing completely 
stupid ?

Thanks for your help.
Wallysx

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Retrieving value from a shader

2011-07-22 Thread Fred Maulir
Great advice. Do you mean than I can I retrieve the modified texture through a 
getUniform call after the update() call ?

In fact I'll have about 200 objects that I need to know if each of them have 
been lit or not.

Do you think I can do a 15*15 texture and associate one pixel with each object 
? Thus how can I retrieve a custom value in pixel shader that we'll indicate me 
which is the index of the current object on which the shader is applied to ?


Thanks again for your help.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Depth texture for Pixel/Fragment Shader

2011-07-22 Thread Fred Maulir
Hello everybody,

I'm new to osg and glsl but I wrote a shader for Texture Projection. So far 
everything is working as expected but I'd like now to implement the occlusion 
of different objects (depth order).

Can any one help me with this. I couldn't managed to find a osg/glsl tutorial 
about that.

Here is what I currently have:
[Image: http://s1.postimage.org/12pl9jd0/im1.jpg ] 
(http://postimage.org/image/12pl9jd0/)

Here is what I would like to obtain:
[Image: http://s1.postimage.org/1243a0xw/im2.jpg ] 
(http://postimage.org/image/1243a0xw/)


Thank you
wallys

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Retrieving value from a shader

2011-07-22 Thread Fred Maulir
Thanks for the ObjectID Uniform idea. It is working well.

However, I still can't find a way to retrieve data from the shader. The texture 
seems a good idea but I don't know how to do it. Any idea ?

As for the screencapture examples they are doing one pass to render the scene 
in the texture although I think it is really ressources consumming for what I 
wanna do.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Retrieving value from a shader

2011-07-22 Thread Fred Maulir
In fact it seems very painful as I have to render the scene twice: the first 
time render the scene in the texture file to retrieve the data, and the second 
time for the actual viewer.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Retrieving value from a shader

2011-07-22 Thread Fred Maulir
Exact, that's what I would like to do. I have a scene I want to render and in 
the same time I have a value I want to get back from the shader.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Retrieving value from a shader

2011-07-22 Thread Fred Maulir
I've been told that to solve my issue I should maybe use Frame Buffer Object 
(FBO). I don't know FBO at all but I wonder whether it could work or not.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org