Materials does not render some atributes properly -OpenGL

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Materials does not render some atributes properly -OpenGL

Post by arras »

Windows XP
OpenGL 2.0.6847
ATI MOBILITY RADEON X700
Irrlicht 1.4
DevC++

Materials are not rendered with correct attributes (as if some attributes were not updated between materials when they are rendered). Not sure however if it is not caused by my hardware so please run test below.

Here is example:
Two spheres using different specular color and shininess but both rendered with the same ones. First rendered incorrectly.

first sphere: specular = r0, g0, b255 shininess = 0.0f
second sphere: specular = r255, g0, b0 shininess = 10.0f

Both are rendered the with the same red specular effect (first should have no specular effect at all and if then blue).

Image

Code: Select all

#include <irrlicht.h>
using namespace irr;

int main()
{
   IrrlichtDevice* device = createDevice(
      video::EDT_OPENGL,
      core::dimension2d<s32>(640, 480), 32, false, false, false, 0);
    
   video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
   
   // firsth sphere, its specular is set to blue and shininess to 0 but it shows
   // red specular instead (should not reflect specular at all)
   // its renders same specular as second shpere
   scene::ISceneNode *sphere1 = smgr->addSphereSceneNode(5,128);
   sphere1->setPosition(core::vector3df(-6,0,0));
   sphere1->getMaterial(0).AmbientColor = video::SColor(255, 255, 255, 255);
   sphere1->getMaterial(0).DiffuseColor = video::SColor(255, 255, 255, 255);
   sphere1->getMaterial(0).SpecularColor = video::SColor(255, 0, 0, 255);
   sphere1->getMaterial(0).Shininess = 0;
   
   // second sphere its specular is set to red and shininess to 10
   scene::ISceneNode *sphere2 = smgr->addSphereSceneNode(5,128);
   sphere2->setPosition(core::vector3df(6,0,0));
   sphere2->getMaterial(0).AmbientColor = video::SColor(255, 255, 255, 255);
   sphere2->getMaterial(0).DiffuseColor = video::SColor(255, 255, 255, 255);
   sphere2->getMaterial(0).SpecularColor = video::SColor(255, 255, 0, 0);
   sphere2->getMaterial(0).Shininess = 10;
   
   // third to show light position
   scene::ISceneNode *sphere3 = smgr->addSphereSceneNode(1,128);
   sphere3->setMaterialFlag(video::EMF_LIGHTING, false);
   sphere3->setMaterialFlag(video::EMF_WIREFRAME, true);
   
   // camera
   scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 50, 10);
   camera->setPosition(core::vector3df(0,10,-10));
   camera->setTarget(core::vector3df(0,0,0));
   
   // light
   scene::ILightSceneNode *light = smgr->addLightSceneNode(sphere3, core::vector3df(0,0,0));
   
   // animate light
   scene::ISceneNodeAnimator *anim = smgr->createFlyCircleAnimator(core::vector3df(0,0,-25), 20.0f, 0.001f);
   sphere3->addAnimator(anim);
   
	while(device->run())
   {
      driver->beginScene(true, true, video::SColor(255,100,101,140));
  
		smgr->drawAll();

		driver->endScene();
   }
   device->drop();

   return 0;
}
tower
Posts: 1
Joined: Sat Dec 13, 2008 10:01 pm
Location: Sweden

Post by tower »

I came across this as well and I think I figured out what the problem is:
Using shininess = 0.0 is basically a nop. The engine seems to make no change to the specular material parameters if this is the case. That means that if you have one material with specular parameters set, these won't be changed when the material with shininess = 0 is processed. You should be able to work around the problem by setting shininess to some non zero value and set the specular color of the material to 0, 0, 0.

As far as I can tell from the code, this is a bug in at least the OpenGL driver.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, yes, you're right. I've improved some things for SVN/trunk. I hope it's not doing too many duplicate calls.
psychophoniac
Posts: 101
Joined: Wed Dec 03, 2008 5:33 pm
Location: ger

Post by psychophoniac »

i tried the burningsvideo driver, and the blue appears.
so it really belongs to the openGL driver.
i love skateboarding!
Post Reply