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?
$\begingroup$
$\endgroup$
0
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
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).