我正在实现一个 Away3D 4.x 应用程序,其中我有一些应该投射阴影的网格。我设置了 DirectionalLight 和 FilteredShadowMapMethod,然后将方法应用到材质上。但是,正如您在屏幕截图中看到的那样,灯光似乎忽略了靠近地面的物体(它们的 Y 位置很小),并且只为高于某个 Y 坐标的物体投射阴影。您可以在右侧的砖块上很好地看到这一点。
我不明白我做错了什么,有人可以帮忙吗?这是我的代码的主要部分:
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;
砖块被创建为具有砖块材料的立方体网格。同样,一些 SphereMeshes 有自己的材质,其创建方式与 grayBrickMaterial 相同,在远处飞来飞去和一个巨大的 CubeMesh。
还要注意棕色大立方体上奇怪的灯光效果——那种灯光是没有意义的!