Jump to content
  • Advertisement
Sign in to follow this  
giugio

light position

This topic is 2685 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!