Shadow Matte / Show show but not the plane

Software: Away3D 4.x

XIDA, Newbie
Posted: 23 February 2013 04:39 PM   Total Posts: 1

I was searching for a way to cast a shadow on a plane but I wanted only the shadow to be visible, not the plane. Since I could find a way to do this I finally solved it myself. So maybe this is useful for people who are trying to do the same:

1. Setup your light:

var sunLight1:DirectionalLight = new DirectionalLight(0, -1, 0);   
   
sunLight1.color = 0xFFFFFF;
   
sunLight1.ambient = 0.4;
   
sunLight1.castsShadows = true;
   
scene.addChild(sunLight1); 

2. Setup the Shadow

var _shadowMapMethod:SoftShadowMapMethod = new SoftShadowMapMethod(sunLight1, 60);
   
_shadowMapMethod.range = 12;
   
_shadowMapMethod.epsilon = .005;
   
_shadowMapMethod.alpha = 0.6; 

3. Setup your plane material

var cMaterial:ColorMaterial = new ColorMaterial(0xFFFFFF);
   
cMaterial.smooth = true;
   
cMaterial.specular = 0;
   
cMaterial.blendMode = BlendMode.MULTIPLY;
   
cMaterial.ambient = 1;
   
cMaterial.repeat = false;
   
cMaterial.lightPicker =  new StaticLightPicker([sunLight1]);
   
cMaterial.shadowMethod = _shadowMapMethod; 

4. Create the plane

var _plane:Mesh = new Mesh(new PlaneGeometry(2000, 2000), cMaterial);   
   
_view.scene.addChild(_plane);
   
_plane.y -= 400;
   
_plane.z = 500; 

Now your objects’ shadows should look like in the attached image.

 

 

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X