Lights / Lighting Issues
by Rob Evans · in Torque X 2D · 05/15/2007 (5:34 am) · 7 replies
I'm trying to get a single light to work in my scene. The code I'm using is:
T2DSceneObject testLight = new T2DSceneObject();
LightRegisterComponent lightRegister = new LightRegisterComponent();
DirectionalLightInfo lightInfo = new DirectionalLightInfo();
lightInfo.AmbientColor = new Vector3(255.0f, 255.0f, 255.0f);
lightInfo.DiffuseColor = new Vector3(255.0f, 255.0f, 255.0f);
lightInfo.Direction = new Vector3(0.0f, 0.0f, 0.0f);
lightRegister.LightList.Add(lightInfo);
testLight.Components.AddComponent(lightRegister);
testLight.Visible = true;
testLight.Position = new Vector2(0.0f, 0.0f);
I've set my background material to translucency off and enableLighting true in my txtscene file as so:
BackgroundMaterial
DefaultEffect
data\images\palmtrees.png
true
false
I expected the light to light up an area of the background image but all I see is darkness...
I've checked other threads on this subject but can't see how I fix this problem.
Any suggestions?
T2DSceneObject testLight = new T2DSceneObject();
LightRegisterComponent lightRegister = new LightRegisterComponent();
DirectionalLightInfo lightInfo = new DirectionalLightInfo();
lightInfo.AmbientColor = new Vector3(255.0f, 255.0f, 255.0f);
lightInfo.DiffuseColor = new Vector3(255.0f, 255.0f, 255.0f);
lightInfo.Direction = new Vector3(0.0f, 0.0f, 0.0f);
lightRegister.LightList.Add(lightInfo);
testLight.Components.AddComponent(lightRegister);
testLight.Visible = true;
testLight.Position = new Vector2(0.0f, 0.0f);
I've set my background material to translucency off and enableLighting true in my txtscene file as so:
I expected the light to light up an area of the background image but all I see is darkness...
I've checked other threads on this subject but can't see how I fix this problem.
Any suggestions?
#2
05/16/2007 (6:57 am)
Opps, I posted the wrong material... the lighting on my object is set to true... still doesn't work...
#3
BackgroundMaterial2
DefaultEffect
data\images\ocean.png
false
true
05/16/2007 (8:23 am)
My material looks like this:
#4
05/16/2007 (9:39 am)
The light direction is {0.0f, 0.0f, 0.0f}, make sure to give the light a valid direction (as a unit/normalized vector).
#5
I'll describe what I'm doing. I've got a big background image on layer 10 and a number of other sprites at layer 1. I want a light to mount to my sprites to light up the background as the sprites move around.
Imagine a dark picture and glowing bugs flying around and the pic being illuminated as they fly.
How can I do that?
05/23/2007 (10:27 am)
What's a normalised vector? LOL.I'll describe what I'm doing. I've got a big background image on layer 10 and a number of other sprites at layer 1. I want a light to mount to my sprites to light up the background as the sprites move around.
Imagine a dark picture and glowing bugs flying around and the pic being illuminated as they fly.
How can I do that?
#6
If you want the light to point straight down from your sprites, try making one of the vector's components 1 or -1. Experiment with Z. Not sure, but give it a shot.
05/23/2007 (4:56 pm)
A normalized vector is a vector whose length is one unit.If you want the light to point straight down from your sprites, try making one of the vector's components 1 or -1. Experiment with Z. Not sure, but give it a shot.
#7
05/24/2007 (4:53 am)
Thanks for that, I'll give it a try and post my results...
Torque 3D Owner Harrison Brock