Projecting Orthographic Matrix Through A Perspective Camera
up vote
1
down vote
favorite
I need to render a mesh in screenspace, essentially like Unity's IMGUI. I say a mesh specifically as it is a constructed mesh of many UI tris, so I am not looking to use GL quads/tris, for example.
To avoid two cameras, I need to take the scene perspective camera, and draw that mesh with an orthographic projection so that it is drawn ortho to the screen. I've tried overriding Camera::projectionMatrix, with no success, along with GL::Push/PopMatrix and GL::LoadProjectionMatrix calls.
Is there a way to draw a single mesh (i.e. Graphics::DrawMeshNow, or a related call) with an orthographic projection matrix, using a perspective camera (or a way to force the camera into ortho just for rendering that one object)?
unity3d matrix graphics projection-matrix
add a comment |
up vote
1
down vote
favorite
I need to render a mesh in screenspace, essentially like Unity's IMGUI. I say a mesh specifically as it is a constructed mesh of many UI tris, so I am not looking to use GL quads/tris, for example.
To avoid two cameras, I need to take the scene perspective camera, and draw that mesh with an orthographic projection so that it is drawn ortho to the screen. I've tried overriding Camera::projectionMatrix, with no success, along with GL::Push/PopMatrix and GL::LoadProjectionMatrix calls.
Is there a way to draw a single mesh (i.e. Graphics::DrawMeshNow, or a related call) with an orthographic projection matrix, using a perspective camera (or a way to force the camera into ortho just for rendering that one object)?
unity3d matrix graphics projection-matrix
And a second camera is bad....why?
– Draco18s
Nov 8 at 0:53
Iam not sure what exactly you are trying to do here. Are you trying to render mesh in screenspace camera? or screenspace overlay? Secondly why your projection override not working? The projection matrix change works and have no issue. And as Draco18s said why not use second camera? Can you add more info on what you are trying to do? Add screenshot of heirarchy so we can also know what you have done. answers.unity.com/questions/876698/… And lastly are you trying to achive the one mentioned in thread?
– killer_mech
Nov 8 at 4:23
@killer_mech there is no hierarchy here, I am building a retained mode UI system and want to render the result with the scene camera. I'm a systems engineer and my 3D spatial math is certainly lacking, so I'm sure it's just an issue on that side, and I wanted to see if anyone suggested a matrix approach. Anyhow, I'm using an internal camera in the meantime which simply renders the thing in ortho and then bleeds to the main camera, which doesn't really have much impact, but naturally if it's possible to project it through the same camera I'd rather take the lighter approach.
– Anon
Nov 8 at 13:01
Have you tried using orthographic projection matrix?Camera.main.projectionMatrix = Matrix4x4.Ortho(-1, 1, -1, 1, 1, 10);
. The six values are of frustum planes namely up,down,left, right, near & far. But this will turn entire camera in orthographic mode. If you want to put part of camera in orthographic mode & rest render perspective mode then i believe only way is using two cameras. I have not seen anywhere the projection can be skewed small region of camera. If you have come across such example do share here. Though I doubt its at all possible as camera accepts only one matrix.
– killer_mech
Nov 9 at 8:32
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I need to render a mesh in screenspace, essentially like Unity's IMGUI. I say a mesh specifically as it is a constructed mesh of many UI tris, so I am not looking to use GL quads/tris, for example.
To avoid two cameras, I need to take the scene perspective camera, and draw that mesh with an orthographic projection so that it is drawn ortho to the screen. I've tried overriding Camera::projectionMatrix, with no success, along with GL::Push/PopMatrix and GL::LoadProjectionMatrix calls.
Is there a way to draw a single mesh (i.e. Graphics::DrawMeshNow, or a related call) with an orthographic projection matrix, using a perspective camera (or a way to force the camera into ortho just for rendering that one object)?
unity3d matrix graphics projection-matrix
I need to render a mesh in screenspace, essentially like Unity's IMGUI. I say a mesh specifically as it is a constructed mesh of many UI tris, so I am not looking to use GL quads/tris, for example.
To avoid two cameras, I need to take the scene perspective camera, and draw that mesh with an orthographic projection so that it is drawn ortho to the screen. I've tried overriding Camera::projectionMatrix, with no success, along with GL::Push/PopMatrix and GL::LoadProjectionMatrix calls.
Is there a way to draw a single mesh (i.e. Graphics::DrawMeshNow, or a related call) with an orthographic projection matrix, using a perspective camera (or a way to force the camera into ortho just for rendering that one object)?
unity3d matrix graphics projection-matrix
unity3d matrix graphics projection-matrix
asked Nov 7 at 20:46
Anon
61
61
And a second camera is bad....why?
– Draco18s
Nov 8 at 0:53
Iam not sure what exactly you are trying to do here. Are you trying to render mesh in screenspace camera? or screenspace overlay? Secondly why your projection override not working? The projection matrix change works and have no issue. And as Draco18s said why not use second camera? Can you add more info on what you are trying to do? Add screenshot of heirarchy so we can also know what you have done. answers.unity.com/questions/876698/… And lastly are you trying to achive the one mentioned in thread?
– killer_mech
Nov 8 at 4:23
@killer_mech there is no hierarchy here, I am building a retained mode UI system and want to render the result with the scene camera. I'm a systems engineer and my 3D spatial math is certainly lacking, so I'm sure it's just an issue on that side, and I wanted to see if anyone suggested a matrix approach. Anyhow, I'm using an internal camera in the meantime which simply renders the thing in ortho and then bleeds to the main camera, which doesn't really have much impact, but naturally if it's possible to project it through the same camera I'd rather take the lighter approach.
– Anon
Nov 8 at 13:01
Have you tried using orthographic projection matrix?Camera.main.projectionMatrix = Matrix4x4.Ortho(-1, 1, -1, 1, 1, 10);
. The six values are of frustum planes namely up,down,left, right, near & far. But this will turn entire camera in orthographic mode. If you want to put part of camera in orthographic mode & rest render perspective mode then i believe only way is using two cameras. I have not seen anywhere the projection can be skewed small region of camera. If you have come across such example do share here. Though I doubt its at all possible as camera accepts only one matrix.
– killer_mech
Nov 9 at 8:32
add a comment |
And a second camera is bad....why?
– Draco18s
Nov 8 at 0:53
Iam not sure what exactly you are trying to do here. Are you trying to render mesh in screenspace camera? or screenspace overlay? Secondly why your projection override not working? The projection matrix change works and have no issue. And as Draco18s said why not use second camera? Can you add more info on what you are trying to do? Add screenshot of heirarchy so we can also know what you have done. answers.unity.com/questions/876698/… And lastly are you trying to achive the one mentioned in thread?
– killer_mech
Nov 8 at 4:23
@killer_mech there is no hierarchy here, I am building a retained mode UI system and want to render the result with the scene camera. I'm a systems engineer and my 3D spatial math is certainly lacking, so I'm sure it's just an issue on that side, and I wanted to see if anyone suggested a matrix approach. Anyhow, I'm using an internal camera in the meantime which simply renders the thing in ortho and then bleeds to the main camera, which doesn't really have much impact, but naturally if it's possible to project it through the same camera I'd rather take the lighter approach.
– Anon
Nov 8 at 13:01
Have you tried using orthographic projection matrix?Camera.main.projectionMatrix = Matrix4x4.Ortho(-1, 1, -1, 1, 1, 10);
. The six values are of frustum planes namely up,down,left, right, near & far. But this will turn entire camera in orthographic mode. If you want to put part of camera in orthographic mode & rest render perspective mode then i believe only way is using two cameras. I have not seen anywhere the projection can be skewed small region of camera. If you have come across such example do share here. Though I doubt its at all possible as camera accepts only one matrix.
– killer_mech
Nov 9 at 8:32
And a second camera is bad....why?
– Draco18s
Nov 8 at 0:53
And a second camera is bad....why?
– Draco18s
Nov 8 at 0:53
Iam not sure what exactly you are trying to do here. Are you trying to render mesh in screenspace camera? or screenspace overlay? Secondly why your projection override not working? The projection matrix change works and have no issue. And as Draco18s said why not use second camera? Can you add more info on what you are trying to do? Add screenshot of heirarchy so we can also know what you have done. answers.unity.com/questions/876698/… And lastly are you trying to achive the one mentioned in thread?
– killer_mech
Nov 8 at 4:23
Iam not sure what exactly you are trying to do here. Are you trying to render mesh in screenspace camera? or screenspace overlay? Secondly why your projection override not working? The projection matrix change works and have no issue. And as Draco18s said why not use second camera? Can you add more info on what you are trying to do? Add screenshot of heirarchy so we can also know what you have done. answers.unity.com/questions/876698/… And lastly are you trying to achive the one mentioned in thread?
– killer_mech
Nov 8 at 4:23
@killer_mech there is no hierarchy here, I am building a retained mode UI system and want to render the result with the scene camera. I'm a systems engineer and my 3D spatial math is certainly lacking, so I'm sure it's just an issue on that side, and I wanted to see if anyone suggested a matrix approach. Anyhow, I'm using an internal camera in the meantime which simply renders the thing in ortho and then bleeds to the main camera, which doesn't really have much impact, but naturally if it's possible to project it through the same camera I'd rather take the lighter approach.
– Anon
Nov 8 at 13:01
@killer_mech there is no hierarchy here, I am building a retained mode UI system and want to render the result with the scene camera. I'm a systems engineer and my 3D spatial math is certainly lacking, so I'm sure it's just an issue on that side, and I wanted to see if anyone suggested a matrix approach. Anyhow, I'm using an internal camera in the meantime which simply renders the thing in ortho and then bleeds to the main camera, which doesn't really have much impact, but naturally if it's possible to project it through the same camera I'd rather take the lighter approach.
– Anon
Nov 8 at 13:01
Have you tried using orthographic projection matrix?
Camera.main.projectionMatrix = Matrix4x4.Ortho(-1, 1, -1, 1, 1, 10);
. The six values are of frustum planes namely up,down,left, right, near & far. But this will turn entire camera in orthographic mode. If you want to put part of camera in orthographic mode & rest render perspective mode then i believe only way is using two cameras. I have not seen anywhere the projection can be skewed small region of camera. If you have come across such example do share here. Though I doubt its at all possible as camera accepts only one matrix.– killer_mech
Nov 9 at 8:32
Have you tried using orthographic projection matrix?
Camera.main.projectionMatrix = Matrix4x4.Ortho(-1, 1, -1, 1, 1, 10);
. The six values are of frustum planes namely up,down,left, right, near & far. But this will turn entire camera in orthographic mode. If you want to put part of camera in orthographic mode & rest render perspective mode then i believe only way is using two cameras. I have not seen anywhere the projection can be skewed small region of camera. If you have come across such example do share here. Though I doubt its at all possible as camera accepts only one matrix.– killer_mech
Nov 9 at 8:32
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53197549%2fprojecting-orthographic-matrix-through-a-perspective-camera%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
And a second camera is bad....why?
– Draco18s
Nov 8 at 0:53
Iam not sure what exactly you are trying to do here. Are you trying to render mesh in screenspace camera? or screenspace overlay? Secondly why your projection override not working? The projection matrix change works and have no issue. And as Draco18s said why not use second camera? Can you add more info on what you are trying to do? Add screenshot of heirarchy so we can also know what you have done. answers.unity.com/questions/876698/… And lastly are you trying to achive the one mentioned in thread?
– killer_mech
Nov 8 at 4:23
@killer_mech there is no hierarchy here, I am building a retained mode UI system and want to render the result with the scene camera. I'm a systems engineer and my 3D spatial math is certainly lacking, so I'm sure it's just an issue on that side, and I wanted to see if anyone suggested a matrix approach. Anyhow, I'm using an internal camera in the meantime which simply renders the thing in ortho and then bleeds to the main camera, which doesn't really have much impact, but naturally if it's possible to project it through the same camera I'd rather take the lighter approach.
– Anon
Nov 8 at 13:01
Have you tried using orthographic projection matrix?
Camera.main.projectionMatrix = Matrix4x4.Ortho(-1, 1, -1, 1, 1, 10);
. The six values are of frustum planes namely up,down,left, right, near & far. But this will turn entire camera in orthographic mode. If you want to put part of camera in orthographic mode & rest render perspective mode then i believe only way is using two cameras. I have not seen anywhere the projection can be skewed small region of camera. If you have come across such example do share here. Though I doubt its at all possible as camera accepts only one matrix.– killer_mech
Nov 9 at 8:32