DirectionalLight direction #5186
-
Can I get some advice on how the direction of the DirectionalLight is controlled using its entity's transform? Right now I'm just creating the light over an XY plane and some cubes, and starting it with the following transform:
I'm assuming the direction is calculated from some point with the rotation applied as the translation doesn't seem to do anything. I've tried animating the rotation to understand what's happening, but wasn't understanding why it was behaving that way. I'm assuming it has something to do with a hard-coded up-vector somewhere.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Directional light sources are modelled to be at infinity and have parallel rays. As such they do not have a position in practical terms and only the rotation matters. The direction of the light is defined by the forward direction and by default the -z axis is forwards (right-handed, y-up, z points backwards and -z is forwards). Rotations are then applied to a Vec3 of (0,0,-1) to calculate the transform’s forward direction. Shadows are more complicated and not so usable yet for directional lights but I am finishing off an automatic shadow implementation for directional lights right now. |
Beta Was this translation helpful? Give feedback.
Directional light sources are modelled to be at infinity and have parallel rays. As such they do not have a position in practical terms and only the rotation matters. The direction of the light is defined by the forward direction and by default the -z axis is forwards (right-handed, y-up, z points backwards and -z is forwards). Rotations are then applied to a Vec3 of (0,0,-1) to calculate the transform’s forward direction. Shadows are more complicated and not so usable yet for directional lights but I am finishing off an automatic shadow implementation for directional lights right now.