Sign in to follow this  
giugio

light position

Recommended Posts

giugio    246
hello.
I wish place a light always at 45°(for example , but the angle can change ) at left of the camera and at 1/2 of the camera dinstance .
The light must follow the camera if i move it.
How i can calculate frame for frame the light position?
I must use dot product?
thanks.

Share this post


Link to post
Share on other sites
jyk    2094
It sounds like you just need a (local) transform for the light, and to concatenate that transform with the camera object's transform each update (which will keep the light in the same configuration with respect to the camera as the camera moves).

I might be misunderstanding the question though.

Share this post


Link to post
Share on other sites
giugio    246
[quote name='jyk' timestamp='1302362873' post='4796370']
It sounds like you just need a (local) transform for the light, and to concatenate that transform with the camera object's transform each update (which will keep the light in the same configuration with respect to the camera as the camera moves).

I might be misunderstanding the question though.
[/quote]

thanks , you have understand.
My problem is that i wish find the position of light(at 45 degree...) in an hlsl shader.
In the shader i have the position of the camera, and i wish find the position of the light .

I try this :
[code]
float angle = radians(45.0);
float x = CameraModelPosition.x * cos(angle) - CameraModelPosition.y * sin(angle);
float y = CameraModelPosition.x * sin(angle) + CameraModelPosition.y * cos(angle);
float3 Light0ModelDirection = float3(x, y, CameraModelPosition.z);
[/code]

but don't work.

Share this post


Link to post
Share on other sites
jyk    2094
[quote name='giugio' timestamp='1302363461' post='4796377']
but don't work.
[/quote]
Yeah, I wouldn't expect that to work; it looks like you're just rotating the camera position by 45 degrees, which won't keep the light position constant with respect to the camera as the camera moves.

I think concatenating the transforms is what you're looking for. I can't give you the HLSL-specific details off the top of my head, but it should reduce to either a matrix multiplication or two, or some simple vector math. (Maybe someone else will be able to provide an HLSL example.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this