c++ - How to set orthographic near/far clipping planes to display all vertices -


i rendering scenes using glm::ortho projection. want rendering include every vertex draw without adding unnecessary depth (i.e. minimal depth buffer resolution impact).

i've seen this post similar question on perspective projections, looking both near , far clipping plane values in orthographic projection.

i can calculate z values of each vertex using viewmatrix transform vertices screen coordinates. in pseudo code:

float near; float far;  (each glm::vec4 vertex) {     glm::vec4 trans = viewmatrix * vertex;     // invert z-buffer     trans.z = -trans.z;     if (trans.z < near)         near = trans.z;     if (trans.z > far)         far = trans.z; } 

this way, near , far represent z-values of nearest , farthest vertices in screen coordinates, respectively.

but when use these values znear , zfar in glm::ortho matrix, of rendering still clipped. missing?


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -