创建具有给定颜色、金属度和粗糙度值、不透明度、背面剔除和可选自发光颜色的金属度-粗糙度材质。
金属度 0 看起来像油漆或塑料,1 像裸金属;粗糙度 0 是镜面效果,1 是哑光。alpha 小于 1 使表面半透明。
名称、颜色、金属度和粗糙度值、不透明度、剔除和 z 偏移
材质
const brushed = bitbybit.babylon.material.pbrMetallicRoughness.create({ name: "brushed", baseColor: "#c0c0c0", emissiveColor: "#000000", metallic: 1, roughness: 0.4, alpha: 1, backFaceCulling: true, zOffset: 0 });
bitbybit.babylon.mesh.setMaterial({ babylonMesh: mesh, material: brushed, includeChildren: true });
为材质赋予一张图像纹理,在整个表面上替换其基础颜色,如 texture.createSimple 所创建。
材质和纹理
const texture = bitbybit.babylon.texture.createSimple({ name: "wood", url: "https://example.com/wood.jpg", invertY: false, invertZ: false, wAng: 0, uScale: 1, vScale: 1, uOffset: 0, vOffset: 0, samplingMode: Bit.Inputs.BabylonTexture.samplingModeEnum.trilinear });
bitbybit.babylon.material.pbrMetallicRoughness.setBaseTexture({ material, baseTexture: texture });
金属度-粗糙度类型的基于物理的材质,是描述真实表面的标准方式:基础颜色,金属度从 0(塑料或油漆)到 1(裸金属),粗糙度从 0(镜面)到 1(哑光),不透明度和可选的纹理。创建一个材质,然后通过
mesh.setMaterial或绘制选项将它赋给网格。