• ### What is your GameDev Story?

#### Archived

This topic is now archived and is closed to further replies.

# Strange lights

This topic is 5340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Does anyone have a good tutorial for setting lights in a scene? I''m struggling with the position and direction of my lights. I''d like them to always be positioned directly looking into the scene. I can''t seem to get them to stay in that position. The lights seem to change as I move scene primitives. Gort...Klaatu, Barada Nikto!

##### Share on other sites
are the lights moving or is it just that your objects are moving and their normals are causing them to reflict light due to the angle differently now?

If you always want them positioned into the scene cant you just make them parallel with the camera then(the look at vector)?

##### Share on other sites
Are you doing all you math correctly? Run through the code and make sure you aren''t accidentally moving your lights somehow.

Also, what kind of lights are you using? Spot, directional, point? One, some, or all?

I am not too experienced with DX but I think I could help.

Notes on lighting positioning:
Point light:
When setting the position and direction, the direction is meaningless since they shine in all directions. The position is a vector describing the position in world coordinates.
Directional light:
When setting the position and direction, the position is meaningless. Say the sun is being represented by a directional light. In your 3D world, if it were in the +x, +y, -z space and were shining at the origin of the world, the direction of the light would be [-1, -1, +1]. I hope that makes sense.
Spot light:
Think of it as a flashlight. The flashlight has a position (the position) and a direction the light is shining (the direction).

I hope that helps with your struggles with position and direction.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 31
• 16
• 11
• 10
• 12
• ### Forum Statistics

• Total Topics
634117
• Total Posts
3015601
×