1
$\begingroup$

in the vertex shader I have the vertex position vpos which is in object space and I want to get the vector going from the camera to vpos. Can I just do vpos - cameraPos or do I need to do some matrix multiplication with the model-view inverse because vPos and cameraPos are not in the same space?

$\endgroup$
0

1 Answer 1

2
$\begingroup$

Operations between two vectors do not make sense unless both vectors are in the same space. So you must either transform the camera position into object space or transform the object position into camera space. I would suggest the latter, since you already likely have a matrix lying around for doing that for other reasons (lighting, etc).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.