Page 3 of 4

Re: MyGUI ported to Ogre 2.1! =)

Posted: Wed Apr 12, 2017 9:42 pm
by Lax
Hi rujialiu, al2950,

I got MyGUI running so far. But getting a crash in MyGUI when trying to use PbsMaterialsWorkspace for my scene, like the following (taken from examples):

Code: Select all

Ogre::CompositorManager2* compositorManager = Core::getSingletonPtr()->getOgreRoot()->getCompositorManager2();
		const Ogre::IdString workspaceName(definitionName);
		if (!compositorManager->hasWorkspaceDefinition(definitionName))
		{
			compositorManager->createBasicWorkspaceDef(definitionName, color, Ogre::IdString());
		}
		this->workspace = compositorManager->addWorkspace(this->sceneManager, Core::getSingletonPtr()->getOgreRenderWindow(), this->camera, definitionName, true);

Code: Select all

OGRE EXCEPTION(5:ItemIdentityException): Can't find texture with name: '2048' If it's a global texture, trying to use it in the output channel will fail. in CompositorNodeDef::getTextureSource at D:\Ogre\GameEngineDevelopment\external\Ogre2.1SDK\OgreMain\src\Compositor\OgreTextureDefinition.cpp (line 212)
@rujialiu: You said:
If you updated your Ogre to the latest commit, which contains the new shadow system, you need to modify MyGUI, (the constructor of PassDef and PassProvider has changed a bit), but it's trivial.
I'm using the lastest commit, so has it something todo with that?

Regards
Lax

Re: MyGUI ported to Ogre 2.1! =)

Posted: Wed Apr 12, 2017 10:44 pm
by al2950
Due to the shadow script changes you need to redo you shadow nodes. In fact I would take a very close look at your whole repository!

Re: MyGUI ported to Ogre 2.1! =)

Posted: Thu Apr 13, 2017 9:27 pm
by Lax
What do you mean with "redo your shadow nodes"? Should I go back to a earlier branch version of Ogre2.1?
I would like to give access to the code, but its just local git for now and for a longer time nothing commited, because its a whole mess since I started to port to Ogre2.1.
The progress is the following:
- I'm using Ogre's resource listener and MyGui at the loading screen to have visual effect when loading all resources and that does work.
- I'm Using a state system inspired by Advanced Ogre Framework http://www.ogre3d.org/tikiwiki/tiki-ind ... &pagenum=1.
- After loading the resources a MenuState will be initialized, where I create a compositor workspace with "PbsMaterialsWorkspace" for shading.

So I do not know if creating "PbsMaterialsWorkspace" does bite with workspace for MyGUI?

Re: MyGUI ported to Ogre 2.1! =)

Posted: Thu Apr 13, 2017 10:48 pm
by al2950
no I am mean the script interface has changed for defining the shadow nodes. So you need to make some changes to your compositor, take a look at the latest samples;
https://bitbucket.org/sinbad/ogre/src/e ... positor-30

Re: MyGUI ported to Ogre 2.1! =)

Posted: Sat Apr 15, 2017 9:56 pm
by Lax
Ok, that was the trick, the hlms resources changed in the media folder so as 2.0/compositor resources. Thanks a lot!
Now I'm fighting with reinitialisation of mygui and workspaces since my application is state based and each state has its scene manager and camera, so each time I try to remove the workspace and add again. But thats my beer.

Re: MyGUI ported to Ogre 2.1! =)

Posted: Mon Apr 24, 2017 9:29 pm
by Lax
Hi all,

I have just another question. I have MyGui running, but I wondered why I do not have shadows in my scene. It came out, that I can have either MyGui workspace or the "PbsMaterialsWorkspace" workspace.
When I removed the MyGui workspace, the shadows were visible.
Is it somehow possible to have both workspaces?

Regards
Lax

Re: MyGUI ported to Ogre 2.1! =)

Posted: Tue Apr 25, 2017 8:39 am
by al2950
Not sure without looking at your code. But having a separate workspace to render mygui over the top should make no difference to shadows. In fact that is exactly how I do it in my app and I have no problems.

Re: MyGUI ported to Ogre 2.1! =)

Posted: Thu Apr 27, 2017 9:07 pm
by Lax
Thats strange, how you do that?

I do the following:

Code: Select all

// Graphics
Ogre::CompositorManager2* compositorManager = Core::getSingletonPtr()->getOgreRoot()->getCompositorManager2();
const Ogre::IdString workspaceName("PbsMaterialsWorkspace");
if (!compositorManager->hasWorkspaceDefinition("PbsMaterialsWorkspace"))
{
	compositorManager->createBasicWorkspaceDef(definitionName, color, Ogre::IdString());
}
this->workspace = compositorManager->addWorkspace(sceneManager, Core::getSingletonPtr()->getOgreRenderWindow(), camera, "PbsMaterialsWorkspace", true); // PbsMaterialsWorkspace

