Page 1 of 1

Problems with sun position tool (vector math help)

Posted: Thu Sep 10, 2009 7:00 am
by Whaat
So I am writing a tool to position the sun in SkIndigo but I ran into a problem. I assumed that the <sundir> vector from the camera position to the sun was the same as the vector from the scene origin [0,0,0] to the sun. Apparently this is not the case.

This tells me that the position of the sun in Indigo is actually some fixed distance from the scene origin. So my question is this:

Given:
- Vector from camera to sun (direction only, not length)
- Vector from scene origin to camera (direction and length)

Determine:
- Vector from scene origin to sun (length not required)

This is probably very easy but I am a bit rusty on my 3D math... :)
Thanks!

Re: Problems with sun position tool (vector math help)

Posted: Thu Sep 10, 2009 9:37 am
by OnoSendai
Well, sundir in Indigo is actually the vector from the origin to the sun. It's just that the sun is actually a finite distance away (the sky model is just a sphere around the scene).

Re: Problems with sun position tool (vector math help)

Posted: Thu Sep 10, 2009 12:15 pm
by Whaat
OnoSendai wrote:Well, sundir in Indigo is actually the vector from the origin to the sun. It's just that the sun is actually a finite distance away (the sky model is just a sphere around the scene).
Could you please share the distance to the sun from the origin? :)

Re: Problems with sun position tool (vector math help)

Posted: Thu Sep 10, 2009 1:33 pm
by OnoSendai
It's basically 10x max radius of scene.