[LayaAirIDE 2.0]PBR标准材质实时阴影渲染问题
先上unity和laya效果的对比图
模型用的材质是'PBR(Standard)',求大佬和技术人员解惑,看看我这是啥地方出了问题。
import ModelViewer from "./ModelViewer";以上代码是对灯光阴影的设置,和模型网格光照信息设置。(好坑,unity设置的接收阴影产生阴影都不管用,得重新代码撸!!)
import Scene = Laya.Scene;
export default class Game3D extends Scene {
constructor() {
super();
//初始化引擎
Laya3D.init(0, 0);
var scene_360 = Laya.loader.getRes("LayaScene_PUCHENG3D/Conventional/PUCHENG3D.ls") as Laya.Scene3D;
Laya.stage.addChildAt(scene_360, 0);
var camera = (scene_360 as Laya.Node).getChildByName('Main Camera') as Laya.Camera;
// var camera = new Laya.Camera(0, 0.1, 100);
// scene_360.addChild(camera);
camera.transform.rotationEuler = new Laya.Vector3(-32, -75, 0);
camera.transform.position = new Laya.Vector3(-8.2, 5.3, 2.2);
var modelViewer = camera.addComponent(ModelViewer);
modelViewer.AroundPos = Laya.Vector3._ZERO;
var directionLight = (scene_360 as Laya.Node).getChildByName('Directional light') as Laya.DirectionLight;
//灯光开启阴影
directionLight.shadow = true;
//可见阴影距离
directionLight.shadowDistance = 20;
directionLight.shadowResolution = 2048;
var receiveShadowgroup = (scene_360 as Laya.Node).getChildByName('PuCheng').getChildByName('receiveShadow');
var castShadowgroup = (scene_360 as Laya.Node).getChildByName('PuCheng').getChildByName('castShadow');
receiveShadowgroup._children.forEach(_model => {
//(_model as Laya.MeshSprite3D).meshRenderer.castShadow = true;
(_model as Laya.MeshSprite3D).meshRenderer.receiveShadow = true;
});
castShadowgroup._children.forEach(_model => {
(_model as Laya.MeshSprite3D).meshRenderer.castShadow = true;
//(_model as Laya.MeshSprite3D).meshRenderer.receiveShadow = true;
});
}
}
模型用的材质是'PBR(Standard)',求大佬和技术人员解惑,看看我这是啥地方出了问题。
没有找到相关结果
已邀请:
要回复问题请先登录
0 个回复