B3D lighting: can't seem to remove ambient lighting [SOLVED]
B3D lighting: can't seem to remove ambient lighting [SOLVED]
Hey All:
I'm going to post this on the DeleD forums too since I think the issues lies there but I figured I would throw this out here as well.
When I create a DeleD map (simple cube room), and export it to B3D, it always has lighting no matter what material settings I change (in Irrlicht or DeleD). I tried leaving out lightmaps in the export and no change. I tried using the DMF format and got some strange happenings but the light was still there.
I tried a crapload of material flags for the whole map but no change.
Any thoughts or ideas? Thanks.
I'm going to post this on the DeleD forums too since I think the issues lies there but I figured I would throw this out here as well.
When I create a DeleD map (simple cube room), and export it to B3D, it always has lighting no matter what material settings I change (in Irrlicht or DeleD). I tried leaving out lightmaps in the export and no change. I tried using the DMF format and got some strange happenings but the light was still there.
I tried a crapload of material flags for the whole map but no change.
Any thoughts or ideas? Thanks.
Last edited by Rytz on Fri Jun 20, 2008 2:40 am, edited 1 time in total.
-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Well, Irrlicht has a default setting of lighting enabled, so this does usually happen in all file formats. Moreover, the DMF loader explicitly uses LIGHTMAP_LIGHTING and enables the lighting just to be sure.
The b3d loader disables lighting only for full-bright setting, however it should also do so for the lightmaps, as it uses the standard lightmaps...
The b3d loader disables lighting only for full-bright setting, however it should also do so for the lightmaps, as it uses the standard lightmaps...
Thanks for the reply hybrid.hybrid wrote:Well, Irrlicht has a default setting of lighting enabled, so this does usually happen in all file formats. Moreover, the DMF loader explicitly uses LIGHTMAP_LIGHTING and enables the lighting just to be sure.
The b3d loader disables lighting only for full-bright setting, however it should also do so for the lightmaps, as it uses the standard lightmaps...
I did some more testing earlier today and the only format that I could get to work correctly from (DeleD) was ".X". I noticed some differences between OpenGL and DirectX with light settings (from what I've read it's the "Attentuation" in OpenGL) so that's going to take a bit of tweaking if I want to stay true to allowing for the use of different different device types.
The COLLADA loader in Irrlicht was skipping over all of the textures and lighting information (and a bunch of other scene information). I tried setting the attribute to load all of the COLLADA scene information but that didn't help.
My main goal here is to use map entity positioned for dynamic lighting in Irrlicht.
What is the full-proof way of stripping all of the default lighting information by use of Irrlicht? What Matiral Types / Flags should be used?
Thanks.
-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
You can always upload the meshes somewhere, or send them directly. Then we can test them and see if there are some material properties which could be better mapped to Irrlicht properties.
The collada loader from 1.4.x only supports Collada 1.3, which is usually not supported by many tools. Irrlicht 1.4 even skipped more things than 1.4.1. In Irrlicht 1.5 there will be Collada 1.4 support, with proper texturing and proper instancing of the models.
As said, meshes should automatically have dynamic lighting enabled. You should note that proper dynamic lighting requires correct normals in the mesh. If you scale the mesh you have to enable the renormalize normals flag, otherwise the lighting will be wrong. Also some tweaking of the lighting properties of a material might be required, although this shold be done by the loader - as long as the mesh format supports those flags, such as emissive light or speculars.
The attenuation is also an important thing. Due the the 'radius' parameter supported by Direct3D the OpenGL lights behave differently to those in d3d, you have to change attenuation to (0,1.f/radius,0) in order to get similar results. This leads to strange results in other situations, though, so it's not a general way, but needs to be customized based on the scene and the light. Maybe irrEdit supports attenuation already, in that case you could play around with the light settings to check for good values.
The collada loader from 1.4.x only supports Collada 1.3, which is usually not supported by many tools. Irrlicht 1.4 even skipped more things than 1.4.1. In Irrlicht 1.5 there will be Collada 1.4 support, with proper texturing and proper instancing of the models.
As said, meshes should automatically have dynamic lighting enabled. You should note that proper dynamic lighting requires correct normals in the mesh. If you scale the mesh you have to enable the renormalize normals flag, otherwise the lighting will be wrong. Also some tweaking of the lighting properties of a material might be required, although this shold be done by the loader - as long as the mesh format supports those flags, such as emissive light or speculars.
The attenuation is also an important thing. Due the the 'radius' parameter supported by Direct3D the OpenGL lights behave differently to those in d3d, you have to change attenuation to (0,1.f/radius,0) in order to get similar results. This leads to strange results in other situations, though, so it's not a general way, but needs to be customized based on the scene and the light. Maybe irrEdit supports attenuation already, in that case you could play around with the light settings to check for good values.
Thanks again for the reply Hybrid.hybrid wrote:You can always upload the meshes somewhere, or send them directly. Then we can test them and see if there are some material properties which could be better mapped to Irrlicht properties.
The collada loader from 1.4.x only supports Collada 1.3, which is usually not supported by many tools. Irrlicht 1.4 even skipped more things than 1.4.1. In Irrlicht 1.5 there will be Collada 1.4 support, with proper texturing and proper instancing of the models.
As said, meshes should automatically have dynamic lighting enabled. You should note that proper dynamic lighting requires correct normals in the mesh. If you scale the mesh you have to enable the renormalize normals flag, otherwise the lighting will be wrong. Also some tweaking of the lighting properties of a material might be required, although this shold be done by the loader - as long as the mesh format supports those flags, such as emissive light or speculars.
The attenuation is also an important thing. Due the the 'radius' parameter supported by Direct3D the OpenGL lights behave differently to those in d3d, you have to change attenuation to (0,1.f/radius,0) in order to get similar results. This leads to strange results in other situations, though, so it's not a general way, but needs to be customized based on the scene and the light. Maybe irrEdit supports attenuation already, in that case you could play around with the light settings to check for good values.
I've been doing a lot of testing with these different export types and options that DeleD has and none of them seem to work correctly (or the way I want them to work). I can get the "room.3ds" from the tutorial package to work fine and the light node to show up exactly the way it should be. It seems that DeleD is doing something different with all of its exports.
I'm going to try some other mapping / modeling programs and see if I can get them to export correctly. So far I've tried 3D World Studio and DeleD and had problems with both of them exporting meshes correctly.
I'll post again later today with some of the maps I was trying to get to work and the test program code I was using to test them with.
Thanks.
I updated the thread on DeleD's forum with some pics. Here's the link if anyone is interested:
http://www.delgine.com/forum/viewtopic. ... 5942#25942
http://www.delgine.com/forum/viewtopic. ... 5942#25942
-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Hmm, how should the screen look like? I cannot see any reasons why the image would ever look like the third one, or even nearly. Moreover, the b3d mesh should also be lit when loaded into Irrlicht, so I'm not sure why there's no dynamic lighting effect. But as said, an example would help. You can find my mail address on my webpage in case you cannot publicly upload the meshes.
The 3DS picture wasn't textured because it's forcefully textured by Irrlicht in the examples. I was just being dumb and lazy and didn't texture it for the screenshot but I updated the pic in that thread so if you look again you'll see what the room should look like. I'm just trying to do a simple dynamic lighting test before I make any larger / more involved maps.hybrid wrote:Hmm, how should the screen look like? I cannot see any reasons why the image would ever look like the third one, or even nearly. Moreover, the b3d mesh should also be lit when loaded into Irrlicht, so I'm not sure why there's no dynamic lighting effect. But as said, an example would help. You can find my mail address on my webpage in case you cannot publicly upload the meshes.
I meant to attach the source code and so my apologies for that. It was another late night :O.
Click [HERE] to download the map tester source code and mesh files.
Click [HERE] to download the DeleD project and mesh files.
[Source Code]
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
int main(){
char i;
// driver...
video::E_DRIVER_TYPE driverType;
printf("Please select the driver you want for this example:\n"\
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
" (d) Software Renderer\n (e) Burning's Software Renderer\n"\
" (f) NullDevice\n (otherKey) exit\n\n");
std::cin >> i;
switch(i){
case 'a': driverType = video::EDT_DIRECT3D9;break;
case 'b': driverType = video::EDT_DIRECT3D8;break;
case 'c': driverType = video::EDT_OPENGL; break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
case 'f': driverType = video::EDT_NULL; break;
default: return 1;
}
// create device and load mesh...
IrrlichtDevice *device = createDevice(driverType, core::dimension2d<s32>(640, 480), 16, false);
scene::IAnimatedMesh* meshRoom = device->getSceneManager()->getMesh("./simple01.b3d");
scene::ISceneNode* nodeRoom = device->getSceneManager()->addAnimatedMeshSceneNode(meshRoom);
nodeRoom->setPosition(core::vector3df(0, 0, 0));
nodeRoom->setMaterialFlag(video::EMF_LIGHTING, true);
//nodeRoom->setMaterialType(video::EMT_SOLID);
// light scene node...
scene::ILightSceneNode *nodeLight = device->getSceneManager()->addLightSceneNode(0, core::vector3df(0, 0, 0), video::SColorf(255.0f, 255.0f, 255.0f), 750);
nodeLight->getLightData().Type = video::ELT_POINT;
nodeLight->getLightData().Attenuation = core::vector3df(0.0f, 1.0f / 1.0f, 0.005f);
nodeLight->getLightData().DiffuseColor = video::SColorf(255.0f, 255.0f, 255.0f);
nodeLight->getLightData().AmbientColor = video::SColorf(0.0f, 0.0f, 0.0f);
nodeLight->getLightData().SpecularColor = video::SColorf(0.0f, 0.0f, 0.0f);
nodeLight->getLightData().CastShadows = true;
// light graphic / billboard...
scene::ISceneNode* nodeBill = device->getSceneManager()->addBillboardSceneNode(nodeLight, core::dimension2d<f32>(50, 50));
nodeBill->setMaterialFlag(video::EMF_LIGHTING, false);
nodeBill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
nodeBill->setMaterialTexture(0, device->getVideoDriver()->getTexture("./particlewhite.bmp"));
nodeBill = 0;
// animator...
scene::ISceneNodeAnimator* anim = device->getSceneManager()->createFlyCircleAnimator (core::vector3df(0, 50, 0), 100.0f);
nodeLight->addAnimator(anim);
anim->drop(); anim = 0;
// camera...
scene::ICameraSceneNode* camera = device->getSceneManager()->addCameraSceneNodeFPS();
camera->setPosition(core::vector3df(0, 0, 0));
// disable mouse cursor
device->getCursorControl()->setVisible(false);
while(device->run())
if (device->isWindowActive()){
device->getVideoDriver()->beginScene(true, true, 0);
device->getSceneManager()->drawAll();
device->getVideoDriver()->endScene();
}
// cleanup...
device->getSceneManager()->clear();
device->getSceneManager()->getMeshCache()->clear();
device->drop();
return 0;
}-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
As far as I could see from a first look at the meshes it is a problem with the normals of the mesh. Some of them are pointing outward, so the faces are not properly oriented. Some of the normals could be even (0,0,0), I wasn't sure why they were not shown at all. Please check in your 3d editing tool.
Thanks for the info and reply Hybrid.hybrid wrote:As far as I could see from a first look at the meshes it is a problem with the normals of the mesh. Some of them are pointing outward, so the faces are not properly oriented. Some of the normals could be even (0,0,0), I wasn't sure why they were not shown at all. Please check in your 3d editing tool.
If it is in fact a problem with the normals, is there a way I could fix it in Irrlicht if I can't fix it in DeleD? I'm still waiting on a response from the DeleD forums but I'll update it here when I do. I'll tool around with some of the settings a bit more in DeleD and see if I can get a fix.
Thanks again.
Nope, couldn't remove the "ambient" light from the B3D map when loaded. I tried setting the material colors directly and recalculating the normals.hybrid wrote:You could try to use the MeshManipulator, there's a method called recalculateNormals. Depends on the meshes if the output is ok for further use.
I was able to get the DirectX format working properly with DeleD so things are good (for now
Thanks again for your help and testing.
I put a link to a short video of the lighting with a DirectX map in the DeleD forums in the same thread link above.
