[SOLVED] Rendering to Ogre texture, nothing shows up

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

TheSHEEEP
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Mon Aug 12, 2013 09:59

Re: Rendering to Ogre texture, nothing shows up

Postby TheSHEEEP » Wed Mar 18, 2015 17:04

Okay, I now use the GuiContext correctly.. I think :)

My code now looks like this:

Code: Select all

// Create the gui context
    CEGUI::System& ceguiSystem = CEGUI::System::getSingleton();
    CEGUI::OgreRenderer* ogreRenderer = static_cast<CEGUI::OgreRenderer *>(ceguiSystem.getRenderer());
    CEGUI::Sizef size(static_cast<float>(_width), static_cast<float>(_height));
    _renderTextureTarget = ogreRenderer->createTextureTarget();
    _renderTextureTarget->declareRenderSize(size);
    _renderGuiContext = &ceguiSystem.createGUIContext(static_cast<CEGUI::RenderTarget&>(*_renderTextureTarget) );
    _renderGuiContext->setRootWindow(_layoutWindow);

    // Render
    ogreRenderer->beginRendering();
    _renderTextureTarget->clear();
    _renderGuiContext->draw();
    ogreRenderer->endRendering();


Alpha is still wrong (as in the screenshot), but the position of the window is now correctly at the bottom of the screen.

Afaik, the Ogre renderer uses shaders to render the GUI. Now, wherever these shaders are applied, they do not apply alpha correctly. For whatever reason.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering to Ogre texture, nothing shows up

Postby Ident » Wed Mar 18, 2015 17:14

Oh another issue the GUIcontext would have solved for you. You asked why the window is on the top right. Well. You only render this one Window to the entire texture, there is no defaultwindow as parent, so the window IS what you render. The rest of the texture is not written to. And the window starts at the top left, the location is only relevant if there was a parent, but there isnt, so that explains that. Regarding the transparency: This is probably an issue in Ogre itself, probably the unused pixels have 0,0,0,0 am I right? 0 alpha should however mean full transparency. Or maybe those other pixels are set to something else and never cleared. Icant know for sure with the given info, you would have to debug the texture on your debugger using gdebugger or a similar program (codexl, etc).
CrazyEddie: "I don't like GUIs"

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering to Ogre texture, nothing shows up

Postby Ident » Wed Mar 18, 2015 17:14

Ah good that it is fixed. Please use a DefaultWindow as described as root anyways. Everything else can lead to issues.

Regarding the alpha please show a before and after image.
CrazyEddie: "I don't like GUIs"

TheSHEEEP
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Mon Aug 12, 2013 09:59

Re: Rendering to Ogre texture, nothing shows up

Postby TheSHEEEP » Wed Mar 18, 2015 17:35

Here is a picture before I load the layout (the green tint is due to the texture that is on the material by default (a green transparent .tga), which is replaced by GUI in the next step):
Link

And here a screenshot after:
Link

I do not think this is an Ogre issue. As the first screenshot shows, alpha works very well in that material. And the only thing that changes is the texture_unit's texture, which is changed to the one created by CEGUI. So that texture really has alpha=1 everywhere, it is not an error in our rendering pipeline.

If it is Ogre related, it must be something in the CEGUI::OgreRenderer.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering to Ogre texture, nothing shows up

Postby Ident » Wed Mar 18, 2015 17:39

Please confirm, so i can be absolutely sure: So you say the textue is rendered in both cases?

If that is true, then yea, the alpha has to be 1 everywhere. Btw this would definitely not be the case in the case of auto-rendering-surfaces inside CEGUI otherwise they would, too, cover everything, which they DO NOT. And you had had the issue with your auto-rendering-surface approach as well. So this is very strange.
CrazyEddie: "I don't like GUIs"

TheSHEEEP
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Mon Aug 12, 2013 09:59

Re: Rendering to Ogre texture, nothing shows up

Postby TheSHEEEP » Wed Mar 18, 2015 17:43

Ident wrote:Please confirm, so i can be absolutely sure: So you say the textue is rendered in both cases?

