Author Topic: Blotchy renders in orthographic  (Read 196 times)

Rhys Thomas   «   on: May 14, 2012, 10:31:15 AM »
Hi I'm currently facing a problem when attempting to render an orthographic scene.
I know that orthographic views generally aren't supported in this version of Flare3D however was told that you can fake it by setting the zoom to something tiny like 1 or 0.1.
So this is what I have done, however when attempting to render the scene you get blotchy noise destroyinng some of the faces or render. I was wondering if anyone know of this problem, knows of the causes of this problem or even knows of a way around this problem??? please see for image of the problem -> http://polygonprophecy.com/orthographic.png


Rhys Thomas   «   Reply #1 on: May 14, 2012, 12:48:57 PM »
here is the source below to create the example:

package
{
    import flare.basic.Scene3D;
    import flare.basic.Viewer3D;
    import flare.core.Camera3D;
    import flare.materials.Shader3D;
    import flare.materials.filters.ColorFilter;
    import flare.primitives.Cube;
    import flare.primitives.Plane;
   
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
   
    [SWF(frameRate = 60, width = 800, height = 450, backgroundColor = 0x000000)]
    public class OrthoTest extends Sprite
    {
        private var scene:Scene3D;
        private var box:Cube;
        private var plane:Plane
        public function OrthoTest()
        {
            // stage configuration.
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            scene = new Viewer3D(this);
            //scene.camera.zoom = 0.1;
            scene.pause();
            //create transparent box material
            var material:Shader3D = new Shader3D("", null, false);
            material.filters.push(new ColorFilter(0x00ff00, 1));
            //material.transparent = true;
            material.build();
            box = new Cube("",10,10,10,10,material);
            //scene.addEventListener( Scene3D.COMPLETE_EVENT, completeEvent );
            var material:Shader3D = new Shader3D("", null, false);
            material.filters.push(new ColorFilter(0x0000ff, 1));
            plane = new Plane("", 300, 300, 1, material, "+xz");
           
           
            completeEvent();
            this.addEventListener(Event.ENTER_FRAME, update);
        }
       
        private function completeEvent(e:Event = null):void
        {
            //camera position and orientation.
            scene.camera = new Camera3D();
            //scene.camera.setPosition( 480, 392, -480 );
            scene.camera.far = 80000;
            scene.camera.fieldOfView = 0.2;
            scene.camera.x = 20000;
            scene.camera.z = 20000;
            scene.camera.y = 20000;
            scene.camera.lookAt( 0, 0, 0 );
            scene.antialias = 1;
           
            //init scene
            scene.play();
            scene.resume();
           
            scene.addChild(box);
            box.y = (box.height/2)+1;
            scene.addChild(plane);
        }
       
        private function update(e:Event = null):void
        {
            box.rotateY(1);
        }
    }
}

Ivan Vodopiviz   «   Reply #2 on: May 14, 2012, 03:21:57 PM »
Hi,

The problem here is that your numbers are so huge that your depth buffer is breaking. Setting a the near plane a little closer to the far plane seems to solve the issue. I also tried reducing the values while keeping the same effect: The following code seems to work:

private function completeEvent(e:Event = null):void
{
      //camera position and orientation.
      scene.camera = new Camera3D();
      //scene.camera.setPosition( 480, 392, -480 );
      scene.camera.far = 35000;
      scene.camera.near = 20000;
      scene.camera.fieldOfView = 0.2;
      scene.camera.x = 20000;
      scene.camera.z = 20000;
      scene.camera.y = 20000;
      scene.camera.lookAt( 0, 0, 0 );
      scene.antialias = 1;
          
      //init scene
      scene.play();
      scene.resume();
          
      scene.addChild(box);
      box.y = (box.height/2)+1;
      scene.addChild(plane);
}

Also, be careful, you're redefining "material" :)

Rhys Thomas   «   Reply #3 on: May 15, 2012, 07:34:09 AM »
Ah thankyou, your a life saver, that worked beautifully :D