See without lights!

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Rowan Lewis
Posts: 24
Joined: Tue Jul 11, 2006 2:24 pm
Contact:

See without lights!

Post 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...
cadue
Posts: 72
Joined: Mon Mar 13, 2006 8:33 pm
Location: Italy - Friuli - Monfalcone - Staranzano

Post by cadue »

Sometime if there aren't lights in the scene Irrlicht atcives an own light....at least I think...
excuse me for my bad english and for my ignorance...but I'm 14 and i come from Italy, where the study of english is a optional (-:
Rowan Lewis
Posts: 24
Joined: Tue Jul 11, 2006 2:24 pm
Contact:

Post 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!
sRc
Posts: 431
Joined: Thu Jul 28, 2005 1:44 am
Location: Salt Lake City, Utah
Contact:

Post by sRc »

curious, which part are you wanting to be dark thats not going dark?
The Bard sRc

Blog | Twitter
cadue
Posts: 72
Joined: Mon Mar 13, 2006 8:33 pm
Location: Italy - Friuli - Monfalcone - Staranzano

Post 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...
excuse me for my bad english and for my ignorance...but I'm 14 and i come from Italy, where the study of english is a optional (-:
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Rowan Lewis
Posts: 24
Joined: Tue Jul 11, 2006 2:24 pm
Contact:

Post 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 :/
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
Rowan Lewis
Posts: 24
Joined: Tue Jul 11, 2006 2:24 pm
Contact:

Post 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
			));
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Rowan Lewis
Posts: 24
Joined: Tue Jul 11, 2006 2:24 pm
Contact:

Post 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
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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.
Post Reply