See without lights!
-
- Posts: 24
- Joined: Tue Jul 11, 2006 2:24 pm
- Contact:
See without lights!
Something has been bugging me, no matter what I do, I can't get my night/day lighting to work, then it struck me when I had the lights commented out: I can see everything clearly, things that should be black are not!
It's worth noting that I am using DeusXLs .NET port to do this, and that I might be missing something completely obvious...
It's worth noting that I am using DeusXLs .NET port to do this, and that I might be missing something completely obvious...
-
- Posts: 24
- Joined: Tue Jul 11, 2006 2:24 pm
- Contact:
-
- Posts: 24
- Joined: Tue Jul 11, 2006 2:24 pm
- Contact:
Normals are used for lighting calculations...
If you want to make the scene dark, turn down the ambient light. If you have lights in the scene, you may need to turn them down also. If you are still seeing light, maybe you should provide us some code for a simple testcase so we might have a chance of seeing what is wrong.
Travis
If you want to make the scene dark, turn down the ambient light. If you have lights in the scene, you may need to turn them down also. If you are still seeing light, maybe you should provide us some code for a simple testcase so we might have a chance of seeing what is wrong.
Travis
-
- Posts: 24
- Joined: Tue Jul 11, 2006 2:24 pm
- Contact:
Ok, I'll show you some of the code, its C#, but its not all of the code:
Code: Select all
// Add the SkyBox:
SkyBox = Engine.Scene.AddSkyBoxSceneNode(
null, new Texture[] {
Engine.Driver.GetTexture("Textures/Game/irrlicht2_up.jpg"),
Engine.Driver.GetTexture("Textures/Game/irrlicht2_dn.jpg"),
Engine.Driver.GetTexture("Textures/Game/irrlicht2_lf.jpg"),
Engine.Driver.GetTexture("Textures/Game/irrlicht2_rt.jpg"),
Engine.Driver.GetTexture("Textures/Game/irrlicht2_ft.jpg"),
Engine.Driver.GetTexture("Textures/Game/irrlicht2_bk.jpg")
}, -1
);
// Add a Terrain:
Terrain = Engine.Scene.AddTerrainSceneNode(
"Textures/Terrains/Island01.bmp", null, 1, new Vector3D(0, 0, 0),
new Vector3D(0, 0, 0), new Vector3D(64, 16, 64),
Color.Gray, 5, TerrainPatchSize.TPS17
);
Terrain.SetMaterialTexture(0, Engine.Driver.GetTexture("Textures/Surfaces/GrassA1024.png"));
Terrain.ScaleTexture(10f, 20.0f);
//Terrain.SetMaterialFlag(MaterialFlag.Lighting, true);
// Position Camera:
Camera.Position = new Vector3D(Terrain.Position.X + 128, Terrain.Position.Y + 128, Terrain.Position.Z + 128);
// Add some light:
/*SkyBoxLight = Engine.Scene.AddLightSceneNode(
SkyBox, new Vector3D(Terrain.Position.X + 1280, Terrain.Position.Y + 12800, Terrain.Position.Z + 1280),
new Colorf(255, 255, 192, 128), 8, 1
);*/
// Add a freaky short man:
AnimatedMeshSceneNode Dwarf = Engine.Scene.AddAnimatedMeshSceneNode(Engine.Scene.GetMesh("Models/Dwarf.x"));
Dwarf.AnimationSpeed = 25;
Dwarf.Position = new Vector3D(Terrain.Position.X + 256, Terrain.Position.Y + 128, Terrain.Position.Z + 256);
Dwarf.SetMaterialFlag(MaterialFlag.NormalizeNormals, true);
Dwarf.AddShadowVolumeSceneNode(-1, true, 10000f);
Dwarf.Scale = new Vector3D(1.5f, 1.5f, 1.5f);
// Collision:
TerrainTriangle = Engine.Scene.CreateTerrainTriangleSelector(Terrain, 0);
Camera.AddAnimator(Engine.Scene.CreateCollisionResponseAnimator(
TerrainTriangle, Camera, new Vector3D(30, 50, 30),
new Vector3D(0, -1, 0), new Vector3D(0, 50, 0), 0.0001f
));
Dwarf.AddAnimator(Engine.Scene.CreateCollisionResponseAnimator(
TerrainTriangle, Dwarf, new Vector3D(30, 0.01f, 30),
new Vector3D(0, -1, 0), new Vector3D(0, 30, 0), 0.0001f
));
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Don't make the skybox a parent for anything, it does not make sense. The skybox won't move and you can thus use the root scene node as a parent. This won't help with your problem, though.
Next thing is that you set the light quite far above your terrain, so it will probably not reach any object in your scene. A range of 8 is not really a useful light.
Then SColorf takes floats in the range [0, 1] while you're using ints in the range [0,255] which will obviously lead to pure white light all the time.
I cannot see where you create the plane. If that's your terrain scene node you should probably try to use a better heightmap
Also terrain has some problem with dynamic lighting and some drivers, I don't remember when or if it's fixed, but that might be a problem here. If you don't enable lighting for the nodes you won't get any effects anyway.
Ok, I think enough hints to proceed. Let's see if something changes and please also detail on your intended effects.
Next thing is that you set the light quite far above your terrain, so it will probably not reach any object in your scene. A range of 8 is not really a useful light.
Then SColorf takes floats in the range [0, 1] while you're using ints in the range [0,255] which will obviously lead to pure white light all the time.
I cannot see where you create the plane. If that's your terrain scene node you should probably try to use a better heightmap
Also terrain has some problem with dynamic lighting and some drivers, I don't remember when or if it's fixed, but that might be a problem here. If you don't enable lighting for the nodes you won't get any effects anyway.
Ok, I think enough hints to proceed. Let's see if something changes and please also detail on your intended effects.
-
- Posts: 24
- Joined: Tue Jul 11, 2006 2:24 pm
- Contact:
As for the SkyBox being parent, I was using SkyBox.Visible = false, so now I'm using Engine.Scene.RootSceneNode.Visible = false; Thanks
As for all the values, I'm having a lot of trouble finding ones that work, for example I want to have 0,0,0 represent the center of the terrain, but I can't even figure out how wide the terrain is and relate that to its positioning, the values are of a different scale or something...
I wasn't aware that Colorf could accept floats, when I tried to use them nothing happened. :/
Some problems, but I'm limited to OpenGL here:
As for all the values, I'm having a lot of trouble finding ones that work, for example I want to have 0,0,0 represent the center of the terrain, but I can't even figure out how wide the terrain is and relate that to its positioning, the values are of a different scale or something...
I wasn't aware that Colorf could accept floats, when I tried to use them nothing happened. :/
Some problems, but I'm limited to OpenGL here:
Try boiling it down to a simple testcase. 50 lines or so total should be enough to show the entire test program. Chances are likely that you are doing something wrong.provide us some code for a simple testcase
Make a backup of your source, then start chopping stuff out until the problem goes away. Once it goes away, put whatever you just removed back, and chop out anything else that doesn't affect it. Then you'll either know what is going on, or you'll have a simple testcase.