light position

Started by
2 comments, last by Zakwayda 13 years ago
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.
Advertisement
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.

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.


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 :

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);


but don't work.

but don't work.

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.)

This topic is closed to new replies.

Advertisement