java3d
  1. java3d
  2. JAVA3D-173

Anti-aliasing/transparency-sorting performance.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.3.2
    • Fix Version/s: 1.6.0
    • Component/s: j3d-core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      173

      Description

      I'm running into a problem in java3d where I have a
      primitive sphere and a LineArray on a switch node. The
      appearance for the LineArray has a LineAttribute set with
      anti-aliasing turned on. The view has
      setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY)
      . I have a collection of these nodes that I want to render.

      Now, if I render the LineArray, performance is good. If I
      render the Sphere without first rendering the LineArray,
      performance is good. However, if I render the LineArray,
      then switch to the Sphere, performance is bad.

      Turning anti-aliasing off on the LineAttribute or setting
      the setTransparencySortingPolicy to none both solve the
      performance problem, but I would like to be able to have
      both of these on.

      Does anyone have any ideas of why the switch node might be
      causing the spheres to use anti-aliasing? Or if that isn't
      the case, does anyone know what else might be causing the
      slowdown. Attached is a sample program the demonstrates the
      problem.

      Thanks,
      Brian Palmer

      import javax.media.j3d.*;
      import java.util.*;
      import com.sun.j3d.utils.behaviors.mouse.*;
      import javax.vecmath.*;
      import com.sun.j3d.utils.geometry.*;
      import com.sun.j3d.utils.universe.*;
      import java.awt.Color;

      public class AntiAliasingBugTest {

      private static final Color3f BLACK = new Color3f(Color.black);
      private static final Color3f WHITE = new Color3f(Color.white);

      public static void main(String[] args){
      SimpleUniverse universe = new SimpleUniverse();
      universe.getCanvas().getView().setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
      BranchGroup group = new BranchGroup();
      TransformGroup sceneTrans = new TransformGroup();
      sceneTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
      sceneTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
      sceneTrans.setCapability(Group.ALLOW_CHILDREN_READ);
      Transform3D sceneTransform = new Transform3D();
      sceneTransform.setTranslation(new Vector3d(0.0,0.0,-30.0));
      sceneTrans.setTransform(sceneTransform);
      group.addChild(sceneTrans);
      for (int i = -1000; i < 1000; i++){
      TransformGroup tg = new TransformGroup();
      tg.setCapability(Group.ALLOW_CHILDREN_READ);
      sceneTrans.addChild(tg);
      Transform3D transform = new Transform3D();
      transform.setTranslation(new Vector3d((double)i/100.0,0.0,0.0));
      tg.setTransform(transform);
      Switch switchNode = new Switch(Switch.CHILD_MASK);
      switchNode.setCapability(Switch.ALLOW_SWITCH_WRITE);
      switchNode.setCapability(Switch.ALLOW_SWITCH_READ);
      BitSet visibleSet = new BitSet();
      switchNode.setChildMask(visibleSet);
      Appearance appearance = createAppearance();
      Sphere sphere = new Sphere(1.0f, appearance);
      switchNode.addChild(sphere);
      Shape3D wireframeLines = new Shape3D();
      LineAttributes lineAttributes = new LineAttributes(2,
      LineAttributes.PATTERN_SOLID, true);
      Appearance lineAppearance = new Appearance();
      lineAppearance.setLineAttributes(lineAttributes);
      ColoringAttributes coloringAttributes = new ColoringAttributes(WHITE,1);
      lineAppearance.setColoringAttributes(coloringAttributes);
      LineArray lines = new LineArray(2, GeometryArray.COORDINATES);
      lines.setCoordinate(0, new Point3d(0.0,0.0,0.0));
      lines.setCoordinate(1, new Point3d((double)i/100.0,0.0,0.0));
      wireframeLines.setAppearance(lineAppearance);
      wireframeLines.setGeometry(lines);
      switchNode.addChild(wireframeLines);
      tg.addChild(switchNode);
      }

      Color3f light1Color = new Color3f(.1f, 1.4f, .1f); // green light
      BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0),
      100.0);
      Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
      DirectionalLight light1 = new DirectionalLight(light1Color,
      light1Direction);
      light1.setInfluencingBounds(bounds);
      group.addChild(light1);
      universe.getViewingPlatform().setNominalViewingTransform();

      MouseRotate behaviorRot = new MouseRotate(sceneTrans);
      sceneTrans.addChild(behaviorRot);
      behaviorRot.setSchedulingBounds(bounds);

      MouseZoom behaviorZoom = new MouseZoom(sceneTrans);
      sceneTrans.addChild(behaviorZoom);
      behaviorZoom.setSchedulingBounds(bounds);

      MouseTranslate behaviorTrans = new MouseTranslate(sceneTrans);
      sceneTrans.addChild(behaviorTrans);
      behaviorTrans.setSchedulingBounds(bounds);
      universe.addBranchGraph(group);
      Enumeration children = sceneTrans.getAllChildren();
      while (children.hasMoreElements()) {
      Object object = children.nextElement();
      if (object instanceof TransformGroup){
      TransformGroup tg = (TransformGroup) object;
      Switch switchNode = (Switch)tg.getChild(0);
      BitSet bitsets = new BitSet();
      bitsets.set(1);
      switchNode.setChildMask(bitsets);
      }
      }
      try {
      Thread.sleep(2000);
      } catch (Exception e){

      }
      children = sceneTrans.getAllChildren();
      while (children.hasMoreElements()) {
      Object object = children.nextElement();
      if (object instanceof TransformGroup){
      TransformGroup tg = (TransformGroup) object;
      Switch switchNode = (Switch)tg.getChild(0);
      BitSet bitsets = new BitSet();
      bitsets.set(0);
      switchNode.setChildMask(bitsets);
      }
      }
      }

      private static Appearance createAppearance() {
      Material material = createMaterial();
      Appearance appearance = new Appearance();
      appearance.setMaterial(material);
      return appearance;
      }

      private static Material createMaterial()

      { Material material = new Material(WHITE, BLACK, WHITE, WHITE, 0.0f); material.setCapability(Material.ALLOW_COMPONENT_WRITE); return material; } }

        Activity

        Hide
        jada added a comment -

        This is a Java 3D bug.

        Show
        jada added a comment - This is a Java 3D bug.
        Hide
        jada added a comment -

        Assigned to jada

        Show
        jada added a comment - Assigned to jada
        Hide
        kcr added a comment -

        Too risky for 1.4.0. Set target to 1.5.0.

        Show
        kcr added a comment - Too risky for 1.4.0. Set target to 1.5.0.
        Hide
        kcr added a comment -

        Set priority to P4.

        Show
        kcr added a comment - Set priority to P4.
        Hide
        kcr added a comment -

        Set target release to 1.6.0

        Show
        kcr added a comment - Set target release to 1.6.0
        Hide
        kcr added a comment -

        Unassigned.

        Show
        kcr added a comment - Unassigned.

          People

          • Assignee:
            java3d-issues
            Reporter:
            sir_swing
          • Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: