projection matrix multiplication help

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
genesys
Posts: 75
Joined: Tue Nov 02, 2004 6:49 pm
Contact:

projection matrix multiplication help

Post by genesys »

Hi!

i've got a problem with matrix multiplication :) i hope you can help me...

i want to multiply my projectionmatrix with another matrix, so that the renderoutput always stretches with the windowsize! means that a square object, that fills out the whole window when the window has the same hight and width, then the object shall get stretched when i resize the viewport so that it always fills out the whole window (all objects shall be stretched that way) . . .

to achieve that i think i have to multiply the projectionmatrix with another matrix which is somehow dependant from screenhight/screenwidth . . .


can someone help me with that? thx!
Phenix
Posts: 51
Joined: Sat Nov 15, 2003 3:15 pm
Location: Earth
Contact:

Post by Phenix »

I think that the window size in pixels does not change the projection of geometry.
I mean, if you create a quad that fills the whole screen, you can change the resolution as you like, and it will still fill the whole screen anyway, if you don't change the FOV and the aspect ratio.
I am not sure about that, but you should test it.
If I want to create a screen-aligned quad I set position and rotation of the camera to (0,0,0), I get the four corners of view frustrum, divide them by 2 to make sure that the corners are in front of the far plane, I create a quad-mesh with that vertices, and finally I add that mesh as child of the camera.
Not very elegant but it works.
genesys
Posts: 75
Joined: Tue Nov 02, 2004 6:49 pm
Contact:

Post by genesys »

no - if it would stretch that way i wouldn't ask here for a solution to do so :)



the proportions of the rendered objects are independand from the window size! if you make your window broader, then you just see more things on the sides (and NOT the same things as before just broader . . .)
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

maybe this is what you're looking for
http://www.irrforge.org/index.php/Resiz ... pect_ratio
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Phenix
Posts: 51
Joined: Sat Nov 15, 2003 3:15 pm
Location: Earth
Contact:

Post by Phenix »

You are right!
In my tests it is exactly the same to set 640x480 or 800x600, exactly the same objects are displayed, I display a 3d hud so it's important that things work like this.
And when I tried to change the ratio of resolution it looked like the objects were stretched. But I tried to set the screen res to 320x200 and actually I can se more things :?
Sorry for the wrong information :)
genesys
Posts: 75
Joined: Tue Nov 02, 2004 6:49 pm
Contact:

Post by genesys »

never mind :)

i figured out how i can solve my problem... i just multiply the viewprojection matrix with this matrix

A = [screenx/screeny,0;0,1]

(it's working in rendermonkey that way - in irrlicht i must use [1,0;0,screenx/screeny] - i think that's because the multiplication of the view and the projectionmatrix i s in another order than in other 3D engines...)
Post Reply