Game Development Community

Sun doesn't work with a LightComponent attached.

by Trent · in Torque X 3D · 01/08/2010 (5:07 am) · 5 replies

I got a sun working then I read the class docs that say it will use the direction of a light component if there is one, so I attached a light component, and the sun disappeared, and there was no lighting either.

#1
01/08/2010 (9:40 am)
Where do you define your sun, in code or XML?
The default 3D template of Torque X has the following definition in levelData.txscene:
<Sun type="GarageGames.Torque.T3D.Sun" name="Sun">
      <Material1 nameRef="SunMaterial1" />
      <Material2 nameRef="SunMaterial2" />
      <Components inPlace="true">
        <SceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent" />
        <LightComponent type="GarageGames.Torque.Lighting.T3DLightComponent">
          <LightList>
            <Light type="GarageGames.Torque.Lighting.DirectionalLight" name="SunLight">
              <DiffuseColor>
                <X>0.9</X>
                <Y>0.9</Y>
                <Z>0.63</Z>
              </DiffuseColor>
              <AmbientColor>
                <X>0.2</X>
                <Y>0.3</Y>
                <Z>0.45</Z>
              </AmbientColor>
              <Direction>
                <X>-0.1</X>
                <Y>0.8191521</Y>
                <Z>-0.5735765</Z>
              </Direction>
              <ConstantAttenuation>1.0</ConstantAttenuation>
            </Light>
          </LightList>
        </LightComponent>
      </Components>
    </Sun>

There's a sun and a light component. In my level I can see the sun and there is light, so that seems to work.

Maybe the same thing written in C# doesn't work? I've just recently read a post where this was allegedly the case. (Not specifically for lighting)
#2
01/08/2010 (8:44 pm)
I don't use XML at all. I went and read John's book and he's doing exactly what I was doing in code, so I'm not sure why it's not working.
#3
01/09/2010 (11:04 pm)
Coming from ignorance: could it be that the Sun does not have any ambient lighting, so that the directional lighting exactly away from it leaves it unilluminated?
#4
06/18/2010 (3:07 pm)
Refresh your scene (I've previously had to unload and reload the level at times.)

But also keep in mind the direction of the light. The sun renders based on the actual direction of the directional light not just on the instance of one.
#5
06/23/2010 (5:43 pm)
For those confused with the OP, just because you have a light component attached to your sun, does not mean there's any light on it. Make sure that your lightslist is populated with (in this case) a directional light.

I believe I explained that correct...I'm terrible at explaining things. I'm used to pointing at the screen and saying "That thingy!" :]