[Solved] Text and image texture corruption with Ogre 2.1 on Windows only

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

Boost113
Not too shy to talk
Not too shy to talk
Posts: 45
Joined: Sat Apr 12, 2014 09:44

[Solved] Text and image texture corruption with Ogre 2.1 on Windows only

Postby Boost113 » Wed Oct 25, 2017 14:34

Hi,

I'm randomly seeing all rendered text and sometimes GUI textures being corrupted. It looks like this:
Image

This is what the texture corruption looks like:
Image

The correct rendering should look like this:

Image


I didn't try to take a video but text flickers between the correct rendering and just being white blocks when I hover over buttons. Also I think the text on the buttons in the middle is not affected because the framewindow is a RTT and the text is only rendered once so it doesn't get updated (at least not often).

What makes this very weird is that sometimes everything is fine (this happens every few restarts of my program) even when I try to hover over the buttons (the correct image). And sometimes only the cursor texture is wrong and the text looks fine, but it flickers quite infrequently.

Here are some screenshot from Renderdoc showing how the actual textures is the source of the invalid rendering:
Image
Image
Image

This doesn't happen on Linux everything works fine there.

Here's a bunch of logs and configuration options (I'm using

Code: Select all

CEGUI_STRING_CLASS=1
which has caused some bugs before and I currently have an open pull request to fix a compilation error with that option):

cmake configuration:

Code: Select all

