Page 1 of 1

See without lights!

Posted: Tue Jul 18, 2006 2:31 pm
by Rowan Lewis
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!

Image

It's worth noting that I am using DeusXLs .NET port to do this, and that I might be missing something completely obvious...

Posted: Tue Jul 18, 2006 3:50 pm
by cadue
Sometime if there aren't lights in the scene Irrlicht atcives an own light....at least I think...

Posted: Tue Jul 18, 2006 4:00 pm
by Rowan Lewis
Well, perhaps, except when there is a light, it barely makes any difference over the "glow" of the scene :/

So if thats the case then its not turning off!

Posted: Tue Jul 18, 2006 5:24 pm
by sRc
curious, which part are you wanting to be dark thats not going dark?

Posted: Tue Jul 18, 2006 5:34 pm
by cadue
Ah! I've understood! It's simple! has the plane only 4 vertexes? Try to make a plane whit a lot of faces...I belive that irrlicht use the vertexes for the light...

Posted: Tue Jul 18, 2006 8:20 pm
by hybrid
Maybe wrong normals? And if you don't have lighting enabled you will have the textures drawn just as the image defines the color, so it won't be dark at all.

Posted: Wed Jul 19, 2006 3:58 am
by Rowan Lewis
Lighting is enabled, but I need to be able to make the map completely dark, or close to it based on a timer.

Even when the plane has alot of faces, it still remains lit.

What do you mean by the wrong normals? I've not set a normal map :/

Posted: Wed Jul 19, 2006 4:15 am
by vitek
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

Posted: Wed Jul 19, 2006 8:07 am
by Rowan Lewis
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
			));

Posted: Wed Jul 19, 2006 8:38 am
by hybrid
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 :wink:
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.

Posted: Wed Jul 19, 2006 11:25 am
by Rowan Lewis
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:

Image

Posted: Wed Jul 19, 2006 3:19 pm
by vitek
provide us some code for a simple testcase
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.

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.