HugoPeters
Topic Author
Posts: 2
Joined: 04 Feb 2019, 12:06

Off-screen elements (opacity < 100%) render incorrectly when resized

20 Apr 2019, 20:21

Hi,

I wasn't sure whether to submit this on the forum or as a bug, but it might very well be me doing something wrong, so here goes:
I've been integrating NoesisGUI into my own engine and I like it a lot, but I'm running into an issue where it seems the off-screen(?) render step doesn't take resizes into account.

As soon as there are transparent elements in the UI, resizing it messes up the entire widget.
Here's a video:


So what happens in the video:
- Widget with red (opaque) square works fine
- Adding another square, blue (80% opacity) messes up the resizing

The render implementation should be very straight forward, and looks like this:
bool NoesisViewRenderCallback::Render(Gfx_Context& aContext)
{
    WAR_PROFILE_CATEGORY_SCOPE("NoesisGUI", C_Colors::Magenta);

    IView* noesisView = mHandler->GetNoesisView();

    {
        WAR_PROFILE_SCOPE_NAMED("View Update");
        noesisView->Update(mElapsedSeconds);
    }

    {
        WAR_PROFILE_SCOPE_NAMED("UpdateRenderTree");
        noesisView->GetRenderer()->UpdateRenderTree();
    }

    if (noesisView->GetRenderer()->NeedsOffscreen())
    {
        WAR_PROFILE_SCOPE_NAMED("RenderOffscreen");
        aContext.GetRenderContext()->SetFrameBuffer(NULL);
        noesisView->GetRenderer()->RenderOffscreen();
        aContext.GetRenderContext()->SetFrameBuffer(aContext.GetRenderData().GetFBO());
    }

    {
        WAR_PROFILE_SCOPE_NAMED("Render");
        noesisView->GetRenderer()->Render();
    }

    return true;
}
The resize code is also pretty straight forward:
void NoesisViewHandler::OnViewResize(int aNewWidth, int aNewHeight)
{
    if (mNoesisView)
    {
        mNoesisView->SetSize(uint32(aNewWidth), uint32(aNewHeight));
    }
}
mNoesisView being a Noesis::Ptr<Noesis::IView> .

Also for reference, the XAML code used in the video:
<UserControl x:Class="WarlockUI.SimpleDialog"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:WarlockUI"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid Background="Black">
		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
			<Grid Height="100" Width="100" Background="Red">
				<TextBlock TextWrapping="Wrap" Text="Opaque" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontFamily="Microsoft Yi Baiti"/>
			</Grid>
			<Grid Height="100" Width="100" Background="#FF0068FF" Margin="15.4,0,0,0" Opacity="0.8">
				<TextBlock TextWrapping="Wrap" Text="Opacity 80%" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontFamily="Microsoft Yi Baiti"/>
			</Grid>
		</StackPanel>

	</Grid>
</UserControl>
Anything that I'm missing or might this be a bug?
This is on latest v2.2.1.

Tags:
 
User avatar
jsantos
Site Admin
Posts: 2900
Joined: 20 Jan 2012, 17:18
Contact:

Re: Off-screen elements (opacity < 100%) render incorrectly when resized

22 Apr 2019, 16:36

Are you restoring the viewport after the off-screen phase?
 
User avatar
jsantos
Site Admin
Posts: 2900
Joined: 20 Jan 2012, 17:18
Contact:

Re: Off-screen elements (opacity < 100%) render incorrectly when resized

22 Apr 2019, 16:40

What profiler is that by the way, is it a custom implementation? It looks cool 😊
 
HugoPeters
Topic Author
Posts: 2
Joined: 04 Feb 2019, 12:06

Re: Off-screen elements (opacity < 100%) render incorrectly when resized

22 Apr 2019, 17:06

Are you restoring the viewport after the off-screen phase?
Ah.. yep that fixes it! Thanks!
Looking back in the manual now I notice the little OpenGL sample, but perhaps some extra callout for dumb people like me would be nice :)
What profiler is that by the way, is it a custom implementation? It looks cool 😊
Haha thanks! I made it from scratch with dear imgui :)

Who is online

Users browsing this forum: No registered users and 1 guest