Thanks!
The only idea that comes to my mind is to tell the ShadowStage what kind of
background is set
and then react correspondingly...



-----------------------------------------------------------------------
thanks for testing! I'm committing a cleaned up version of it. There is
a new option on the ShadowStage, that you need to enable
(setCombineBlend(true)), this enables blending when writing the combined
scene and shadow images to the framebuffer.
The limitation on having to switch backgrounds when shadows are enabled
remains unfortunately. I'll explain the reason for it, in case someone
has an idea how to resolve it:

The ShadowStage first renders a lit (no shadows) version of the scene
into an FBO (if shadows are enabled, otherwise it simply renders the lit
scene to the target framebuffer). It then creates the shadow maps for
each light source and combines those into a single shadow intensity
image. The two images (lit scene and shadow intensity) are then combined
by multiplying the scene color with the shadow intensity and written to
the target framebuffer.
For the compositing to work the scene image has to be transparent except
where the scene objects are (hence the FBO has to be cleared with a
SolidBackground with alpha == 0).
However, if shadows are disabled there is no scene image, the scene is
rendered directly to the target framebuffer, so no clearing of colour
buffers should happen (i.e. a DepthClearBackground is needed).
One option would be to add a NO_SHADOW_COMPOSE mode that renders the
scene to an FBO and then draws that image into the target framebuffer,
but that seems like overkill. Other ideas?

        Cheers,
                Carsten



On Tue, Mar 19, 2013 at 4:40 PM, Christian Bar <[email protected]> wrote:

> Whoah! It works!
> Thank you.
> Hope you can make it work with the DepthClearBackground also when shadows
> are enabled, but for now... Thanks!
>
>
>
> On Tue, Mar 19, 2013 at 3:46 PM, Christian Bar <[email protected]>wrote:
>
>> Thank you! ASAP I'll try it and I'll let you know :)
>>
>> Christian
>>
>>
>> ---------------------------------------------
>> I'm attaching a quick hack that makes the test case I have work. Before I
>> clean it up and implement it properly would you mind giving it a try to
>> see if it works for you as well? Thanks!
>>
>> There is one remaining issue I'm aware of:
>>
>> The viewport with shadows needs a SolidBackground with alpha == 0.f when 
>> shadows
>> are enabled and a DepthClearBackground when shadows are disabled. I'm
>> not sure how to get around that right now.
>>
>>         Cheers,
>>                 Carsten
>>
>>
>>
>>
>>
>> On Fri, Mar 15, 2013 at 5:11 PM, Christian Bar <[email protected]>wrote:
>>
>>> Thank you for your answer :)
>>> No, I have to render the other viewport first...
>>> The solution shoul be exactly what you are proposing:
>>> teaching the ShadowStage to not touch pixels not
>>> written to by the scene it renders.
>>> Hope it is not too complicated...
>>> In any case, Thank you :)
>>>
>>> Christian
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------------
>>>         Hello Christian,
>>>
>>>
>>> On 03/15/2013 04:54 AM, Christian Bar wrote:
>>> > Firstly I call window->addPort( viewport_2 ), then  window->addPort(
>>> > viewport_1 ) (misleading viewort names, maybe :) ),
>>> >
>>> > so the rendering order should be the one I told you (as the rendering
>>> > without shadows demonstrates me).
>>>
>>> ah, ok :)
>>>
>>>
>>> > The problem shows only when I activate the ShadowStage...
>>>
>>> yes, the ShadowStage works sort of like a post-processing effect that
>>> redraws the whole viewport. I'll have to investigate the implementation
>>> to see how difficult it would be to teach it not to touch pixels not
>>> written to by the scene it renders. I'll look into it.
>>> I'm assuming rendering the shadowed scene first is not an option for
>>> you, right?
>>>
>>>         Cheers,
>>>                 Carsten
>>>
>>>
>>>
>>> On Fri, Mar 15, 2013 at 10:54 AM, Christian Bar <[email protected]>wrote:
>>>
>>>> Firstly I call window->addPort( viewport_2 ), then  window->addPort(
>>>> viewport_1 ) (misleading viewort names, maybe :) ),
>>>>
>>>> so the rendering order should be the one I told you (as the rendering
>>>> without shadows demonstrates me).
>>>>
>>>> The problem shows only when I activate the ShadowStage...
>>>>
>>>> Thanks,
>>>>
>>>> Christian
>>>>
>>>>
>>>> ---------------------------------------------------------------------------------
>>>>
>>>> Carsten 
>>>> Neumann<http://www.mail-archive.com/[email protected]&q=from:%22Carsten+Neumann%22>
>>>>  Thu, 14 Mar 2013 16:34:09 
>>>> -0700<http://www.mail-archive.com/[email protected]&q=date:20130314>
>>>>
>>>>         Hello Christian,
>>>>
>>>> thanks for the updated problem description!
>>>>
>>>> On 03/14/2013 09:45 AM, Christian Bar wrote:
>>>> > I have one window. In this window I render two viewports, fully 
>>>> > overlapping
>>>> > inside the window.
>>>> > Each viewport renders a different scenegraph. Let's call 'viewport_1' and
>>>> > 'viewport_2' the two viewports.
>>>> >
>>>> > - viewport_1 begins with a Node containing a ShadowStage and has a
>>>> > DepthClearBackground
>>>> > - viewport_2 has no shadows and a GradientBackground
>>>> >
>>>> > When I call window->render(), I expect that:
>>>> > - GradientBackground is rendered,
>>>> > - viewport_2 scenegraph content is rendered,
>>>> > - DepthClearBackground clears the depth buffer (not the frame buffer)
>>>> > - viewport_1 is rendered (also with shadows)
>>>>
>>>> hmm, viewports are rendered in the order they are stored in the window,
>>>> so viewport_1 should be first, then viewport_2.
>>>>
>>>> > What I see inside the window is only viewport_1 content, without a 
>>>> > background
>>>> > (as if there were none, the framebuffer is not cleared).
>>>> > This behaviour happens with every shadow mode.
>>>>
>>>> Given the render order above, my expectation would be that you only see
>>>> the content of viewport_2 - something seems to go wrong though.
>>>>
>>>> > When I disable shadows, I see that everything works as expected.
>>>> > Maybe it's useful for you to know that if I change the window size, the
>>>> > framebuffer is cleared (with a black color).
>>>>
>>>> I think you'll have to put the GradientBackground on viewport_1 and the
>>>> DepthClearBackground on viewport_2.
>>>> Under normal circumstances (i.e. I suspect a bug is preventing this from
>>>> working right now) this should give you the desired result. I'm looking
>>>> into it.
>>>>
>>>>         Cheers,
>>>>                 Carsten
>>>>
>>>>
>>>
>>
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to