Camera Clipping

Software: Away3D 4.x

Avatar
Baush, Sr. Member
Posted: 12 September 2011 03:58 PM   Total Posts: 135

Hello, I’m having trouble with the camera’s far clipping. As you will see from the example below, the terrain mesh is clipping correctly over the “far” distance. Therefore, the Sprite3D (trees) are never made invisible over the “far” distance.

Is this expected, or a bug?

http://www.chitchatcity.com/beta/3d/

   

Avatar
Alejandro Santander, Administrator
Posted: 12 September 2011 04:55 PM   Total Posts: 414   [ # 1 ]

Hey Baush, running a few tests, will let you know how it goes…

 

   

Avatar
Alejandro Santander, Administrator
Posted: 12 September 2011 05:39 PM   Total Posts: 414   [ # 2 ]

Ok, looks like there are 2 issues in your demo.

1) Frustum edges side clipping on sprites makes them jump in and out of the scene. I have reported this issue in github: https://github.com/away3d/away3d-core-fp11/issues/92

2) Sprite3D’s not being clipped by far lens. This does not seem to be an Away3D issue, but something weird going on on your demo. Please try to find what may be causing the problem or provide further details of your implementation.

These two assertions can be confirmed on this test:
http://www.lidev.com.ar/tests/away3d/sprites_clipping/
WASD to move, click and drag to rotate camera

 

   

Avatar
Baush, Sr. Member
Posted: 27 September 2011 10:32 PM   Total Posts: 135   [ # 3 ]

Thanks for the reply,

I’ve discovered something interesting; it seems the: “bitmapMaterial.alphaBlending = true” ignores the far attribute. When I set to false, they disappear at the far value and work correctly.

Please test with an alpha PNG with alphaBlending = true to confirm.

Thanks

 

 

   

Avatar
Baush, Sr. Member
Posted: 28 September 2011 11:38 AM   Total Posts: 135   [ # 4 ]

scratch this, it seems to be solved in the latest git.

Thanks!

 

   

Avatar
Alejandro Santander, Administrator
Posted: 28 September 2011 03:15 PM   Total Posts: 414   [ # 5 ]

Thanks for reporting the state of things Baush. I’ll mark the topic as resolved. Please let us know if you need anything else regarding this matter.

 

   

Avatar
Baush, Sr. Member
Posted: 29 September 2011 11:34 AM   Total Posts: 135   [ # 6 ]

I managed to reproduce the same problem.

Here is the source code attached (sorry for the mess, I’m just prototyping)

Also check out the updated demo here, we can clearly see the problem when using alphaBlending material on sprites. Therefore, when set to false, the far clipping works correctly. (Pan the camera a bit to see the horizon)

http://www.chitchatcity.com/beta/3d/

 

File Attachments
SpriteTest.as  (File Size: 12KB - Downloads: 328)
   

Avatar
Baush, Sr. Member
Posted: 29 September 2011 11:38 AM   Total Posts: 135   [ # 7 ]

If anyone else is having trouble with the attatchment:

http://www.chitchatcity.com/beta/3d/SpriteTest.as

 

   

Avatar
Matse, Sr. Member
Posted: 29 September 2011 12:50 PM   Total Posts: 149   [ # 8 ]

Don’t have time to look into it at the moment, but just in case you don’t know : you can use alphaThreshold instead of alphaBlending. AlphaBlending is to be used with caution as it is not always being Z-sorted properly.

alphaThreshold will only give you 0-1 transparency (100% transparent or 100% opaque, no in-between) but doesn’t have the problem as far as I can tell.

 

   

Avatar
Alejandro Santander, Administrator
Posted: 29 September 2011 04:37 PM   Total Posts: 414   [ # 9 ]

Guys, I’ve just run a test and everything appears to be working fine with the latest source, so I would be inclined to say that your allegation that “far clipping on sprite3D’s with a BitmapMaterial that uses alphaBlending does not work” is false.

Here are 2 tests:
- with alphaBlending = true: http://www.lidev.com.ar/tests/away3d/sprite_alphaBlending/
- with alphaThreshold = 0.5: http://www.lidev.com.ar/tests/away3d/sprite_alphaThreshold/

Notice that far clipping is occurring.

The source I used to test this is:

view.camera.lens.far 5000;
   
view.backgroundColor 0xFF00FF;

   var 
r:Number 5000;

   var 
colorMaterial:ColorMaterial = new ColorMaterial(0xFFFFFF);
   var 
plane:Plane = new Plane(colorMaterialrrr);
   
plane.= -r/2;
   
view.scene.addChild(plane);

   var 
bmd:BitmapData = new BitmapData(512512true0xFF000000);
   
bmd.perlinNoise(484818falsetrueBitmapDataChannel.RED BitmapDataChannel.ALPHAtrue);
   var 
bitmapMaterial:BitmapMaterial = new BitmapMaterial(bmd);
   
bitmapMaterial.alphaBlending true// choose 1
//   bitmapMaterial.alphaThreshold = 0.5;

   
for(var i:uint250; ++i)
   
{
    
var sprite:Sprite3D = new Sprite3D(bitmapMaterial500500);
    
sprite.position = new Vector3Drand(-rr), rand(-rr), rand(-rr) );
    
view.scene.addChild(sprite);
   

 

   

Avatar
Matse, Sr. Member
Posted: 29 September 2011 04:56 PM   Total Posts: 149   [ # 10 ]

Just a note : I was only speaking about Z-sorting issues with alphablending, it doesn’t appear on your demo though, I’ll run some tests later but I thought it was a problem that didn’t come from away3d.

 

   

Avatar
Baush, Sr. Member
Posted: 29 September 2011 06:58 PM   Total Posts: 135   [ # 11 ]

Thanks Alejandro, I will try to compile your example to confirm if there’s something wrong with my away3d sources or environment in general.

Are both SVN and GIT sources synchronized? Please point me to the away3d sources I should be using, just in case I’m using old sources or something.

Thanks
-Matt

 

   

Avatar
Alejandro Santander, Administrator
Posted: 29 September 2011 07:08 PM   Total Posts: 414   [ # 12 ]

Please use GItHub, there is no guarantee atm that the SVN is updated.

 

   

Avatar
Baush, Sr. Member
Posted: 30 September 2011 02:38 AM   Total Posts: 135   [ # 13 ]

Ok, I have some more information concerning this issue.

1- Using the alphaThreshold makes the sprite clip correctly as opposed to alphaBlending

2- The alphaBlending is also clipped, but not a the exact “far” value (a bit farther)

In short: An alphaThreshold sprite clips exactly at the same position as the terrain, but alphaBleding clips father away.

See the demo here:

Trees uses alphaThreshold, and Rocks / Herbs uses alphaBlending. Notice the difference between the clipping:

http://www.chitchatcity.com/beta/3d/

Hope this helps reproduce the problem. Thanks!

 

   

Avatar
Alejandro Santander, Administrator
Posted: 30 September 2011 04:15 AM   Total Posts: 414   [ # 14 ]

I’ve made another test laying out sprites on a circle on the XZ plane, alternating between a bitmap material with alpha blending and a bitmap material with alpha threshold: http://www.lidev.com.ar/tests/away3d/alpha_far/

view.camera.lens.far 5000;
   
view.backgroundColor 0xFF00FF;

   var 
r:Number 5000;

   var 
tri:Trident = new Trident();
   
view.scene.addChild(tri);

   var 
colorMaterial:ColorMaterial = new ColorMaterial(0xFFFFFF);
   var 
plane:Plane = new Plane(colorMaterialrrr);
   
plane.= -r/2;
   
view.scene.addChild(plane);

   var 
bmd:BitmapData = new BitmapData(512512true0xFF000000);
   
bmd.perlinNoise(484818falsetrueBitmapDataChannel.RED BitmapDataChannel.ALPHAtrue);
   var 
bmd1:BitmapData bmd.clone();
   
bmd1.colorTransformbmd.rect, new ColorTransform(100) );

   var 
bitmapMaterialForBlending:BitmapMaterial = new BitmapMaterial(bmd);
   
bitmapMaterialForBlending.alphaBlending true;

   var 
bitmapMaterialForThreshold:BitmapMaterial = new BitmapMaterial(bmd1);
   
bitmapMaterialForThreshold.alphaThreshold 0.5;

   var 
toRads:Number Math.PI 180;
   for(var 
i:uint90; ++i)
   
{
    
var sprite:Sprite3D = new Sprite3D== bitmapMaterialForThreshold bitmapMaterialForBlending 500500);
    
sprite.0.7 Math.costoRads );
    
sprite.0.7 Math.sintoRads );
    
view.scene.addChild(sprite);
   

As you can see, they are clipped by the far plane in exactly the same manner.

The problem seems to be something different though. Can you try to reduce it to the simplest possible error case (a test) and submit that code?

 

   

Avatar
Baush, Sr. Member
Posted: 30 September 2011 01:45 PM   Total Posts: 135   [ # 15 ]

We’re getting closer.. It would seem the skybox is causing the problem. I’ll investigate this further.. If you want, try adding a skybox to your example and see if it changes anything.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X