Thank you very much for such an elucidative and prompt answer!

I knew the FBO way but since this is for a cluster with not-so-recent GPUs,
that alternative is was early declined.
With this need for changing every material in the tree to support the
stencilChunk, I opted for another approach, yes a third one. :)

I sorted the viewports with the map being rendered first, into a
TextureGragForeground. Then the object in the main viewport used the texture
in its material with the proper UVs. It's working really well without
changing too many things (this is a big project on tight schedule, the KISS
approach is always welcome).

Anyway thank you very much for the answer. I may need to use this in the
future anyway!


On 9/19/07, Carsten Neumann <[EMAIL PROTECTED]> wrote:
>
>         Hello José,
>
> José Pedro Dias wrote:
> > Hello to you all. I'm posting this after leading the most relevant mails
> in
> > this subject and taking a look at the examples provided in the source.
> So
> > you know :)
> >
> > I have two viewports, the second of them smaller, kind of a bird's eye
> view
> > map.
> > I already have them the way I want, except for the fact that I want the
> > smaller one to have a shape other than a rectangle (circle, in fact).
>
> using plain OpenGL you'd probably do the following:
> 1) render the circle form with the following stencil settings:
>         Func: GL_NEVER
>         Value: 1
>         Mask:  0xFFFF
>         OpFail: GL_REPLACE
>         OpZFail: GL_REPLACE
>         OpZPass: GL_REPLACE
>
> 2) render the scene with the following stencil settings:
>         Func: GL_EQUAL
>         Value: 1
>         Mask: 0xFFFF
>         OpFail: GL_KEEP
>         OpZFail: GL_KEEP
>         OpZPass: GL_KEEP
>
> For OpenSG that translates to:
> - create two stencil chunks, one for each of the above settings.
> - add the first one to the circle's material
> - set the ClearBuffer for that stencil chunk to 1, to clear the stencil
>    buffer before the circle is drawn
> - set the SortKey of the circle's material to a negative value, to
> make      sure it is rendered first
> - add the second stencil chunk to each material in the scene
> - render the small viewport
>
> For your large viewport you need to set the StencilFunc of the second
> chunk to GL_ALWAYS so that it does not affect that rendering. That
> however means you can not call Window::render because it will render
> both viewports in one go without giving you a chance to switch the value
>   in the stencil chunk. But you can just do the calls Window::render
> issues "by hand" (it is not much) and insert the value change between
> them.
>
> The ClearBuffer field of the stencil chunk is a bit tricky as it allows
> clearing that buffer during rendering. However due to the state sorting
> OpenSG normally performs this becomes quite unpredictable. For your case
> you only need to clear the buffer once, before the circle shape is
> drawn, so the combination of a negative sortKey and setClearBuffer(1) is
> sufficient.
>
> BTW for drawing the circle shape you might want to look at the
> PolygonBackground.
>
> A different solution to your problem would be to render to "map view"
> with a FBOViewport and draw the generated texture with a
> PolygonForeground over the main view.
>
>         Hope it helps,
>                 Carsten
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Opensg-users mailing list
> Opensg-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>



-- 
José Pedro Dias, n.48296, LEIC Tagus Park
[EMAIL PROTECTED]
[EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to