-- Cache values
CCACHE_FOUND:FILEPATH=CCACHE_FOUND-NOTFOUND
CEGUI_BUILD_APPLICATION_TEMPLATES:BOOL=OFF
CEGUI_BUILD_COMMON_DIALOGS:BOOL=ON
CEGUI_BUILD_DATAFILES_TEST:BOOL=OFF
CEGUI_BUILD_DYNAMIC_CONFIGURATION:BOOL=ON
CEGUI_BUILD_IMAGECODEC_CORONA:BOOL=OFF
CEGUI_BUILD_IMAGECODEC_DEVIL:BOOL=OFF
CEGUI_BUILD_IMAGECODEC_FREEIMAGE:BOOL=OFF
CEGUI_BUILD_IMAGECODEC_PVR:BOOL=OFF
CEGUI_BUILD_IMAGECODEC_SDL2:BOOL=OFF
CEGUI_BUILD_IMAGECODEC_SILLY:BOOL=ON
CEGUI_BUILD_IMAGECODEC_STB:BOOL=OFF
CEGUI_BUILD_IMAGECODEC_TGA:BOOL=OFF
CEGUI_BUILD_LUA_GENERATOR:BOOL=OFF
CEGUI_BUILD_LUA_MODULE:BOOL=OFF
CEGUI_BUILD_PERFORMANCE_TESTS:BOOL=OFF
CEGUI_BUILD_PYTHON_MODULES:BOOL=OFF
CEGUI_BUILD_RENDERER_DIRECT3D11:BOOL=OFF
CEGUI_BUILD_RENDERER_DIRECTFB:BOOL=OFF
CEGUI_BUILD_RENDERER_IRRLICHT:BOOL=OFF
CEGUI_BUILD_RENDERER_NULL:BOOL=OFF
CEGUI_BUILD_RENDERER_OGRE:BOOL=ON
CEGUI_BUILD_RENDERER_OPENGL:BOOL=OFF
CEGUI_BUILD_RENDERER_OPENGL3:BOOL=OFF
CEGUI_BUILD_RENDERER_OPENGLES:BOOL=OFF
CEGUI_BUILD_RENDERER_OPENGLES2_ALTERNATE:BOOL=OFF
CEGUI_BUILD_RENDERER_OPENGLES2_ALTERNATE_WITH_GLES3_SUPPORT:BOOL=OFF
CEGUI_BUILD_SHARED_LIBS_WITH_STATIC_DEPENDENCIES:BOOL=OFF
CEGUI_BUILD_STATIC_CONFIGURATION:BOOL=OFF
CEGUI_BUILD_STATIC_FACTORY_MODULE:BOOL=OFF
CEGUI_BUILD_SUFFIX:STRING=_d
CEGUI_BUILD_TESTS:BOOL=OFF
CEGUI_BUILD_XMLPARSER_EXPAT:BOOL=ON
CEGUI_BUILD_XMLPARSER_LIBXML2:BOOL=OFF
CEGUI_BUILD_XMLPARSER_RAPIDXML:BOOL=OFF
CEGUI_BUILD_XMLPARSER_TINYXML:BOOL=OFF
CEGUI_BUILD_XMLPARSER_TINYXML2:BOOL=OFF
CEGUI_BUILD_XMLPARSER_XERCES:BOOL=OFF
CEGUI_DATA_INSTALL_DIR:BOOL=OFF
CEGUI_DOC_INSTALL_DIR:BOOL=OFF
CEGUI_HAS_DEFAULT_LOGGER:BOOL=ON
CEGUI_HAS_FREETYPE:BOOL=ON
CEGUI_HAS_MINIZIP_RESOURCE_PROVIDER:BOOL=OFF
CEGUI_HAS_PCRE_REGEX:BOOL=ON
CEGUI_INCLUDE_INSTALL_DIR:BOOL=OFF
CEGUI_INSTALL_WITH_RPATH:BOOL=OFF
CEGUI_LIB_INSTALL_DIR:BOOL=OFF
CEGUI_MODULE_INSTALL_DIR:BOOL=OFF
CEGUI_MSVC_STATIC_RUNTIME:BOOL=OFF
CEGUI_OPTION_DEFAULT_IMAGECODEC:STRING=SILLYImageCodec
CEGUI_OPTION_DEFAULT_XMLPARSER:STRING=ExpatParser
CEGUI_OPTION_SAFE_LUA_MODULE:BOOL=OFF
CEGUI_PKGCONFIG_INSTALL_DIR:BOOL=OFF
CEGUI_SAMPLES_ENABLED:BOOL=OFF
CEGUI_SAMPLE_INSTALL_DIR:BOOL=OFF
CEGUI_STATIC_IMAGECODEC_MODULE:STRING=CEGUISILLYImageCodec
CEGUI_STATIC_XMLPARSER_MODULE:STRING=CEGUIExpatParser
CEGUI_STRING_CLASS:STRING=1
CEGUI_USE_FRIBIDI:BOOL=OFF
CEGUI_USE_MINIBIDI:BOOL=OFF
CEGUI_USE_RAQM:BOOL=ON
CEGUI_WARNINGS_AS_ERRORS:BOOL=OFF
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo
CMAKE_INSTALL_PREFIX:PATH=C:/projects/Thrive/ThirdParty/leviathan/build/ThirdParty
CMAKE_PREFIX_PATH:PATH=C:/projects/Thrive/ThirdParty/leviathan/ThirdParty/cegui/dependencies
OGRE_FRAMEWORK_PATH:STRING=NOTFOUND
PCRE_DEFINITIONS_STATIC:STRING=PCRE_STATIC
SFML_INCLUDE_DIR:PATH=C:/projects/Thrive/ThirdParty/leviathan/build/ThirdParty/include
_LIB_PATH:FILEPATH=C:/projects/Thrive/ThirdParty/leviathan/ThirdParty/cegui/dependencies/lib/static/jpeg_d.lib


CEGUI log file important part:

Code: Select all

---- Version: 9999.0.0 (Build: Oct 25 2017 Microsoft Windows MSVC++ 14.0 (2015) 64 bit) ----
25/10/2017 15:18:45 (Std)    ---- Renderer module is: CEGUI::OgreRenderer - OGRE based 3rd generation renderer module with Ogre::Compositor2 enabled. ----
25/10/2017 15:18:45 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
25/10/2017 15:18:45 (Std)    ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
25/10/2017 15:18:45 (Std)    ---- Scripting module is: None ----


