Overlay Showing Blank Whilte

Problems building or running the engine, queries about how to use features etc.
Post Reply
mcmonkey
Gnoblar
Posts: 19
Joined: Fri Jan 09, 2015 6:12 am

Overlay Showing Blank Whilte

Post by mcmonkey »

This code

Code: Select all

                overlay = OverlayManager.Singleton.Create("MainGUI");
                PanelOverlayElement element = (PanelOverlayElement)OverlayManager.Singleton.CreateOverlayElement("Panel", "PanelElement");
                element.MaterialName = "Test/ColourTest";
                element.Top = 0f;
                element.Height = 0.5f;
                element.Left = 0f;
                element.Width = 1f;
                element.Colour = new ColourValue(0, 1, 1, 1);
                TextAreaOverlayElement text = (TextAreaOverlayElement)OverlayManager.Singleton.CreateOverlayElement("TextArea", "TestText");
                text.Colour = new ColourValue(0, 0, 1, 1);
                text.CharHeight = 16;

                FontPtr mFont = FontManager.Singleton.Create("BlueHighway", "General");
                mFont.Type = FontType.FT_TRUETYPE;
                mFont.TrueTypeSize = 16;
                mFont.TrueTypeResolution = 96;
                mFont.AddCodePointRange(new Pair<uint, uint>(33, 255));
                mFont.Source = "bluehigh.ttf";

                text.FontName = "BlueHighway";
                text.Left = 0.1f;
                text.Top = 0.1f;
                text.Width = 0.5f;
                text.Height = 0.5f;
                text.SetAlignment(TextAreaOverlayElement.Alignment.Left);
                text.Caption = "Hello World";
                text.Show();
                element.AddChild(text);
                element.Show();
                overlay.Add2D(element);
                overlay.Show();
where the material is defined as

Code: Select all

            MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourTest", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
generates a blank white wall covering half the screen.

In theory, it should render a cyan wall covering half the screen with deep-blue text on it.

Why is this not working?

I'm thinking it's because the material ignores the Colour value set on the elements and forces everything to white - how do I avoid that?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Overlay Showing Blank Whilte

Post by dark_sylinc »

Grab the pass (material->getTechnique(0)->getPass(0)) you have several options:
  • Set the colour in the material's pass rather than in the overlay. i.e. call pass->setDiffuse or pass->setEmissive.
  • Instruct the material to use the vertex colour, use pass->setVertexColourTracking for that.
  • Use shaders (recommended, but a more advanced topic); read the colour from the vertex shader and output it to the pixel shader.
mcmonkey
Gnoblar
Posts: 19
Joined: Fri Jan 09, 2015 6:12 am

Re: Overlay Showing Blank Whilte

Post by mcmonkey »

Code: Select all

            material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT;
No change.

Code: Select all

            material.GetTechnique(0).GetPass(0).SetDiffuse(1, 0, 0, 1);
No change.

Code: Select all

            material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT;
            material.GetTechnique(0).GetPass(0).SetDiffuse(1, 0, 0, 1);
No change.

Adding

Code: Select all

            material.Load();
after any: No change.

Adding

Code: Select all

            material.Compile();
after any: No change.

EDIT{
Adding

Code: Select all

            material.GetTechnique(0).SetAmbient(1, 0, 0);
does nothing too.}

There's gotta be something big I'm missing.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Overlay Showing Blank Whilte

Post by dark_sylinc »

My knowledge on the FF (Fixed Function) pipeline in Ogre is a little rusty.
But try TVC_DIFFUSE and TVC_EMISSION, rather than AMBIENT.
mcmonkey
Gnoblar
Posts: 19
Joined: Fri Jan 09, 2015 6:12 am

Re: Overlay Showing Blank Whilte

Post by mcmonkey »

dark_sylinc wrote:My knowledge on the FF (Fixed Function) pipeline in Ogre is a little rusty.
But try TVC_DIFFUSE and TVC_EMISSION, rather than AMBIENT.
Both yield nothing :(

Know any good tutorials on setting up shaders in OGRE? I can't find any.

(I've experience in OpenGL, including using shaders, so it shouldn't be too difficult for me to learn how OGRE does it).

UPDATE: While I'm still curious about this, I found a sprite manager which solves 90% of my problems for now -- in the end, learning the native OGRE systems is probably better.

.. a way to link shaders in the SpriteManager2d (this: http://www.ogre3d.org/tikiwiki/tiki-ind ... eManager2d ) would be amazing
Post Reply