Results 1 to 6 of 6

Thread: shapes disappearing when I zoom out

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2016
    Posts
    18

    shapes disappearing when I zoom out

    I'm drawing an icosahedron made out of triangles, and when I zoom out it disappears. First thing first, I'm pretty sure this is NOT about the far clipping plane. I'm using glm::infinitePerspective , and when i zoom out I'm just increasing the field of view (to a maximum of 45 deg). I'm just guessing, but I suspect that since I'm using perspective and the object is so "far" away, it's considered too small to be worth rendering.

    What I'd like is for it to always be visible, even if it's just as a pixel. A minimum perspective size, basically. Switching from perspective to orthographic projection might work, but I'd really prefer to avoid that. I was able to kind of achieve the effect by drawing a GL_POINT at the same location as the shape. The point is always visible, so it works as a placeholder when zoomed out. However, has I zoom in the point remains overlaid on top of the shape, which is distracting. I could only draw the points when the shape is not being rendered, but I've got no idea how to tell when that would be.

    So is this possible?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,650
    The first thing is to understand why your shape disappears.

    Is it getting smaller than a pixel? If none of the triangles happen to overlap the point at the center of the pixel, then nothing will be drawn (NOTE: I'm assuming you don't have MSAA enabled).

    A few things you might try: try a normal perspective projection where you "know" the far clip is 2X further than the distance from the eye to the object and the near plane is close. Also, if you're depth testing, are you clearing the depth buffer at the beginning of rendering every frame?

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2016
    Posts
    18
    I tried using a normal perspective, with far plane, but it doesn't seem to make a difference. I am clearing the depth buffer every frame.

    It seems like it is getting smaller than a pixel. I tried drawing a bunch these shapes at the same depth, but scattered around. If I zoom to a certain amount, I can get it so that some are visible and others not. That would make sense based on your description. Some of them just happened to overlap the middle of their pixels. I'm not using MSAA. Had to look up what it meant

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,650
    Ok, good. Now you know for sure what's going on. You've got a number of options. You can dynamically determine when your object is going to be smaller than the pixel by determining how wide a bounding sphere around your object would be in screen space. Then you can dynamically increase the size of the object to prevent it from getting smaller than a pixel or change to some "iconic" representation like a point.

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2016
    Posts
    18
    Do you mind telling me how to convert to screenspace? I'm guessing it's something like this:

    1) projection * view * model * point, for all the points in the object
    2) That is giving me some large numbers, which I'm thinking should be scaled to (-1,1). But what should I use for that scaling? The field of view width and height at the depth of the objects?
    3) After those results are normalized, I find the width of the object by scaling again ugins the pixel dimensions of the window.

    Am i at least on the right track here?

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,103
    Quote Originally Posted by Sunny_Lime View Post
    1) projection * view * model * point, for all the points in the object
    2) That is giving me some large numbers, which I'm thinking should be scaled to (-1,1). But what should I use for that scaling? The field of view width and height at the depth of the objects?
    Step 1.5: Divide X, Y and Z by W to convert from homogeneous coordinates to Euclidean coordinates. That should give you normalised device coordinates (NDC) in the range -1 to +1. Then, X and Y are converted to window coordinates using the viewport transformation set by by glViewport(), Z is converted to depth according to glDepthRange() (the initial state is equivalent to glDepthRange(0,1)).

Similar Threads

  1. Replies: 0
    Last Post: 01-06-2015, 09:42 AM
  2. Change zoom from dolly to "real" zoom
    By Rainer Wahnsinn in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-01-2013, 05:48 PM
  3. Incomplete shapes and "blobs" (extra solid shapes)
    By bballdave025 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-12-2011, 11:54 PM
  4. zoom in and zoom out with gl4java and Java
    By vamsee kanth in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-03-2004, 02:32 AM
  5. Replies: 0
    Last Post: 03-15-2001, 02:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean