Hm, putting light directly into the camera is interesting - I'm not quite sure if that is a good idea. Really never tried.
But in theory you are not doing anything wrong. Vertex lighting simply isn't good and has lots of cases where you wonder if something is broken. Games using it use all kind of tricks to make it work. Like placing several lights. And adding a bit of ambient light to avoid the super dark places (and sometimes to give "mood" to a scene by coloring it somewhat). Also using more polygons will make vertex light use better - so 2 triangles for a flat area looks worse than more triangles (unlike pixel lighting where you want to reduce polygons as much as possible).
If you need better lighting there is no way around using pixel shaders Which calculate the light per pixel instead of calculating it per vertex and then average over the pixels. Irrlicht comes with some simple ones, like EMT_NORMAL_MAP_SOLID, but you need to convert your mesh to use EVT_TANGENTS vertex type. Unfortunately I've also not worked yet much with that one and trying to convert your example to use that gave strange results. Maybe the normalmap I created is not going straight up as I expect? Would have to invest a bit more time I fear, but currently already working on another bug and a bit short on time, so can't help more today (and next week probably even worse...). So, experiment!
Code: Select all
#include <irrlicht.h>
int main(int argc, char* argv[])
{
irr::IrrlichtDevice* dev = irr::createDevice(irr::video::EDT_OPENGL);
irr::scene::IAnimatedMesh* mesh = dev->getSceneManager()->getMesh("Test.dae");
// convert to mesh which can be used with build-in pixel shaders
irr::scene::IMesh* meshT = dev->getSceneManager()->getMeshManipulator()->createMeshWithTangents(mesh->getMesh(0));
irr::scene::IMeshSceneNode* node = dev->getSceneManager()->addMeshSceneNode(meshT);
node->setDebugDataVisible(irr::scene::EDS_NORMALS);
// Trying to create a dummy normalmap where all values just go up
irr::video::IImage* imgNormals = dev->getVideoDriver()->createImage(irr::video::ECF_A8R8G8B8, irr::core::dimension2du(2,2));
imgNormals->fill(irr::video::SColor(255,255,255,255));
irr::video::ITexture* normalMap = dev->getVideoDriver()->addTexture("normalMap", imgNormals);
imgNormals->drop();
node->getMaterial(0).setTexture(1, normalMap);
node->getMaterial(0).MaterialType = irr::video::EMT_NORMAL_MAP_SOLID;
irr::scene::ICameraSceneNode* cam = dev->getSceneManager()->addCameraSceneNodeFPS(nullptr, 100, 0.01f);
cam->setPosition(irr::core::vector3df(0, 1.75, 0));
// moved it a up a bit in case camera and light exact same pos is the problem - but that wasn't it
irr::scene::ILightSceneNode* light = dev->getSceneManager()->addLightSceneNode(cam, irr::core::vector3df(0,20,0), irr::video::SColorf(1,1,1), 150);
while (dev->run())
{
dev->getVideoDriver()->beginScene();
dev->getSceneManager()->drawAll();
dev->getVideoDriver()->endScene();
}
return 0;
}