Hello Vincenzo,
Vincenzo Marafioti wrote:
> Carsten Neumann ha scritto:
>> Basically you only have to create an FBOViewport and add multiple
>> TextureChunks to it, they will be added as color attachments to the
>> FBO and you can write them from a shader with gl_FragData[i]. I don't
>> have any example for MRT handy, but there is
>> Source/System/Window/testFboVp.cpp and Tutorials/29FBOTexture.cpp that
>> demonstrate how to use the FBOViewport in general.
>>
> I made some test using MRT in OpenSG but now the "only" triky part if to
> pass back the texture written to OpenGL for the next pass. I have a
> multipass algorithm composed by a first shader to be run in openGL and
> the second in OpenSG for each pass. This is wat i have done till now:
do you have to keep the pure OpenGL parts or could you reimplement them
with OpenSG code?
Can you give some details on what your multipass algorithm is doing? To
what extend do you want it to work seamlessly with OpenSG (e.g. do you
need this to work in a cluster at some point, do you expect certain
passes to be able to render with more or less arbitrary materials/textures)?
> < From OpenGL to OpenSG > (works!)
> - i just call glActivateTexture(GL_TEXTUREXYZ) for the three
> textures i need and bind it, then pass to the OpenSG shader, as uniform,
> the texture unit activated (setUniformParameter("samplerTex", XYZ));
ok, this probably works because OpenSG is not trying to activate or
change any state relating to textures by itself, but it seems rather
hackish and may not work in general (hence my question above, if that is
a problem for you).
> < From OpenSG to OpenGL >
> - my first attemp was to bind in OpenGL to the correct fbo with the
> three texture to be written
> - my second attemp was to use the FBOViewport and so to write to the
> texture attached to the FBOViewport (as you suggest).
probably both ways could be made to work, you are not describing what
*exactly* is not working, so I'm not sure how to help. Maybe if you post
a pseudo code description of how/where you create OpenGL resources, how
you pass them around and how you enable them for use it would be
possible to diagnose this better. In general you'd to use a texture that
was used by OpenSG in some pure OpenGL code, you'd only need to know the
OpenGL id of that texture and then bind and activate it normally.
To get the texture id from OpenSG you need to take the value
TextureChunk::getGLId() and pass it to Window::getGLObjectId(), the
return value from that function is the "real" OpenGL id.
The indirection through the window is necessary because a texture can
have different OpenGL ids in different OpenGL contexts (Window is the
abstraction of an OpenGL context).
> I attache a simple chart to explain it better.
> In both case the problem seams to be about make them to be read back by
> the OpenGL shader. I would like to find a good performance way to do it.
Keep the texture on the gfx card, without ever downloading it to main
memory. You can access the texture represented by a TextureChunk from
OpenGL if you know the id it has in the current GL context (see above).
Cheers,
Carsten
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users