// MyGui
this->myGuiOgrePlatform = new MyGUI::Ogre2Platform();
this->myGuiOgrePlatform->initialise(this->renderWindow, sceneManager, "Essential", logName);

const Ogre::String workspaceName = "MyGuiWorkspace";
const Ogre::IdString workspaceNameHash = workspaceName;

Ogre::CompositorManager2* compositorManager = this->root->getCompositorManager2();
Ogre::CompositorNodeDef* nodeDef = compositorManager->addNodeDefinition("MyGuiWorkspaceNode");
//Input texture
nodeDef->addTextureSourceName("WindowRT", 0, Ogre::TextureDefinitionBase::TEXTURE_INPUT);
nodeDef->setNumTargetPass(1);
{
	Ogre::CompositorTargetDef* targetDef = nodeDef->addTargetPass("WindowRT");
	targetDef->setNumPasses(3);
	{
		Ogre::CompositorPassClearDef* passClear = static_cast<Ogre::CompositorPassClearDef*>(targetDef->addPass(Ogre::PASS_CLEAR));
		Ogre::CompositorPassSceneDef* passScene = static_cast<Ogre::CompositorPassSceneDef*>(targetDef->addPass(Ogre::PASS_SCENE));
		passScene->mShadowNode = Ogre::IdString();

		// For the MyGUI pass
		targetDef->addPass(Ogre::PASS_CUSTOM, "MYGUI");
	}
}

Ogre::CompositorWorkspaceDef* workDef = compositorManager->addWorkspaceDefinition(workspaceName);

workDef->connectExternal(0, nodeDef->getName(), 0);
this->myGuiWorkspace = compositorManager->addWorkspace(sceneManager, this->renderWindow, camera, workspaceNameHash, true);

this->myGui = new MyGUI::Gui();
this->myGui->initialise();
So I have MyGui but no shadows. If I reverse the code (First MyGui then Graphics) I have shadows but no MyGUI anymore. Using one workspace "PbsMaterialsWorkspace" for graphics and MyGUI causes a crash.

Or is it possible somehow to have one workspace for MyGUI and the scene with shadows?

I also tried to use "PbsMaterialsWorkspace" for MyGUI but that does not work, as MyGUI does create its own target pass etc. and the "PbsMaterialsWorkspace" has also passes for scene and shadows.

This is really a hell. I'm really stuck here for weeks now... :(

Re: MyGUI ported to Ogre 2.1! =)

Posted: Tue May 02, 2017 12:26 pm
by Lax
I managed to use MyGUI as seperate pass within the "PbsMaterialsWorkspace". It was really tricky. Hlms must be registered prior and the resource group for all 2.0 materials initialized. After that the "PbsMaterialsWorkspace" workspace definition does exist and can be used. So anyone that has issues with that, here is the example code:

Code: Select all

                this->myGuiOgrePlatform = new MyGUI::Ogre2Platform();
		this->myGuiOgrePlatform->initialise(this->renderWindow, sceneManager, "Essential", logName);

		const Ogre::String workspaceName = "PbsMaterialsWorkspace";
		const Ogre::IdString workspaceNameHash = workspaceName;

		Ogre::CompositorManager2* compositorManager = this->root->getCompositorManager2();
		Ogre::CompositorNodeDef* nodeDef = compositorManager->getNodeDefinitionNonConst("PbsMaterialsRenderingNode");

		nodeDef->setNumTargetPass(1);
		{
			Ogre::CompositorTargetDef* targetDef = nodeDef->getTargetPass(0);
			targetDef->setNumPasses(3);
			{
				// For the MyGUI pass
				targetDef->addPass(Ogre::PASS_CUSTOM, "MYGUI");
			}
		}

		Ogre::CompositorWorkspaceDef* workDef = nullptr;
		if (!compositorManager->hasWorkspaceDefinition(workspaceName))
		{
			workDef = compositorManager->addWorkspaceDefinition(workspaceName);
		}
		else
		{
			workDef = compositorManager->getWorkspaceDefinition(workspaceName);
		}

		workDef->connectExternal(0, nodeDef->getName(), 0);
		this->myGuiWorkspace = compositorManager->addWorkspace(sceneManager, this->renderWindow, camera, workspaceNameHash, true);

		this->myGui = new MyGUI::Gui();
		this->myGui->initialise();
