[osg-users] multipass calculating with shaders

2007-09-17 Thread [EMAIL PROTECTED]
Hi,
 first I would like to reask the question I sent few days ago since it might 
have been overlooked so here it is:

Hello,
 in the osg examples there are several examples of how to use RTT.
I would like to concatenate several renderings. I mean, render the scene to 
texture1, then use texture1 to create texture2, then use texture1  texture2 to 
create texture3 and so on.

I don't understand how to control the order of the rendering. I tried to change 
the rendering order number of the camera's I used in PRE_RENDER and it didn't 
seem to have any effect. The results seems fine, but I don't know if it used 
the data in the texture from the current frame or the previous.

(in the example I made to check this ability, I render the cow to texture, then 
using PRE_REND
ER  shader I remove the red plane and later I remove the green plane, changing 
the order should result in different images)

this brings me to the next question. I tried to clear the texture used to 
render the Scene to. I tried setting the texture image to new allocated image, 
dirty the texture parameters and dirty the texture object and nothing seems to 
have the required result. dirty the texture object results as blank screen, the 
other operation doesn't seem to clear the texture since changing the order in 
the multipass didn't change the results.

another problem I had was to render in different passes to the same texture. 
(Even if it was in the POST_RENDER sub tree). is there a way to reuse the same 
texture in different passes?

the last problem I encountered is that I rendered the resulting textures, using 
several cameras NESTED_RENDER each drawing a square with different texture 
attached 2 it and each camera has different viewport. The problem is the is the 
cameras viewport intersected, I couldn't change the order they are rendered (to 
make one of them on top of the other). I tried setting the RenderDetaill with 
higher and lower numbers, both for the Camera and for the Geodes, with no 
success.

any ideas concerning any of the problems would be appriciated.

thanks,
  Guy.

second, I want to render single or several (4 - 8) values which represnt some 
calculation. So I use render to texture. The texture is 1D and to render to it 
I use orthographic projection, and the viewport fits to the texture dimension. 
The geometry I render is points. One point per calculation, and each point 
should result as one pixel. Is this the right way? I has to set the point size 
to 1.5 to see anything, any ideas why?

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


Re: [osg-users] multipass calculating with shaders

2007-09-17 Thread [EMAIL PROTECTED]
thanks, I'll try that.

more problems I'm facing is setting the image internal data type, I've seen
in the examples setting the internal type to 3 or 4. what does it mean? how
do I set it to float or int?
and I couldn't read from the image even that I used code very similar to
osgprerender example :(, the image-data() return buffer filled with
garbage.

but thanks anyway,
 Guy.
- Original Message -
From: John Donovan [EMAIL PROTECTED]
To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
Sent: Monday, September 17, 2007 3:43 PM
Subject: Re: [osg-users] multipass  calculating with shaders


 [EMAIL PROTECTED] wrote:

  second, I want to render single or several (4 - 8) values which represnt
some calculation. So I use render to texture. The texture is 1D and to
render to it I use orthographic projection, and the viewport fits to the
texture dimension. The geometry I render is points. One point per
calculation, and each point should result as one pixel. Is this the right
way? I has to set the point size to 1.5 to see anything, any ideas why?

 It sounds like you need to offset your point centres by 0.5 I don't have
the
 spec in front of me, but I think you've got to shift it in the positive
 direction on both axes, but you may have to play with the signs until it
works :)

 -J



 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



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


Re: [osg-users] multipass calculating with shaders

2007-09-17 Thread John Donovan
[EMAIL PROTECTED] wrote:
 thanks, I'll try that.
 
 more problems I'm facing is setting the image internal data type, I've seen
 in the examples setting the internal type to 3 or 4. what does it mean? how
 do I set it to float or int?

I use the following code for rendering to a floating-point texture:
_texture = new Texture2D;
_texture-setResizeNonPowerOfTwoHint(false);
_texture-setTextureSize(_totalWidth, _totalHeight);
_texture-setSourceType(GL_FLOAT);
_texture-setSourceFormat(GL_RGB);
_texture-setInternalFormat(GL_RGB32F_ARB);
_texture-setFilter(Texture2D::MIN_FILTER, Texture2D::NEAREST);
_texture-setFilter(Texture2D::MAG_FILTER, Texture2D::NEAREST);


 and I couldn't read from the image even that I used code very similar to
 osgprerender example :(, the image-data() return buffer filled with
 garbage.

If I understand it correctly, the Image associated with a Texture is used for
uploading the data into the texture. If you want to read from the texture,
you'll need to copy it to a buffer. I can't remember how to do that off-hand,
but it'll likely be fairly slow.

-J


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] multipass calculating with shaders

2007-09-17 Thread [EMAIL PROTECTED]
thank Jhon.

I want to read the buffer from the texture only for debug purposes. In the
final program I won't do it. I need to  associate image with the texture to
set it's initial values, and later some passes in the multipass sequences
are updating this data. The problem is that after associating image with the
texture, I think the image reads automatically the texture buffer (take the
osgprerender example for instance, there is an image and in the post render
they play with it's buffer, which means the image read the current texture),
and this might slow down the program.

Another thing is as I mentioned earlier: I need to set the initial values of
the texture, and the only way I know how to do it is using images, so the
question is how do I set images internal type, pixel type and gltype, to be
float, long, etc... (unsigned char appears in the examples).

btw, I offset the point by half and it worked for one pass that renders
about 3 pixels. it didn't work for other pass that renders 1 pixel. is there
a problem when the viewport is 1x1?

thanks a lot,
 Guy.
- Original Message -
From: John Donovan [EMAIL PROTECTED]
To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
Sent: Monday, September 17, 2007 4:54 PM
Subject: Re: [osg-users] multipass  calculating with shaders


 [EMAIL PROTECTED] wrote:
  thanks, I'll try that.
 
  more problems I'm facing is setting the image internal data type, I've
seen
  in the examples setting the internal type to 3 or 4. what does it mean?
how
  do I set it to float or int?

 I use the following code for rendering to a floating-point texture:
 _texture = new Texture2D;
 _texture-setResizeNonPowerOfTwoHint(false);
 _texture-setTextureSize(_totalWidth, _totalHeight);
 _texture-setSourceType(GL_FLOAT);
 _texture-setSourceFormat(GL_RGB);
 _texture-setInternalFormat(GL_RGB32F_ARB);
 _texture-setFilter(Texture2D::MIN_FILTER, Texture2D::NEAREST);
 _texture-setFilter(Texture2D::MAG_FILTER, Texture2D::NEAREST);


  and I couldn't read from the image even that I used code very similar to
  osgprerender example :(, the image-data() return buffer filled with
  garbage.

 If I understand it correctly, the Image associated with a Texture is used
for
 uploading the data into the texture. If you want to read from the texture,
 you'll need to copy it to a buffer. I can't remember how to do that
off-hand,
 but it'll likely be fairly slow.

 -J


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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