Color changes

Problems building or running the engine, queries about how to use features etc.
Post Reply
jhwangbo
Gnoblar
Posts: 12
Joined: Sun Feb 24, 2019 11:27 pm
x 1

Color changes

Post by jhwangbo » Thu Oct 10, 2019 3:12 pm

Ogre Version: 1.12.1, 1.12.2
Operating System: Ubuntu 18.04
Render System: GL3PLUS

I am developing an open-source visualizer for my simulator RAISIM (https://github.com/leggedrobotics/raisimOgre). I have a big issue in the displayed color. Even though I specify a material for every object, some objects become the same color as other objects. Here is how I create an object (from OgreVis.cpp)

Code: Select all

  auto *ent = this->getSceneManager()->createEntity(name, meshName);
  ent->setMaterialName(mat);
  auto *node = this->getSceneManager()->getRootSceneNode()->createChildSceneNode(name);
  node->attachObject(ent);
then I render it using

Code: Select all

  getRoot()->renderOneFrame();
here the getRoot() is from OgreApplicationContextBase. This color change is random. Sometimes, I get the correct color, sometimes not. I tried it to debug it myself. I ran with Valgrind but there is no memory issues. Could this be a bug in ogre? I tested it with 1.12.1, 1.12.2 and the latest master commit and consistently see this error
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 877
Joined: Sun Mar 30, 2014 2:51 pm
x 176
Contact:

Re: Color changes

Post by paroj » Thu Oct 10, 2019 3:26 pm

- does it also happen with the GL render sytem?
- does the correct coulor appear at some alter timepoint?
- are you sure that the random colors are not actually the same?
0 x

jhwangbo
Gnoblar
Posts: 12
Joined: Sun Feb 24, 2019 11:27 pm
x 1

Re: Color changes

Post by jhwangbo » Thu Oct 10, 2019 3:39 pm

- it works fine with GL render system.
- alter time point? do you mean it changes every frame? as far as my video recording goes, no.
- the color is not actually random. it is one that I defined for another object. If I define blue for object A and red for object B, I get purple on one of them. So the color is overlayed I think
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 877
Joined: Sun Mar 30, 2014 2:51 pm
x 176
Contact:

Re: Color changes

Post by paroj » Thu Oct 10, 2019 4:23 pm

in that case I would say that the code snipped you posted is correct, but something with the material creation goes wrong.

With GL3+ the color goes through the RTSS and hence through:
https://github.com/OGRECave/ogre/blob/0 ... e.cpp#L574

where you could break to check whether the value is still correct. With GL it uses the fixed function pipeline instead.

Also I could not reproduce your issue (using opencv ovis):

Code: Select all

import cv2

sz = (4, 4)
N = 20

win = cv2.ovis.createWindow("test", (800, 600))

for i in range(N):
    for j in range(N):
        e = "e{:02d}{:02d}".format(i, j)
        m = "m{:02d}{:02d}".format(i, j)
        cv2.ovis.createPlaneMesh(m, sz)
        win.createEntity(e, "m0000", ((i - N / 2) * 5, (j - N / 2) * 5, 0))
        win.setEntityProperty(e, cv2.ovis.ENTITY_MATERIAL, m)
        cv2.ovis.setMaterialProperty(m, cv2.ovis.MATERIAL_EMISSIVE, (255 / N * i, 255 / N * j, 255))
        cv2.ovis.waitKey(1)
0 x

Post Reply