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)?










share|improve this question






















  • 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















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)?










share|improve this question






















  • 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













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)?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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

















active

oldest

votes











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',
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
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Hercules Kyvelos

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud