Light rendering flicker

Software: Away3D 4.x

claudiu s, Newbie
Posted: 09 August 2012 12:12 PM   Total Posts: 6

What i basicly do is add a new plane on the scene that has a basic material applyed. I have a directional light in the scene. Once i add the plane on the scene, the plane turns black for a fraction of a second. The ambient value of the light is 1. The less the ambient is, the less the effect is noticeable.

I’m using away3d 4.0.7 and fp 11.3
I’ll attach a simple demo class.
Thanks.

 

File Attachments
ExampleBug.as  (File Size: 3KB - Downloads: 310)
   

claudiu s, Newbie
Posted: 09 August 2012 12:15 PM   Total Posts: 6   [ # 1 ]

I forgot here’s a link to a demo of this bug:
http://webdev.zone-secure.net/flipbookdev/bug/

   

Richard Olsson, Administrator
Posted: 10 August 2012 10:53 AM   Total Posts: 1192   [ # 2 ]

I can’t see a flicker. Can you upload the code to gist.github.com or as a text file to the forums. The .as file suffix is not properly served by the away3d.com server.

   

claudiu s, Newbie
Posted: 10 August 2012 11:47 AM   Total Posts: 6   [ # 3 ]

here’s the complete as file :

package
{
 import away3d
.cameras.*;
 
import away3d.containers.*;
 
import away3d.controllers.*;
 
import away3d.debug.*;
 
import away3d.entities.*;
 
import away3d.lights.*;
 
import away3d.materials.*;
 
import away3d.materials.lightpickers.StaticLightPicker;
 
import away3d.primitives.*;
 
import away3d.textures.BitmapTexture;
 
import away3d.utils.*;
 
import flash.display.*;
 
import flash.events.*;
 
import flash.geom.*;
 
import flash.text.TextField;
 
import flash.utils.*;
 
 
[SWF(backgroundColor="#000000"frameRate="60"quality="LOW")]
 
public class ExampleBug extends Sprite
 {
     
private var scene:Scene3D;
  private var 
camera:Camera3D;
  private var 
view:View3D;
  
  private var 
light1:DirectionalLight;
  private var 
lightPicker:StaticLightPicker;
  
  public function 
ExampleBug() {
   init
();
  
}

  
private function init():void {
   initEngine
();
   
initLights();
   
initListeners();
   
   var 
tf:TextField = new TextField();
   
addChild(tf);
   
tf.autoSize "left"
   
tf.text "Click on the stage -> a plane will apear, but it has a quick black flicker"
  
}

  
private function initEngine():void {
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
   
   
scene = new Scene3D();
   
   
camera = new Camera3D();
   
camera.= -2000
   
   view 
= new View3D();
   
view.backgroundColor 0x8080C0;
   
view.antiAlias 4;
   
view.scene scene;
   
view.camera camera;
   
   
view.addSourceURL("srcview/index.html");
   
addChild(view);
  
}

  
private function initLights():void {
   light1 
= new DirectionalLight();
   
light1.direction = new Vector3D(010);
   
light1.color 0xFFFFFF;
   
light1.ambient 0.1;
   
light1.diffuse 0.7;
   
   
scene.addChild(light1);
   
   
lightPicker = new StaticLightPicker([light1]);
  
}
  
  
private function initListeners():void {
   addEventListener
(Event.ENTER_FRAMEonEnterFrame);
   
stage.addEventListener(MouseEvent.MOUSE_DOWNonMouseDown);
  
}

  
private function onEnterFrame(event:Event):void {
   view
.render();
  
}
  
  
private function onMouseDown(event:MouseEvent):void {
   stage
.removeEventListener(MouseEvent.MOUSE_DOWNonMouseDown);
   
addObject();
  
}
  
  
private function addObject():void {
   
var bd:BitmapData = new BitmapData(256256false0xffffffff);
   var 
_material:TextureMaterial = new TextureMaterial(new BitmapTexture(bd), truefalsefalse);
   
_material.lightPicker lightPicker;
   
_material.ambient 3
   
var plane2:Mesh = new Mesh(new PlaneGeometry(10001000), _material);
   
plane2.rotationX = -90
   
//plane2.x = -550
   //MeshHelper.invertFaces(plane2);
   
   
view.scene.addChild(plane2);
  
}
  
 }
   

Richard Olsson, Administrator
Posted: 10 August 2012 12:48 PM   Total Posts: 1192   [ # 4 ]

Everything looks ok in the code, and I can’t see any glitches or flickering in your demo. What is your environment (operating system, GPU et c)?

   

claudiu s, Newbie
Posted: 10 August 2012 01:03 PM   Total Posts: 6   [ # 5 ]

Indeed, the flicker doesn’t always appear. I have a AMD Radeon HD 6670, on win 7, i also tested on a mac, same thing - sometimes it happens, sometimes it don’t. Weird…

   

Richard Olsson, Administrator
Posted: 10 August 2012 01:12 PM   Total Posts: 1192   [ # 6 ]

Ok, I tried again and was actually able to reproduce about 20-30% o the times. I’ll speak to the rest of the team to see if anyone has any idea what it might be.

   

Richard Olsson, Administrator
Posted: 10 August 2012 01:23 PM   Total Posts: 1192   [ # 7 ]

Can you try changing the direction of the directional light, e.g. (1,-1,1)? Your light is configured to point straight up, so it will never actually affect a plane that is on the XY plane. For that reason, you should either use another direction for the light, or remove the light picker from the plane’s material.

   

claudiu s, Newbie
Posted: 10 August 2012 02:49 PM   Total Posts: 6   [ # 8 ]

thanks a lot, it worked, the flicker is gone. As a conclusion, never use a directional light which is paralel to the object you want to lid.

   

Ontheronix, Jr. Member
Posted: 27 August 2012 05:41 PM   Total Posts: 37   [ # 9 ]

I have the same problem with a similar setup, but the Directional Light was already pointing downwards in my case.
The flicker appears on startup, and affects only the objects in my View3D.
It seems to be the lighting that changes for a splitsecond.

Example: (horizontal plane) http://mark.me/test/ (Refresh page to repeat if you didn’t see it)

package  {
 
 import flash
.display.MovieClip;
 
import away3d.entities.Mesh;
 
import away3d.containers.View3D;
 
import away3d.primitives.PlaneGeometry;
 
 
import flash.events.Event;
 
import away3d.materials.lightpickers.StaticLightPicker;
 
import away3d.lights.DirectionalLight;
 
import away3d.materials.methods.TripleFilteredShadowMapMethod;
 
import flash.geom.Vector3D;

 
import away3d.core.pick.PickingType;
 
 
import flash.events.Event;
 
import away3d.events.Scene3DEvent;
 
 public class 
Main extends MovieClip {
  
  
var view:View3D;
  public function 
Main() {
    view 
= new View3D();
    var 
light:DirectionalLight = new DirectionalLight();   
    
light.ambient 0.6;
    
    
    
view.scene.addChild(light);
    
view.camera.position=new Vector3D(0,50,-400);
    
view.backgroundColor 0xFFFFFF;
    
view.addEventListener(Event.ENTER_FRAME,entr);
    
    
      var 
_lightPicker:StaticLightPicker = new StaticLightPicker([light]);
    
    var 
_groundMaterial:ColorMaterial = new ColorMaterial(0xEEEEEE);
    
_groundMaterial.shadowMethod = new TripleFilteredShadowMapMethod(light);
    
_groundMaterial.lightPicker _lightPicker;
    
    
    var 
msh:Mesh = new Mesh(new PlaneGeometry(400400),_groundMaterial);
    
view.scene.addChild(msh);
    
addChild(view);
  
}
  
function entr (e:Event{
     view
.render();  
  
}
 }
 

Also, the difference between light.direction and light.lookat() isn’t very clear to me.
Does anybody has some advice?

edit: the flicker doesn’t occur if i comment:

light.ambient 0.6

 

   

Jake, Newbie
Posted: 29 August 2012 02:30 PM   Total Posts: 11   [ # 10 ]

I had much the same experience reported a few posts above, Not having the light assinged both to the view and to the plane’s lightpicker (I eliminated the view light) seemed to fix it for me.

I could only see the effect the first time it loaded in my browser, reloaded seemed to not show it at all, though one’s eye persistence can make it tricky.

Opening the sample file location with the stand along player:

webdev.zone-secure.net/flipbookdev/bug/Away3d4Test.swf

Gave a clearer example, that seemed to get worse rerunning with open recent.

   

Ontheronix, Jr. Member
Posted: 31 August 2012 07:35 PM   Total Posts: 37   [ # 11 ]

Do you mean that you didn’t add the light to the view’s scene? Because a View3D doesn’t have a lightPicker property.
(And it doesn’t work for me)

edit: upgraded to the latest git release, same problem

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X