Model jittering in front of camera

It seems to me I am getting into floating precision related problems, that I don’t know how to fix. The following test code constructs the node chaser, parents the camera to it, and then moves chaser with a certain velocity. A model is loaded as object node, parented to chaser, scaled and put in front of the camera. If the model is put very near to camera (case == 1 branch), then it quite visibly jitters when run. If it is put much further away (case == 2 branch) and enlarged, such that visual apparence on the screen is the same as in case 1, then there is no jitter any more.

chaser = render.attachNewNode("chaser")
chaser.setPos(0, 0, 4000)
chaser.setHpr(0, 10, 0)

object = loader.loadModel("sphere1280.egg")

case = 1
if case == 1:
    object.setPos(0, 0.5, 0)
elif case == 2:
    object.setPos(0, 10.5, 0)

spd = 200.0
vel = render.getRelativeVector(chaser, PM.Vec3(0, spd, 0))
def test_task (task):
    dt = globalClock.getDt()
    chaser.setPos(chaser.getPos() + vel * dt)
    return task.cont
task = taskMgr.add(test_task, "test-task")

Note that initial position of chaser is (0, 0, 4000); if I put that to (0, 0, 0) instead, then the jitter is gone in case 1 as well at first, but starts to appear and increase as chaser moves away from (0, 0, 0). Jitter permanently disappears if HPR of chaser is set to (0, 0, 0). (The full code, including the model:

Background: I’m trying to make a 3D airplane cockpit, and when I set all positions and sizes realistically against the full scene (taking 1 scene unit = 1 meter), then the cockpit is jittering. Maybe there is a known best way to do this, instead of making the cockpit a normal part of the full scene?

since your cockpit usualy is always drawn ontop of your landscape you could easily set up a new scene+camera and draw it over (like aspect and render2d). just with your own setup.

havent checked the actual jittering yet.

The problem with putting cockpit in separate scene is that I would have to “simulate” every interaction with the environment that would otherwise be automatic. Like lighting, or positioning of outer airplane elements (as pilot turns head). Of course, if that’s the only way…

I think you will find that in order to achieve a particular visual effect, you will need to simulate all of this stuff anyway. This is the way almost all games do it, because if you relied on physically correct rendering, the look would tend to be unsatisfying.


If that’s the case, I’m off to “simulating” :slight_smile: Thanks, folks.