Background Color support added

Background Color support just committed to CVS HEAD.

Background color now rendering with no extra performance cost by changing canvas clear color before clearing frame buffer.

Additional atom (BackgroundColorAtom) added, additional rendering setup pass introduced (no performance impact if no background color set, no background existing or packground color set to null).

Appropriate examples added as Xith3DBackgroundColorTest.java and Xith3DBackgroundColorTest.bat.

Yuri

Two thumbs up :slight_smile:

Hey man just checked the xith3d.jar file in the cvs and it dates all the way back to 10/11/03.
The size is also 484k whereas the nightly build commited by William weighs no less than 650k
???

I would suggest deleting xith3d.jar from cvs. Support libraries - ok, but main library should be not included inside CVS IMHO.

You have to run the ant build script to update xith3d.jar.

NVM built it all up using netbeans build all command :slight_smile:
Works like a charm now.

Me again, I managed to compile the source using the provided ant build, but when I try to run some of my demos, it takes about 2-3 seconds before a null pointer exception surfaces:


java.lang.NullPointerException
        at com.xith3d.render.RenderBin.addAtom(RenderBin.java:87)
        at com.xith3d.render.Renderer.addRenderSetupAtom(Renderer.java:167)
        at com.xith3d.scenegraph.View.renderNode(View.java:902)
        at com.xith3d.scenegraph.View.renderNode(View.java:1015)
        at com.xith3d.scenegraph.View.getRenderFrame(View.java:824)
        at com.xith3d.scenegraph.View.renderOnce(View.java:717)
        at com.xith3d.scenegraph.View.renderOnce(View.java:655)
        at Xith3DParticles.ParticlesTest.run(ParticlesTest.java:353)
        at java.lang.Thread.run(Thread.java:534)

Also enabling background color gives the performance a firm kick in the nuts (we’re talking about 20-30% performance loss on a 2.1 Ghz Athlon, Radeon 9500 Pro machine).
Oh well :’(

[quote]I would suggest deleting xith3d.jar from cvs. Support libraries - ok, but main library should be not included inside CVS IMHO.
[/quote]
100% agree with you there :slight_smile:

Since we’re on the topic I think that the reference/xith_utilities.zip isn’t needed anymore since it’s now in the main trunk. Same goes for third-party/xith_utilities.jar.

Would anyone object to the removal of those three files from CVS?

Will.

Fixed my null exception by modifying the RenderBin.


    public void addAtom( RenderAtom atom ) {
        if (curSize == buckets.length) {
            RenderBucket[] newBuckets = new RenderBucket[buckets.length + EXT_SIZE];
            System.arraycopy(buckets, 0, newBuckets, 0, buckets.length);
            buckets = newBuckets;
        }
        if(curSize<buckets.length-1)
          buckets[curSize++].setAtom(atom);
    }

Still, now running my particles system containing 50 billboarded, alpha blend squares, shows a huge performance drop:
Without BackGround color FPS ~1900FPS
With BackGround color FPS ~1000FPS!!!
:sad panda:

Thats weird JCD, the first part of that code should obviate the need for the second part. How could curSize ever be >= to the array size if the preceeding clause increases it in just that condition?

[quote]Thats weird JCD, the first part of that code should obviate the need for the second part. How could curSize ever be >= to the array size if the preceeding clause increases it in just that condition?
[/quote]
No clue and yet it’s the only fix that I could put together… ???

An example showing performance cut in half after adding a background color.


  public BranchGroup scene(){
    BranchGroup scene      = new BranchGroup();
    Background  backGround = new Background(new Color3f(0,1,0));
    scene.addChild(backGround);
    return  scene;
  }

Trying commenting out the “addChild” part and get blown away by the frame rate increase…

Hi,

Sorry, it was a bug in Renderer.java - I forget to clear Render Setup pass bin between passes. This caused overflow of render bin after some time (3000 frames) and slowdown increasing over time.

Just committed a fix. Try now.

Fix provided by JCD replaced by one line in Renderer.java, so just use latest CVS HEAD version.

I tried JCD’s test with and without Background node and got exactly the same performance [after applying fix].

Yuri

Yup yup yup :slight_smile:

I’m trying to set the background to an image using the code below, but I’m getting the standard greyish background color instead. Am I doing something wrong?


             try
             {
                   BufferedImage im = ImageUtility.readImage("gfx\\bg.png");
                  ImageComponent2D ic2D = new ImageComponent2D(ImageComponent.FORMAT_RGBA, 800, 600, im);
                  Background  backGround = new Background(ic2D);
                  scene.addChild(backGround);
             }
            catch (Exception e) { e.printStackTrace();}

Images are not supported as backgrounds for a moment. What you can do is to use textured rectangle/grid of rectangles instead of BG. I am trying to find good accelerated way to draw BG image [I mean the way other than textured rect].

Yuri