swift 快速奔跑的兔几 本节的内容是:SceneKit 第三说 使用材料 法向贴图

材料定义呈现对象的方式。默认情况下,所有对象都是由之中平整的白色的无光泽材料制成。但是我们可以做大幅度修改。可以修改的内容如下所示:
*散射分量diffuse:材料的基本颜色和纹理
*反射分量specular:材料的亮度如何,应当如何反射光
*发光分量
*法向分量normal:材料表面是否应具有更多细节来反射光

// 质感
        let redMetallicMaterial = SCNMaterial()
        redMetallicMaterial.diffuse.contents = UIColor.grayColor()
        redMetallicMaterial.specular.contents = UIColor.whiteColor()
        redMetallicMaterial.shininess = 1
        capsuleOne.materials = [redMetallicMaterial]
        // 文字纹理
        let noiseTexture = SKTexture(noiseWithSmoothness:0.25,size:CGSize(width: 512,height: 512),grayscale:true)
        let noiseMaterial = SCNMaterial()
        noiseMaterial.diffuse.contents = noiseTexture
        text3D.materials = [noiseMaterial]

法向贴图:

// 法向贴图
        let noiseNormalMapTexture = noiseTexture.textureByGeneratingNormalMapWithSmoothness(0.1,contrast: 1)
        redMetallicMaterial.normal.contents = noiseNormalMapTexture

将如上的代码应用于胶囊,胶囊会显得有一点变形。 法向贴图需要取得一个纹理,然后用它来计算,在物体表面的任何点上,光线应该如何反射。 法向贴图意味着我们可以伪造一个拥有更多细节的模型。

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...