Yes, the texture on the material is rendered in both cases.
In the first case it is just a tga (with working transparency), in the second case, it is the texture produced by CEGUI (transparency not working).

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering to Ogre texture, nothing shows up

Postby Ident » Wed Mar 18, 2015 17:45

There is no TGA on your GPU. What's important is only what the pixel values are on the GPU, which is why I asked for GPU debugging. Anyways, try the following: use the CEGUI stuff and after drawing always call clear() on the CEGUITextureTarget. What do you see?
CrazyEddie: "I don't like GUIs"

TheSHEEEP
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Mon Aug 12, 2013 09:59

Re: Rendering to Ogre texture, nothing shows up

Postby TheSHEEEP » Wed Mar 18, 2015 17:51

Ident wrote:Anyways, try the following: use the CEGUI stuff and after drawing always call clear() on the CEGUITextureTarget. What do you see?

The result is exactly the same as in the second screenshot.

Btw... I am using a DefaultWindow now as the root. Did not change anything about the result.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering to Ogre texture, nothing shows up

Postby Ident » Wed Mar 18, 2015 18:05

DefaultWindow or not - this wont change anything in the case of rendering a GUIContext. This is merely solving any potential functional issues, such as mouse-inside window events etc. DefaultWindows are not rendered themselve. However they can be auto-render-targets in which case you could use them in your previous technique and get the window position right this time ;)


Okay,.. in the case of OpenGL the clear function would set all pixels to 0,0,0,0 so that should be equal to full transparency. The OgreRenderer does too but it also does things differently a bit. Imo it should already work.

Without using CEGUI, can you do the following:
ogreRenderSystem.clearFrameBuffer(Ogre::FBT_COLOUR, Ogre::ColourValue(0, 0, 0, 0)); after setting the viewport to your Texture in which you would otherwise render CEGUI. Do you know how to create a correct viewport?

What I am trying to achieve here is to find out if the clear function, as used inside CEGUIOgreRenderer, leads to the same issue if you call it directly as above.
CrazyEddie: "I don't like GUIs"

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering to Ogre texture, nothing shows up

Postby Ident » Wed Mar 18, 2015 18:08

TheSHEEEP wrote:
Ident wrote:Anyways, try the following: use the CEGUI stuff and after drawing always call clear() on the CEGUITextureTarget. What do you see?

The result is exactly the same as in the second screenshot.


Wait that makes no sense. Your GUI is still drawn?
CrazyEddie: "I don't like GUIs"

TheSHEEEP
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Mon Aug 12, 2013 09:59

Re: Rendering to Ogre texture, nothing shows up

Postby TheSHEEEP » Wed Mar 18, 2015 18:17

Ident wrote:
TheSHEEEP wrote:
Ident wrote:Anyways, try the following: use the CEGUI stuff and after drawing always call clear() on the CEGUITextureTarget. What do you see?

The result is exactly the same as in the second screenshot.


Wait that makes no sense. Your GUI is still drawn?

Yes.

Anyway... Progress!

I think our assumption about alpha was all wrong:
This is another screenshot, this time showing the alpha value instead of the colors.
Link
I should have output that long ago, sorry :(

So, CEGUI does output correct alpha values.
But using the image for some reason prevents anything else from being rendered.

I will research this, my guess is it has something to do with the compositors, but I am not sure...

TheSHEEEP
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Mon Aug 12, 2013 09:59

Re: Rendering to Ogre texture, nothing shows up

Postby TheSHEEEP » Wed Mar 18, 2015 18:32

TheSHEEEP wrote:I will research this, my guess is it has something to do with the compositors, but I am not sure...

At least this time, I was correct.
Note: Do not set the texture of a material in a compositor listener each single frame. I am not sure why this lead to the problem, though.

Now I'll correct my wiki entry.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering to Ogre texture, nothing shows up

Postby Ident » Wed Mar 18, 2015 18:34

So nothing was wrong with CEGUI after all ;)

Thanks for correcting the CEGUI article. Be sure to add info about the trouble you had and how you resolved it. I am pretty sure someone else will run into the issue at some poin as well.
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 12 guests