Away3D - DirectionalLight施放的阴影已关闭

时间:2015-02-12 19:57:49

标签: actionscript-3 flash rendering away3d shadows

我正在实施一个Away3D 4.x应用程序,其中我有一些应该投射阴影的网格物体。我设置了DirectionalLight和FilteredShadowMapMethod,然后将该方法应用到材质上。但是,正如您在屏幕截图中看到的那样,灯光似乎忽略了靠近地面的物体(它们的Y位置很小),并且只为高于某个Y坐标的物体投射阴影。你可以在右边的砖块上看到这个。 enter image description here

我不明白我做错了什么,请有人帮忙吗?这是我的代码的主要部分:

light1 = new DirectionalLight(0, -3, -5);
light1.ambient = 0.5;
light1.diffuse = 1.0;
light1.specular = 1.0;

lightPicker = new StaticLightPicker([light1]);      
this.scene.addChild(light1);        
shadowMapMethod = new FilteredShadowMapMethod(light1);

groundCloseMaterial = new TextureMaterial(Cast.bitmapTexture(GroundDiffuseClose));
groundCloseMaterial.lightPicker = lightPicker;
groundCloseMaterial.specular = 0;
groundCloseMaterial.ambient = 1;
groundCloseMaterial.shadowMethod = shadowMapMethod;
groundCloseMaterial.repeat = true;
groundCloseMaterial.mipmap = false;

groundClose = new Mesh(new PlaneGeometry(MAX_WORLD_X*2, MAX_WORLD_Z*2), groundCloseMaterial);
groundClose.geometry.scaleUV(20, 20);
groundClose.y = 0.1;


//-- create bricks
greyBrickMaterial = new TextureMaterial(Cast.bitmapTexture(BrickDiffuse));
greyBrickMaterial.specularMap = Cast.bitmapTexture(BrickSpecular);
greyBrickMaterial.normalMap = Cast.bitmapTexture(BrickNormals);
greyBrickMaterial.lightPicker = lightPicker;
greyBrickMaterial.mipmap = false;
greyBrickMaterial.specular = 1;
greyBrickMaterial.ambient = 1;
greyBrickMaterial.shadowMethod = shadowMapMethod;

使用砖材料将砖块创建为CubeMeshes。同样,一些SphereMeshes也有自己的材质,它的创建方式与greyBrickMaterial相同,在远处飞来飞去,还有一个巨大的CubeMesh。

还要注意大棕色立方体上的奇怪光效 - 那种照明没有意义!

1 个答案:

答案 0 :(得分:0)

在Away3d论坛的社区成员的帮助下,我找到了一个解决方案。

简而言之,光的位置值应<&lt; 1.0以防止某些表面发生强烈反射:

light1 = new DirectionalLight(0., -0.7, -0.7);

其次,使用shadowMapMethod的.epsilon属性有助于让阴影从它们应该的位置开始,而不是偏移:

shadowMapMethod = new FilteredShadowMapMethod(light1);
shadowMapMethod.epsilon = 0.08;

这里的答案很长:http://away3d.com/forum/viewthread/5787/