书接上回,这里讨论贴图的运用!!!
// 创建球网格
const ball = MeshBuilder.CreateSphere('ball',{diameter:1},scene)
ball.position = new Vector3(0,1,0)
// 创建PRB材质
const ballMat = new PBRMaterial('pbr',scene)
// albedoTexture 反照率贴图
ballMat.albedoTexture = new Texture('./textures/aerial_beach_02_diff_4k.jpg',scene)
// 法线贴图
ballMat.bumpTexture = new Texture('./textures/aerial_beach_02_nor_gl_4k.jpg',scene)
ballMat.invertNormalMapX = true
ballMat.invertNormalMapY = true
// ao贴图
ballMat.metallicTexture = new Texture('./textures/aerial_beach_02_ao_4k.jpg',scene)
ballMat.useAmbientOcclusionFromMetallicTextureRed = true
ballMat.useRoughnessFromMetallicTextureGreen = true
ballMat.useMetallnessFromMetallicTextureBlue = true
// 发光贴图
ballMat.emissiveTexture = new Texture('./textures/emissive.jpg',scene)
// 默认是黑色 不发光
ballMat.emissiveColor = new Color3(1,1,1)
// 发光强度
ballMat.emissiveIntensity = 1
// 材质接收到的环境光强度
ballMat.environmentIntensity = 0.25
// 发光层
const glowLayer = new GlowLayer('glow',scene)
glowLayer.intensity = 1
// 应用材质
ball.material = ballMat;