Everything’s dark when using CascadeShadows [solved]

Software: Away3D 4.x

Van Hellsing, Newbie
Posted: 10 January 2014 05:51 PM   Total Posts: 30

I’ve built a scene in Away Builder and loaded it into my game.

In Builder it is working fine, however in the game the ground mesh gets all dark as if it’s in shadow. All but a thin light stripe from one end to the other.

If I place any objects over the stripe, no shadows are drawn.

Any ideas on why that might be? I’m using CascadeShadows with FilteredShadowMapMethod on default settings.

I’ve attached screenshots of both in-game and AwayBuilder.

 

   

Van Hellsing, Newbie
Posted: 10 January 2014 11:21 PM   Total Posts: 30   [ # 1 ]

Nobody ever helps me here :( I’ve been developing this game for well over a year and shadows are being the biggest pain in the ass. They’ve been doing all sorts of things to me.

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 11 January 2014 06:23 PM   Total Posts: 669   [ # 2 ]

Can I take it you’ve tried the suggestions in this article?
http://www.derschmale.com/2012/11/15/multi-pass-rendering-and-cascaded-shadow-mapping/

People will normally reply if they’ve stumbled across the same issue and found a solution. I’ve not used cascading shadows so I for one can’t offer much insight.

Good Luck!

 

   

Van Hellsing, Newbie
Posted: 11 January 2014 09:20 PM   Total Posts: 30   [ # 3 ]

Maybe someone wants to try to load the scene and see what happens? Is there anyone else who’s developing a game with large open spaces with Away3D.

 

File Attachments
home_bak.awd  (File Size: 1461KB - Downloads: 234)
   

Avatar
theMightyAtom, Sr. Member
Posted: 12 January 2014 01:17 PM   Total Posts: 669   [ # 4 ]

OK, what you need to do is split your enormous ground plane into smaller pieces. Currently you’re relying on a single shadow map to cover an area 28000 units square. Doing this should enable more accurate and definitely more well defined shadows. The area of the dip in your model, where the only shadows are, could be an object all its own.

Good Luck!

 

 

   

Van Hellsing, Newbie
Posted: 12 January 2014 07:19 PM   Total Posts: 30   [ # 5 ]

I’ve devided the ground grid like this (different sizes for comparison purposes). But the problem persists. Everything renders dark. And still if I enable for the ground to cast shadows, it covers with artifacts.

 

   

Van Hellsing, Newbie
Posted: 12 January 2014 07:39 PM   Total Posts: 30   [ # 6 ]

This is my main problem: after importing this AWD in game i get no shadows at all. Or one large shadow. No matter if the ground casts shadows on itself or not. And on my old laptop there’s no bright strip in the middle.

 

   

Van Hellsing, Newbie
Posted: 12 January 2014 07:50 PM   Total Posts: 30   [ # 7 ]

Wow. When I try to set ShadowMethod to null on any material AwayBuilder crashes with error #1125

 

   

John Brookes, Moderator
Posted: 12 January 2014 10:41 PM   Total Posts: 732   [ # 8 ]

The cameras lens far value is the most important thing on the quality of the shadows.
camera.lens.far =  AS LOW AS POSSIBLE

The issue with the black stripes is to do with the epsilon value of the shadowMethod
I think the default is 0.02
Lower that value. That will get rid of the stripes.
BUT it may also detach the shadows. Meaning the shadows will start a little away from the mesh.
Find a happy medium :/

Another is the angle of the light ( the elevation) low angles (sunset/sunrise) will also show the black stripes more.

Mess about with the above.

The bigest tip is.
If you dont need to alter the position of the light during the game, bake all your static mesh shadows to your textures in a 3d app (Blender/Maya/MAx)

Oh and mightys idea of spliting the mesh wont work.

And yeah AwayBuilder is erm… very alpha :/

 

   

Van Hellsing, Newbie
Posted: 14 January 2014 12:10 AM   Total Posts: 30   [ # 9 ]

I’ve set camera far value to 7000 units but the problem is still there. I have the same all-dark-with-bright-stripe ground mesh (now multiple meshes) and no shadows, when objects are obove the bright stripe.

 

   

John Brookes, Moderator
Posted: 14 January 2014 01:48 PM   Total Posts: 732   [ # 10 ]

Not sure whats happening there looks like an old bug with cascade.
What branch are you using? DEV MASTER? version 4.?

First you would need to update to the latest DEV branch on git as that will have the latest bug fixes.

To help the devs and anyone answering.
Post your code on how you are loading/setting up your scene.
Make it as simple as possible while still showing the issue.

 

   

Van Hellsing, Newbie
Posted: 14 January 2014 03:11 PM   Total Posts: 30   [ # 11 ]

At the moment I began this topic I was using 4.1.4, and yesterday upgraded to 4.1.5 witch is the latest as far as I can tell.

Yes, code… There’s lots of code and lots of classes. So here’s how I load the scene:

private function download():void
{
 assetLibrary 
AssetLibrary.getBundle("map");
 
 
assetLibrary.enableParser(AWD2Parser);

 
assetLibrary.addEventListenerAssetEvent.ASSET_COMPLETEonAsset );
 
assetLibrary.addEventListenerLoaderEvent.LOAD_ERRORonAssetError );
 
assetLibrary.addEventListenerLoaderEvent.RESOURCE_COMPLETEonResourceComplete );
 
 
resourcesLoaded 0;
 
resourcesToLoad 0;
 
 
assetLibrary.load(new URLRequest("app:/" path "/" name ".awd"));
 
resourcesToLoad++;
}


private function onAsset(e:AssetEvent):void
{
 
if (e.asset.assetType == AssetType.CONTAINER)
 
{
  view
.scene.addChild(e.asset as ObjectContainer3D);
 
}
 
 
if (e.asset.assetType == AssetType.SKYBOX)
 
{
  skyBox 
e.asset as SkyBox;
  
view.scene.addChild(skyBox);
 
}
 
 
if (e.asset.assetType == AssetType.TEXTURE)
 
{
  
if (e.asset.name == "environment"environment e.asset as BitmapCubeTexture;  // catching an environment map for later use
 
}
 
 
if (e.asset.assetType == AssetType.MESH)
 
{
  
// this is for creating rigid bodies for all the meshes loaded. 
  
var mesh:Mesh e.asset as Mesh;
  if (
mesh.parent.name == "solid")  // not the best criteria, but works for now. Gonna change it after I will figure out a way of assigning metadata in away builder
  
{
   
var transform:Matrix3D = new Matrix3D();
   
transform mesh.transform.clone();
   
   var 
shape:AWPBvhTriangleMeshShape = new AWPBvhTriangleMeshShape(mesh.geometry);
   
   var 
body:AWPRigidBody = new AWPRigidBody(shapemesh,0);
   
body.friction .99;
   
   
body.transform transform;
   
   
physicsWorld.addRigidBody(body);
  
}
 }
 
 
// catching lightpicker for later use
 
if (e.asset.assetType == AssetType.LIGHT_PICKER)
 
{
  lights 
e.asset as StaticLightPicker;  // catching lights for later use
 
}
 
 
// catching light and it's mapper for later use
 
if (e.asset.assetType == AssetType.LIGHT)
 
{
  dLight 
e.asset as DirectionalLight;
  var 
mapper:CascadeShadowMapper dLight.shadowMapper as CascadeShadowMapper;
 
}

 trace 
("Loaded " e.asset.assetType " Name: " e.asset.name);
 
 
loadHandler("Loaded " e.asset.assetType " Name: " e.asset.name);

All lights and meshes and everything is packed in one .awd. I “catch” light source, mapper and picker for using them with models for other stuff that is not a map, like my vehicle in the middle.

I now see that I’m adding to the scene only objectContainers. That’s left from the times when I was using awd 1.0, obviously.

So the question is, how, when and what exactly should I add to the scene when parsing awd 2.0?

 

   

Van Hellsing, Newbie
Posted: 14 January 2014 03:18 PM   Total Posts: 30   [ # 12 ]

Ok. Tried adding this here line and everything suddenly worked!!!

if (e.asset.assetType == AssetType.LIGHT)
{
 
if (e.asset is DirectionalLight)
 
{
  dLight 
e.asset as DirectionalLight;
  
view.scene.addChild(e.asset as DirectionalLight);  // <--- This here line
 
}

Though please answer my question from my last post (for future generations to come, and my better knowledge of the platform). But it works!

Thank you all for your help, you are awesome! Never once have I regretted choosing Away3D for this project.

 

   

John Brookes, Moderator
Posted: 14 January 2014 04:13 PM   Total Posts: 732   [ # 13 ]

Not so fast… smile
Yeah that was going to be my next question as I can get your file to load.
But you may notice the shadow sometimes disappears (it does this in awayBuilder too)

So there is another bug with cascade.
https://github.com/away3d/away3d-core-fp11/issues/673

As for when to add stuff to scene, I usually do it onResource but onAsset should also work.

Awaybuilder still needs a lot of work on it and im not a fan of using it to set up lights/shadows just yet. Prefer code

 

   

Van Hellsing, Newbie
Posted: 14 January 2014 05:57 PM   Total Posts: 30   [ # 14 ]

I’ve encountered that bug with directional shadows as well btw.

I’m trying to make an easy way for mappers to create and my levels. Having everything done by awaybuilder would have been the best option.

 

   

Van Hellsing, Newbie
Posted: 14 January 2014 06:44 PM   Total Posts: 30   [ # 15 ]

Aaaand there’s a big problem with objects that both need to cast and receive shadows. They all become like this:

 

   
   
‹‹ Non biped anim awd

X

Away3D Forum

Member Login

Username

Password

Remember_me



X