我对away3d相当新。在用阴影对象组合一个基本场景后,我想知道他们为什么不相互遮挡阴影?
在我的例子中,在平面上方有一个立方体,在两者之上有一个方向光。如何让立方体在它下面的平面上投下阴影?
使用3d 3.6
编写示例package {
import flash.display.MovieClip;
import flash.events.*;
import away3d.containers.View3D;
import away3d.primitives.Cube;
import away3d.primitives.Plane;
import away3d.lights.DirectionalLight3D;
import away3d.materials.PhongColorMaterial;
import away3d.materials.ColorMaterial;
import flash.geom.Vector3D;
public class Test7 extends MovieClip {
public var view:View3D;
public var light:DirectionalLight3D;
public var cube:Cube;
public var plane:Plane;
public function Test7() {
// constructor code
view = new View3D();
view.x = 200;
view.y = 200;
view.z = 150;
light = new DirectionalLight3D();
light.direction = new Vector3D(0, -1, 0);
light.brightness = 5;
view.scene.addLight(light);
plane = new Plane();
plane.material = new PhongColorMaterial(0xCCCCCC);
plane.width = 1000;
plane.height = 1000;
plane.segmentsH =
plane.segmentsW = 10;
plane.y = -100;
view.scene.addChild(plane);
cube = new Cube();
cube.rotationX = 45;
cube.rotationY = 45;
cube.segmentsD =
cube.segmentsH =
cube.segmentsW = 10;
cube.material = new PhongColorMaterial(0x330099);
view.scene.addChild(cube);
addChild(view);
addEventListener(Event.ENTER_FRAME, render);
}
public function render(e:Event):void {
view.render();
}
}
}
答案 0 :(得分:1)
实时计算阴影对CPU太重,因此需要GPU(远离3D 4.0+) 您应该使用图形编辑器将阴影,漫反射光照,全局照明,环境光遮挡等烘焙到纹理。这将为您提供超高质量的静态照明,因为预先计算全局照明可能需要大量时间而不是1秒30秒。使场景更加动态您可以将环境立方体贴图添加到模型或基本光照。
以下是预先计算阴影的演示: http://alternativaplatform.com/ru/demos/temple/ 这个与env地图: http://alternativaplatform.com/swf/demos/mobilephone/mobilephone.swf
答案 1 :(得分:0)
您似乎需要在材质中添加shadowMethod。
http://away3d.com/livedocs/away3d/4.0/away3d/materials/DefaultMaterialBase.html#shadowMethod
http://away3d.com/livedocs/away3d/4.0/away3d/materials/methods/FilteredShadowMapMethod.html
看看这个演示,了解它是如何实现的
源: http://infiniteturtles.co.uk/projects/away3d4/examples/Intermediate_PerelithKnightMD2/srcview/