Line Segs, Orthographic Lens, Z-order puzzle / bug

Hello,

I am creating a LineSegs object that has some funny behavior.

In this program, both linesegs appear behind the card ‘c1N’. But when the last two lines are commented out, the green line appears in front as expected.

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from panda3d.core import *


cm = CardMaker('card')
c1N= cm.generate( )
c1= NodePath( c1N )
c1.setPos( 0, 0, 0 )
c1.copyTo( render )

linesrandR= LineSegs( 'linesrand' )

#green: lower left to top right
linesrandR.setColor( 0, 1, 0, 1 )
linesrandR.moveTo( -1, -.1, -1 )
linesrandR.drawTo( 2, -.1, 2 )

#red: lower right to top left
linesrandR.setColor( 1, 0, 0, 1 )
linesrandR.moveTo( 2, .1, -1 )
linesrandR.drawTo( -1, .1, 2 )

linesrandN= linesrandR.create( )
linesrand= NodePath( linesrandN )
linesrand.reparentTo( render )

base.cam.setPos( 0, -10, 0 )
base.cam.node( ).setLens( OrthographicLens( ) )
base.cam.node( ).getLens( ).setFilmSize( 5, 5 )

run( )

In a slight variation, both linesegs appear in front of the card, until the last two lines are commented out. The linesegs don’t move behind the card until their Y-coordinate is around +0.5, slighty larger.

I see the red line behind and the green line in front. Maybe it’s your limited Z-depth again? Try reducing the distance between the near and far planes on the OrthographicLens.

David

Right again.

base.cam.node( ).getLens( ).setFar( 100 )

fixes it.

That’s getting a little ridiculous. It looks like I only have 6 sig. figures on my depth order.

(Pdb) p base.cam.node( ).getLens( ).getNear( )
1.0
(Pdb) p base.cam.node( ).getLens( ).getFar( )
100000.0

When the far-plane is 100000, depth epsilons < 1 don’t render correctly.

That’s consistent with a 16-bit depth buffer, which can represent 65,536 different values (just less than 5 significant digits).

You might be able to get more depth, at the cost of color or stencil or aux buffers or something, by fiddling with the startup bits:

color-bits 24
depth-bits 24
stencil-bits 0
aux-bits 0

David