I’m trying to draw a space scene where I can be very close to one object and yet see another object far away. I’ve been developing my application in JOGL (Java OpenGL bindings) and upto now I was using version 1.1.1, which is fairly old. That version seemed to allow me to have a very, very large ratio of near/far clipping planes and everything was working well. I was likely breaking the rule that requires the ratio to be reasonably small, but now I’m paying the price and with my update to JOGL 2.0+ I am having problems.
Basically, the picture below is what I am trying to achieve visually. I want to be able to have a camera located on a vehicle that approaches the International Space Station, and I want to be able to see parts of the vehicle from that camera view, while also seeing the station when it is far away.
So, currently I am unable to move too far away from the space station before it disappears, basically it falls outside of my clipping region. I tried to expand the clipping region to the same values I used under version 1.1.1 and it was broken - it wouldn’t render either when it got too far away, although under the old version is used to be fine.
My question is NOT about JOGL versions - that’s not important. I obviously need to keep those clipping plane ratio small, my question is what other options I have. I realize I could do a dual pass rendering where I render the far away scene to a texture and then project that texture, but my current setup would require too much code change to accomodate that so I was looking for another solution.
Specifically I read the following posts that mention a possible solution
https://www.opengl.org/discussion_boards/showthread.php/184983-glfrustum-near-and-far-values
I believe visually this means I am doing the following with my opengl gluPerspective() calls…ie left image is the old style where you have close near and distant far clipping planes, while the right image shows (what I imagine is being discussed above), that you have two (2) calls to gluPerspective() in the same pass with one call with one set of near/far clipping planes and the other call with a second set of clipping planes.
Effectively, I tried this kind of code:
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fov, ar, nearBACK, farBACK);
glMatrixMode(GL_MODELVIEW);
DRAWBACKGROUND();
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fov, ar, nearFWD, farFWD);
glMatrixMode(GL_MODELVIEW);
DRAWFOREGROUND();
But this doesn’t seem to be working for me. It seems like the second gluPerspective() is what the DRAWBACKGROUND() is using, because if I change the farFWD clipping distance to something closer than the BACKGROUND, then the BACKGROUND disappears.
Am I doing this correctly?
btw, why can’t I upload any images…keeping getting “not a valid image error” /rant