Note that, I'm using an own Ogre::ResourceGroupListener to visualize the resource loading. So because of that, I needed to load also all 2.0 (compositor, pbs) resources, in order to have a valid "PbsMaterialsWorkspace".
The only question that I have, I added as a third pass the MYGUI pass and I see that the frames per second went down :( . Was It valid to merge "PbsMaterialsWorkspace" with MyGUI? Or is there a better solution?

Regards
Lax

Re: MyGUI ported to Ogre 2.1! =)

Posted: Wed May 03, 2017 5:23 am
by rujialiu
Lax wrote:I managed to use MyGUI as seperate pass within the "PbsMaterialsWorkspace". It was really tricky. Hlms must be registered prior and the resource group for all 2.0
Note that, I'm using an own Ogre::ResourceGroupListener to visualize the resource loading. So because of that, I needed to load also all 2.0 (compositor, pbs) resources, in order to have a valid "PbsMaterialsWorkspace".
The only question that I have, I added as a third pass the MYGUI pass and I see that the frames per second went down :( . Was It valid to merge "PbsMaterialsWorkspace" with MyGUI? Or is there a better solution?
What do you mean by "merge PbsMaterialsWorkspace with MyGUI"? For me your setup looks ok.

You're creating workspace definition by hand with C++? We also did this when we're using Ogre 2.0, but later we use pure compositor scripts, which is a lot easier to maintain. Adding a new pass in the compositor node is simple:

Code: Select all

pass custom MYGUI_PASS
{
}
And if you later add another pass before that, you don't have to change your code from "targetDef->setNumPasses(3)" to "targetDef->setNumPasses(4)". And if you want to temporarily disable MyGUI, simple comment out that pass with the usual /* and */. If your fps still drops sigfinicantly (e.g. from 60 to 30?), you can try to simplify your UI to see whether your UI is too complex or there's something wrong (e.g. fps drops even if you execute mygui pass but don't have ANY UI to render).

Re: MyGUI ported to Ogre 2.1! =)

Posted: Wed May 03, 2017 6:58 pm
by Lax
Hi rujialiu,

"merge PbsMaterialsWorkspace with MyGUI" means, I used the pre-defined PbsMaterialsWorkspace and added the custom MYGUI pass by code. So that I do have Pbs with shadows and MyGui working.
But you are right and thanks for the tip! I loose the flexibility when I do It by code. So now I'm doing it via script:

Code: Select all

compositor_node PbsMaterialsRenderingNode
{
	in 0 rt_renderwindow

	target rt_renderwindow
	{
		
		pass clear
		{
			colour_value 0.2 0.4 0.6 1
		}

		pass render_scene
		{
			overlays	on
			shadows		PbsMaterialsShadowNode
		}
		
		pass custom MYGUI
		{
		   
		}
	}
}
The trick is that, the "Compositors" scripts must be parsed, after Ogre2Plattform is initialized:

Code: Select all

this->myGuiOgrePlatform = new MyGUI::Ogre2Platform();
this->myGuiOgrePlatform->initialise(this->renderWindow, sceneManager, "Essential", logName);

// Load compositor resources
Ogre::String compositorsFolder = "../../media/2.0/scripts/Compositors";
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(compositorsFolder, "FileSystem", "Compositors");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Compositors");
Regards
Lax

Re: MyGUI ported to Ogre 2.1! =)

Posted: Thu May 04, 2017 8:07 am
by rujialiu
Lax wrote: The trick is that, the "Compositors" scripts must be parsed, after Ogre2Plattform is initialized:
Yes, indeed. This is tricky. Forgot to tell you. Sorry.... You have to be very careful about compositor node DEFINITION ORDER. Also, if you have complex compositors which are split into files, you may even need to put them into different folders to ensure the loading order is correct (in the same folder, they're parsed in lexicographical order)

Do you have other issues?

BTW: For me, I don't use overlays so I use "overlay off" during render scene.

Re: MyGUI ported to Ogre 2.1! =)

Posted: Thu May 04, 2017 9:33 pm
by Lax
Hi,

no, MyGUI works now fine. Thank you all!

Regards
Lax

Re: MyGUI ported to Ogre 2.1! =)

Posted: Thu Jun 15, 2017 3:41 pm
by xrgo
Hello! I just started using MyGui... awesome library btw!! thanks for the port!!!
I am rendering MyGui to a RGBA texture, which is used in a Pbs datablock (with alpha blend) on a 3D mesh.... and I have 2 problems (I don't know if its 2.1 related, anyways I prefer to post here because mygui subforums seems really dead), to achieve this I also removed the scene pass of the compositor node.

1)
Image
as you can see the antialiased pixels of fonts and images are transparent and I can see through them =(, how to fix this?? I need to use alpha blending because I obviously want some parts of the gui to be transparent.

2)
when calling Ogre2Platform->initialise one of the arguments its the renderwindow... since I am rendering to a texture I shouldn't need to pass the renderwindow... and its actually giving me trouble:
The texture I am rendering to has a resolution of 1920x1080, if I start my engine with a window resolution of 1920x1080 or 1280x720 or any other 16:9 ratio everything works fine... but if I use another ratio all the MyGui things in my texture gets stretched and cropped. It seems like there used to be a platform->getRenderManagerPtr()->setViewSize where you could force a size but that method is gone.any fix for this? (this problem is less important since 99% of the time I will start the engine with a 16:9 ratio)

Thank you so much in advance!!!

Re: MyGUI ported to Ogre 2.1! =)

Posted: Fri Jun 30, 2017 7:35 pm
by xrgo
No one knows about my prev post? =(

EDIT: I think I can solve the problem below using CompositorWorkspaceListener::passPreExecute and CompositorWorkspaceListener::passPosExecute, I've done that before for other things.. it should work =)... still interested in the problems of my previous post.

I have another question regarding MyGui....
is it posible to create multiple instances of MyGui to be used in multiple textures/rendertargets with this port??
I have read that it should be posible at least in Ogre1.X, and the test UnitTest_RTTLayer does that using multiple layers, but my concern is that this port uses a custom mygui pass compositor that has a passID that is static/unique... so I think I can't just make another workspace...
I would like to confirm if its even posible before wasting many hours =)

Thanks!!!!

Re: MyGUI ported to Ogre 2.1! =)

Posted: Sun Jul 02, 2017 2:33 am
by xrgo
I have a problem using CompositorWorkspaceListener, it doesn't work with custom passes =(

EDIT:
OK!! solved the lack of custom pass notification to the listener with this workaround:

I made a second clear pass after the custom mygui pass, so the pass execution of the workspace is CLEAR, CUSTOM, CLEAR, but this second clear pass don't clear color... so just using the passPosExecute, I toggle a bool flag and set the visibility of MyGui's root widget for this specific gui on and off... so ti goes like this:

starts the clear
do the clear
finish the clear, and the listener catches this with the passPosExecute, so setVisible(true) to the rootwidget of this gui.
render the myGui pass!
starts the second clear
do the clear
finish the second clear, and the listener catches this with the passPosExecute, so setVisible(false) to the rootwidget of this gui.

this way the other guis I have wont mix up with each other, it works!

Re: MyGUI ported to Ogre 2.1! =)

Posted: Mon Jul 03, 2017 12:37 am
by xrgo
Hello again, I just workarounded problem 2) by doing a dummy hidden window

Code: Select all

    Ogre::NameValuePairList params;
    params["hidden"] = "true";

    Ogre::RenderWindow* dummyWindow = Ogre::Root::getSingletonPtr()->createRenderWindow( "dummyWindow", 1024, 1024, false, &params );

    mMyGUIPlatform = new MyGUI::Ogre2Platform();
    mMyGUIPlatform->initialise(
                dummyWindow,
                mSceneManager,
                Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME
    );

    dummyWindow->destroy();

Re: MyGUI ported to Ogre 2.1! =)

Posted: Mon Jul 03, 2017 10:23 am
by al2950
Hi xrgo

Apologies for not answering any of your posts. However I am afraid I can not help without taking a closer look myself. There is no reason why you could not render MYGUI into 2 separate windows, although MYGUI takes a renderwindow as a parameter I dont htink it actually uses it at the moment. However if you wanted different content I am not sure how that might be achieved.

As for your rendering issues, well it appears my previous comment is wrong and it does use the render window! If that code was not working I would expect to see more issues. Please note that the MYGUI port still has some issues, especially when it comes to layering or RTTs, but I currently only need it for very simply overlays so have not had time to look into it.

Re: MyGUI ported to Ogre 2.1! =)

Posted: Mon Jul 03, 2017 4:15 pm
by xrgo
Thank you so much, don't worry, already solved most of the problems/limitations
al2950 wrote:However if you wanted different content I am not sure how that might be achieved
yes! that is exactly what I wanted and I achieved! using CompositorWorkspaceListener, its working great (at this moment at least, haven't tested so much)

so the only problem I am having right now is the transparency one that I posted the screenshot :/

Re: MyGUI ported to Ogre 2.1! =)

Posted: Mon Jul 03, 2017 5:39 pm
by al2950
Are you running with Anti-aliasing, and if so what technique are you using?

Re: MyGUI ported to Ogre 2.1! =)

Posted: Mon Jul 03, 2017 7:15 pm
by xrgo
al2950 wrote:Are you running with Anti-aliasing, and if so what technique are you using?
its the antialiasing of the Font texture and the images (in this case that logo) itself... the problem seems to be the following:

I render the gui into a texture with alpha channel, If I have a completely opaque widget, lets say a button, it works great, I can only see the button floating around... but! if I put some text in the button I can see the antialiased border of the texture transparent above the opaque button background... in other words.. its like the alpha value of a widget/texture/font overwrites the alpha value below them, so in result it becomes transparent.

not sure if I made myself clear :P

Gracias! Saludos!!

Re: MyGUI ported to Ogre 2.1! =)

Posted: Wed Aug 09, 2017 8:48 pm
by xrgo
xrgo wrote: Image
I was messing with transparency in my pbs datablocks and noticed that when two semi-transparent planes where on top of each other I got the same problem, and setting macroblock.mDepthWrite = false; solved the issue..
so I tried to do the same with the unlit datablocks used/generated by MyGui (since every widget is a plane rendered on top of the parent one)... but no luck =(
any ideas on how to solve this?

Re: MyGUI ported to Ogre 2.1! =)

Posted: Wed Aug 09, 2017 9:40 pm
by xrgo
SOLVED!!!

it was the blendblock... I just made a refreshDatablock method like this:

Code: Select all

void yGuiManager::refreshDatablocks(){
    Ogre::Hlms::HlmsDatablockMap::const_iterator itor = Ogre::Root::getSingletonPtr()->getHlmsManager()->getHlms( Ogre::HLMS_UNLIT )->getDatablockMap().begin();
    Ogre::Hlms::HlmsDatablockMap::const_iterator end  = Ogre::Root::getSingletonPtr()->getHlmsManager()->getHlms( Ogre::HLMS_UNLIT )->getDatablockMap().end();
    while( itor != end )
    {
        Ogre::HlmsUnlitDatablock* datablock = static_cast<Ogre::HlmsUnlitDatablock*>( itor->second.datablock );
        Ogre::HlmsBlendblock newMacroblock;

        newMacroblock.mSeparateBlend = true;
        newMacroblock.mSourceBlendFactor = Ogre::SBF_SOURCE_ALPHA;
        newMacroblock.mDestBlendFactor = Ogre::SBF_ONE_MINUS_SOURCE_ALPHA;
        newMacroblock.mSourceBlendFactorAlpha = Ogre::SBF_ONE;
        newMacroblock.mDestBlendFactorAlpha = Ogre::SBF_ONE_MINUS_SOURCE_ALPHA;

        datablock->setBlendblock( Ogre::Root::getSingletonPtr()->getHlmsManager()->getBlendblock( newMacroblock ) );
        ++itor;
    }
}
that has to be called every time after myGui creates a datablock, like when it loads a texture or a font.
Now its working perfectly... but I think my gui should use datablocks with a blendblock like that by default so we dont have to do this kind of workarounds.

Thanks! awesome lib!

Re: MyGUI ported to Ogre 2.1! =)

Posted: Sat Sep 02, 2017 6:03 pm
by Lanboost
al2950 wrote:Fixes done and pull request has been accepted. I would recommend getting the source from the main MyGUI Repo

NB to use the Ogre 2 render system you MUST set the MYGUI_RENDERSYSTEM to 8

THINGS THAT DONT WORK
1) RTTs dont currently function properly
2) Due to 1, the layout editor does not work as expected

Old post but, anyone know if this ever got fixed, cause my "layout editor" seems not to show any "widgets" until I use the "test" button.

I dont really care about LE but I need RTT to work correctly and no hack I have tried have worked currently, tried to duplicate my current gui to a second ogre RTT compositor and it worked except the blending didnt seem to work correctly making the gui components to just copy the alpha value to the texture overwriting the data there.

Anyone have any ideas?

Re: MyGUI ported to Ogre 2.1! =)

Posted: Sat Sep 02, 2017 6:41 pm
by xrgo
Lanboost wrote:Old post but, anyone know if this ever got fixed, cause my "layout editor" seems not to show any "widgets" until I use the "test" button.
I just use the precompiled ones (that use Ogre 1.X I guess) and it works great
https://sourceforge.net/projects/my-gui ... p/download
Lanboost wrote:except the blending didnt seem to work correctly making the gui components to just copy the alpha value to the texture overwriting the data there
you mean like the problem I mentioned many post before? I solved it!, see the post just above yours