General Formula for Perspective Projection Matrix
up vote
0
down vote
favorite
Can anyone please tell me what is the general formula to implement the Perspective Projection Matrix? I'm trying to implement a way to generate this matrix in order to use it for a game engine I'm working on.
math matrix graphics projection perspective
add a comment |
up vote
0
down vote
favorite
Can anyone please tell me what is the general formula to implement the Perspective Projection Matrix? I'm trying to implement a way to generate this matrix in order to use it for a game engine I'm working on.
math matrix graphics projection perspective
there are more than one type of perspective matrix out there ... I am used to this one depth buffer got by glReadPixels is always 1 look forglPerspective
– Spektre
Nov 11 at 5:04
@Spektre I gave it a look but I'm still having a hard time figuring things out. But clarify this to me, a Perspective Projection Matrix isn't the product between a perspective matrix and a projection matrix? Or there's something else to it?
– Pmsmm
Nov 12 at 1:24
1
Yes you're right but the projection matrix to which you are multiplying the perspective matrix is usually unit matrix unless you want to simulate some special behavior. My matrix just preserve aspect ratio and re-map the z to logarithmic values (likegluPerspective
would do)
– Spektre
Nov 12 at 7:18
I think I'm getting it, I'll try to do some further research but thanks for the help.
– Pmsmm
Nov 12 at 19:56
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Can anyone please tell me what is the general formula to implement the Perspective Projection Matrix? I'm trying to implement a way to generate this matrix in order to use it for a game engine I'm working on.
math matrix graphics projection perspective
Can anyone please tell me what is the general formula to implement the Perspective Projection Matrix? I'm trying to implement a way to generate this matrix in order to use it for a game engine I'm working on.
math matrix graphics projection perspective
math matrix graphics projection perspective
asked Nov 11 at 3:37
Pmsmm
248
248
there are more than one type of perspective matrix out there ... I am used to this one depth buffer got by glReadPixels is always 1 look forglPerspective
– Spektre
Nov 11 at 5:04
@Spektre I gave it a look but I'm still having a hard time figuring things out. But clarify this to me, a Perspective Projection Matrix isn't the product between a perspective matrix and a projection matrix? Or there's something else to it?
– Pmsmm
Nov 12 at 1:24
1
Yes you're right but the projection matrix to which you are multiplying the perspective matrix is usually unit matrix unless you want to simulate some special behavior. My matrix just preserve aspect ratio and re-map the z to logarithmic values (likegluPerspective
would do)
– Spektre
Nov 12 at 7:18
I think I'm getting it, I'll try to do some further research but thanks for the help.
– Pmsmm
Nov 12 at 19:56
add a comment |
there are more than one type of perspective matrix out there ... I am used to this one depth buffer got by glReadPixels is always 1 look forglPerspective
– Spektre
Nov 11 at 5:04
@Spektre I gave it a look but I'm still having a hard time figuring things out. But clarify this to me, a Perspective Projection Matrix isn't the product between a perspective matrix and a projection matrix? Or there's something else to it?
– Pmsmm
Nov 12 at 1:24
1
Yes you're right but the projection matrix to which you are multiplying the perspective matrix is usually unit matrix unless you want to simulate some special behavior. My matrix just preserve aspect ratio and re-map the z to logarithmic values (likegluPerspective
would do)
– Spektre
Nov 12 at 7:18
I think I'm getting it, I'll try to do some further research but thanks for the help.
– Pmsmm
Nov 12 at 19:56
there are more than one type of perspective matrix out there ... I am used to this one depth buffer got by glReadPixels is always 1 look for
glPerspective
– Spektre
Nov 11 at 5:04
there are more than one type of perspective matrix out there ... I am used to this one depth buffer got by glReadPixels is always 1 look for
glPerspective
– Spektre
Nov 11 at 5:04
@Spektre I gave it a look but I'm still having a hard time figuring things out. But clarify this to me, a Perspective Projection Matrix isn't the product between a perspective matrix and a projection matrix? Or there's something else to it?
– Pmsmm
Nov 12 at 1:24
@Spektre I gave it a look but I'm still having a hard time figuring things out. But clarify this to me, a Perspective Projection Matrix isn't the product between a perspective matrix and a projection matrix? Or there's something else to it?
– Pmsmm
Nov 12 at 1:24
1
1
Yes you're right but the projection matrix to which you are multiplying the perspective matrix is usually unit matrix unless you want to simulate some special behavior. My matrix just preserve aspect ratio and re-map the z to logarithmic values (like
gluPerspective
would do)– Spektre
Nov 12 at 7:18
Yes you're right but the projection matrix to which you are multiplying the perspective matrix is usually unit matrix unless you want to simulate some special behavior. My matrix just preserve aspect ratio and re-map the z to logarithmic values (like
gluPerspective
would do)– Spektre
Nov 12 at 7:18
I think I'm getting it, I'll try to do some further research but thanks for the help.
– Pmsmm
Nov 12 at 19:56
I think I'm getting it, I'll try to do some further research but thanks for the help.
– Pmsmm
Nov 12 at 19:56
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Ok so basically with some help from @spektre and a friend of mine I was able to figure out how to really do this. Pretty much the formula I used was this:
So pretty much what you need to make this matrix is a function that receives 4 arguments which are the following:
- zFar
- zNear
- Aspect Ratio
- Field of View
If you want to know more about these fields and the matrix itself my advice is to head over to WebGL 3D Perspective to actually see this working.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245632%2fgeneral-formula-for-perspective-projection-matrix%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Ok so basically with some help from @spektre and a friend of mine I was able to figure out how to really do this. Pretty much the formula I used was this:
So pretty much what you need to make this matrix is a function that receives 4 arguments which are the following:
- zFar
- zNear
- Aspect Ratio
- Field of View
If you want to know more about these fields and the matrix itself my advice is to head over to WebGL 3D Perspective to actually see this working.
add a comment |
up vote
0
down vote
Ok so basically with some help from @spektre and a friend of mine I was able to figure out how to really do this. Pretty much the formula I used was this:
So pretty much what you need to make this matrix is a function that receives 4 arguments which are the following:
- zFar
- zNear
- Aspect Ratio
- Field of View
If you want to know more about these fields and the matrix itself my advice is to head over to WebGL 3D Perspective to actually see this working.
add a comment |
up vote
0
down vote
up vote
0
down vote
Ok so basically with some help from @spektre and a friend of mine I was able to figure out how to really do this. Pretty much the formula I used was this:
So pretty much what you need to make this matrix is a function that receives 4 arguments which are the following:
- zFar
- zNear
- Aspect Ratio
- Field of View
If you want to know more about these fields and the matrix itself my advice is to head over to WebGL 3D Perspective to actually see this working.
Ok so basically with some help from @spektre and a friend of mine I was able to figure out how to really do this. Pretty much the formula I used was this:
So pretty much what you need to make this matrix is a function that receives 4 arguments which are the following:
- zFar
- zNear
- Aspect Ratio
- Field of View
If you want to know more about these fields and the matrix itself my advice is to head over to WebGL 3D Perspective to actually see this working.
answered Nov 18 at 22:39
Pmsmm
248
248
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245632%2fgeneral-formula-for-perspective-projection-matrix%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
there are more than one type of perspective matrix out there ... I am used to this one depth buffer got by glReadPixels is always 1 look for
glPerspective
– Spektre
Nov 11 at 5:04
@Spektre I gave it a look but I'm still having a hard time figuring things out. But clarify this to me, a Perspective Projection Matrix isn't the product between a perspective matrix and a projection matrix? Or there's something else to it?
– Pmsmm
Nov 12 at 1:24
1
Yes you're right but the projection matrix to which you are multiplying the perspective matrix is usually unit matrix unless you want to simulate some special behavior. My matrix just preserve aspect ratio and re-map the z to logarithmic values (like
gluPerspective
would do)– Spektre
Nov 12 at 7:18
I think I'm getting it, I'll try to do some further research but thanks for the help.
– Pmsmm
Nov 12 at 19:56