Nothing interesting in the Ogre log. But Ogre seems to correctly load non-gui textures



I'm not 100% certain where the issue is (whether it is in my code, CEGUI or Ogre, or something weird is going on due to the way I've setup my library compilation). So does anyone have any ideas?

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

Re: [Bug?] Text and image texture corruption with Ogre 2.1 on Windows only

Postby Ident » Wed Oct 25, 2017 19:19

Looks a lot like a misconfigured alpha blending in those cases where you see a square of white in the background of an image, where you should normally have transparency. So this would be a rendering issue, imo. I would look for it in the OgreRenderer.

On the second picture there is also this triangle mesh in the middle that looks messed up, if that is from CEGUI then I would put my bets on a misconfigured offset/strife in the vertex buffer.

On the second picture, regarding the textures, i cant tell whats wrong because i dont know how it should look. Are the colours right?
CrazyEddie: "I don't like GUIs"

Boost113
Not too shy to talk
Not too shy to talk
Posts: 45
Joined: Sat Apr 12, 2014 09:44

Re: [Bug?] Text and image texture corruption with Ogre 2.1 on Windows only

Postby Boost113 » Wed Oct 25, 2017 19:24

Actually, yeah it might be that the alpha blending is getting turned off and on causing the flickering and making the text appear as blocks.

But that still leaves the incorrect colours of the textures. This is what it should look like:
Image
(the top left GUI element is the correct colour in this image and the top right text isn't a bunch of squares)

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

Re: [Bug?] Text and image texture corruption with Ogre 2.1 on Windows only

Postby Ident » Wed Oct 25, 2017 19:42

It might be that this is also related to blending, although it is not quite as obvious. Would be good to first fix the blending and then see if the issue on those texture elements persists.
CrazyEddie: "I don't like GUIs"

Boost113
Not too shy to talk
Not too shy to talk
Posts: 45
Joined: Sat Apr 12, 2014 09:44

Re: [Bug?] Text and image texture corruption with Ogre 2.1 on Windows only

Postby Boost113 » Thu Oct 26, 2017 12:31

Poking around in the blending options I think I found where the issue is. There is this if statement in the Ogre Renderer.cpp on line 1121:

Code: Select all

if (d_pimpl->d_activeBlendMode == BlendMode::RttPremultiplied)


Tweaking it I was able to completely break the text rendering:
Image

And then fix it:
Image

This also fixed the weird colour issues:
Image

This is the code of that if statement in those working images (replaced the condition check with false):

Code: Select all

    //if (d_pimpl->d_activeBlendMode == BlendMode::RttPremultiplied)
    if(false)
    {
        blendblock.mSourceBlendFactor = Ogre::SBF_ONE;
        blendblock.mDestBlendFactor = Ogre::SBF_ONE_MINUS_SOURCE_ALPHA;
    }
    else
    {
        blendblock.mSeparateBlend = true;
        blendblock.mSourceBlendFactor = Ogre::SBF_SOURCE_ALPHA;
        blendblock.mDestBlendFactor = Ogre::SBF_ONE_MINUS_SOURCE_ALPHA;
        blendblock.mSourceBlendFactorAlpha = Ogre::SBF_ONE_MINUS_DEST_ALPHA;
        blendblock.mDestBlendFactorAlpha = Ogre::SBF_ONE;
    }


So the blend options in the top block of code are incorrect but the bottom ones work correctly
Now I just need to come up with a satisfactory fix and I'll open a pull request.

Edit: I think the issue was with Ogre::SBF_ONE which I changed to Ogre::SBF_SOURCE_ALPHA and that seems to have fixed the issues I was having. I'll open a pull request now.


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

Re: [Bug?] Text and image texture corruption with Ogre 2.1 on Windows only

Postby Ident » Fri Oct 27, 2017 08:30

Thanks a lot! It is merged.
CrazyEddie: "I don't like GUIs"


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 8 guests