PDA

View Full Version : Matrix questions.



Sanctus
05-30-2009, 03:37 AM
Hey guys.
I have some questions that I coudn't find on the internet(maybe I wasn't searching for the right thing).

So I'm trying to implement the deferred lighting tehnique.
I have my buffers drawn well enough.
When I draw the lighting pass I need to have the light position in the view matrix. Note that the view changes from the perspective one to the orthogonal one in order to draw the albedo buffer.

Anyway to get to the point I want to calculate the viewMatrix. Is that by any chance the projection matrix multiplied with the modelviewmatrix?

I'll have to send the old viewmatrix to the shader in order to get the light position in the viewmatrix.


Next in order is something about viewplanes and frustum.
I have the frustum as this "float frustum[6][4]". The function I used to calculate it is not written by me and thus I'm not sure which are the near and far planes (vector4).
Aparently I need that too in order to get things right.

Ilian Dinev
05-30-2009, 01:47 PM
frustum and field-of-view go into projection-matrix
camera position and rotation go into view-matrix
object's position goes into model-matrix.

Right after you finish doing transformations for the camera, - you have the view-matrix. Appending more transformations to it makes that matrix the "model-view matrix".
If you're using the glTranslatef/glRotatef/etc, then you should retrieve that view-matrix by glGetFloatv(GL_MODELVIEW_MATRIX,..) right before concatenating models' transformations.

(view = camera = eye) .