worldShadowLight and setLightPos
-
Hey all, Anyone had much practice with these functions?
I'm attempting to setup a scene in 3D but can't seem to grasp how worldShadowLight works for centre and direction
Have played with both vectors but this seems to behave differently to something like setCamera's location and target (which i was hoping for with wSL)
Wanting to have the light go over a 3D scene slowly and adjust the lighting shadows with a simple objWorldLight.x += 0.1 on each cycle
Thanks!
-
@Tratax I struggled too, in "Da Bean" project. Somehow it felt like cam center and cam direction behaves in the opposite way of what I was expecting. But I did not had the patience to think it through, so I found the values by experimenting: just changed one of them. What I can probly say is that one of your parameters has to stay. ...ok thats probably what you already found out.
-
-
The
worldShadowLight()
parameters are a little tricky for sure. The first thing to bear in mind is that a world light doesn't have a position, it's a light which generally affects the entire world space.First, direction (since it's not contingent on shadows) - the vector here becomes normalized automatically - so it's the ratios between the 3 dimensions which is the important thing. It would make no difference to the effect if the suplied vector was
{0, -3, 4}
or{0, -0.3, 0.4}
. At{0, -1, 1}
the light is "pointing" just as much down as it is backward (toward the camera, assuming your camera is at{0, 0, 0}
).Centre and range are to do with shadow processing. The centre parameter is the point in world space from which the range parameter is applied. So at
{0, 0, 0}
with a range of10
, shadows will be processed within ten units from the centre point in all directions.The other parameters I don't think you'll have trouble with, colour, brightness and shadow resolution are fairly self explanatory. However, when choosing a resolution for shadows, stick to a power of 2 for optimal memory usage - however this is rather a negligible effect.
I hope this helps even slightly!
-
@Dave Thanks mate, that's perfect.. I'll have another try at it with this feedback!
-
Thank you @Dave , this was very helpful. I drew what you said. Example:
worldShadowLight({7, 0, 4}, {6, -4, 0}, white, 1, 2, 4096 )
(The light direction could also be set to{0.83, -0.55, 0}
as mentioned above)
)