[2.1] Unlit weird transparency issue with scaling

Problems building or running the engine, queries about how to use features etc.
Post Reply
Boost113
Kobold
Posts: 35
Joined: Sun Sep 08, 2013 6:39 pm
x 6

[2.1] Unlit weird transparency issue with scaling

Post by Boost113 »

Ogre Version: 2.1 (a6204308c4fa)
Operating System: Linux
Render System: OpenGL3+

After getting my meshes to render in the correct order with Unlit and transparency, I've hit another issue. Sorry for being so bad at graphics programming...

Anyway, the issue is that I want to scale a mesh, that I've built using pixel size, to fit another size. But when the scale factor (I use the same for both X and Y) is under 1.0 the texture becomes transparent all of a sudden (the texture has an alpha channel but all pixels are fully opaque) so I have no idea why that happens:
Image
The logo in the center should not be visible.

Then when I increase the window size so that the scale is over 1.0 the transparency suddenly fixes itself:
Image

This is my code for doing the scaling (width and height are the window size to fit the mesh to):

Code: Select all

DLLEXPORT void WidgetWithStandardResources::SetAllocatedSize(int width, int height)
{
    if(!Node)
        return;

    if(width == NaturalWidth && height == NaturalHeight) {

        Node->setScale(1, 1, 1);
        return;
    }

    const float scaleWidth = width / static_cast<float>(NaturalWidth);
    const float scaleHeight = height / static_cast<float>(NaturalHeight);

    const auto scale = std::min(scaleWidth, scaleHeight);

    const int widthDifference = width - NaturalWidth * scale;
    const int heightDifference = height - NaturalHeight * scale;

    Node->setScale(scale, scale, 1);
    Node->setPosition(X + widthDifference / 2, -(Y + heightDifference / 2), 0);
}
I had a look with RenderDoc but I could not see anything interesting, all the settings seem to be basically the same between big and small window size:
Image

At least I confirmed with RenderDoc that the texture correctly has 255 as alpha. There's also no errors in the Ogre log.

If I disable the transparency on the blendblock then it works correctly, but I've linked that to checking if the texture has an alpha channel, so I don't want to use this approach and add a separate flag for overriding the alpha channel from the texture. I also tried to set the bounds to be bigger on the mesh and scaling up in the Z direction, but those had no effect. Any help with this is greatly appreciated.
Boost113
Kobold
Posts: 35
Joined: Sun Sep 08, 2013 6:39 pm
x 6

Re: [2.1] Unlit weird transparency issue with scaling

Post by Boost113 »

And I just ran into another issue (one that I can't figure any kind of workaround for). It happens when I swap the scene I'm displaying on a window by removing the workspace the scene is in and creating a new workspace with a different scene. This seems to break almost everything. Just a few select things display correctly. This time RenderDoc shows that the objects don't get any vertex buffers set (and that's why they stop rendering):
Image

So something obviously goes wrong when I remove and add a workspace. I tried disabling removing the workspace and just adding one extra one but that results in the same thing for some reason.

This is how the game should look like:
Image

This is how the new scene looks like (the mouse, background,and GUI is missing):
Image

And after returning from the other scene (with another compositor workspace remove and add) only some items display correctly:
Image

The behaviour seems consistent as the same object types are always the ones that keep working.
Post Reply