美文网首页从零开始学习 Unity
002-从零开始学习 Unity 之 Lighting a Si

002-从零开始学习 Unity 之 Lighting a Si

作者: KomalZheng | 来源:发表于2019-07-20 18:22 被阅读0次

    前言

    边做边学系列之《Lighting a Simple Scene》

    微信公众号请点击下方查看原视频地址。
    原视频地址:https://lmhpoly.com/unity-2017-tutorial-lighting-a-simple-scene/

    上述视频,最终将会获得如下的效果:


    final_effect.png

    手把手教学

    Unity 选择 2019.2.0b7 版本
    Mac 开发环境

    创建 Unity 工程 DemoLightingASimpleScene


    02_create_new_scene.png

    顶部菜单栏 Edit -> Project Settings 弹出 Project Settings 面板

    Project Settings 面板选中 Player

    在 Settings for PC, Mac & Linux Standalone 中的 Other Settings 中将 Color Space* 更改为 Linear,按照文中的说法,目的是 "To have more realistic colors"

    Project 的 Assets 下新建一个 Folder,命名为 Meshes


    04_create_MeshesFolder.png

    从原视频地址下载所需要的资源文件 Box.fbx
    微信公众号请点击下方,在原视频地址链接中,获得下载链接。

    在新建的文件夹上右键 -> Import New Assets...
    将下载的 Box.fbx 导入到工程

    选中新导入的 Box,在 Inspector 的 Mode 中,勾选 Generate Lightmap UVs,因为我们需要使用 Lightmap UVs 来烘焙 Box 中的光照数据。

    点击 Apply 使新配置生效

    将 Meshes 中的 Box 拖拽到 Hierarchy 中,设置 Rotation Y 为 180

    在 Hierarchy 中新建 3D sphere,Transform 中的齿轮按钮(Gear Icon) 选择 Reset 重置 sphere 的 Transform 数据

    小技巧:
    w 键切换到移动工具(Move Tool),按住 Cmd 键,移动 sphere 时会匹配网格(默认配置是每次移动 1 格,Edit->Snap Settings 中可以将 x, y, z更改为 0.5)。

    将 sphere 的 y 设置为 0.5

    选中 sphere, Cmd + D 两次,复制 2 个 sphere
    一个 sphere 的 x 设为 1, 另一个 sphere 的 x 设为 -1

    选中 3 个 sphere, 将其 z 设置为 0.5

    Assets 文件夹下新建 Materials 文件夹

    Materials 文件夹下新建 Material,命名为 Sphere,并将 smoothness 设置为 0

    设置主摄像机的 Y: 1.34 Z: -3.64

    Hierarchy 中创建 3D 对象 Plane, Reset Data

    将其缩放设置为 x: 0.2, y: 1, z: 0.2
    旋转设置为 X: 0, Y: 180 Z: 90
    位置设置为 X: -1.999 Y: 1, Z: 0
    Plane 名字更改为 Light_1

    新建一个名为 MAT_Light_1 的 Material,勾选其 Emission。颜色设置为 白色

    将其设置为 Light_1 的 Material

    Hierarchy 中删除 Directional Light

    可以看到世界变暗了。而面光源 Light_1 设置的 Emission 对其他物体没有产生光照效果,现在我们要来修复它。

    选中 Main Camera 以外的所有场景物件,勾选它们的 Static

    Window -> Lighting -> Settings
    设置 Skybox Material 为 None
    设置 Ambient Color 为 Black

    复制 Light_1 为 Light_2
    更改 postion X 为 1.999
    更改 rotate Y 为 0

    复制 MAT_Light_1 材质 为 MAT_Light_2
    并设置 Light_2 的材质为 MAT_Light_2
    设置 Emission Color 为 0 202 255

    Lighting 标签设置 Realtime Global Illumination 为不可用,于是场景会使用 Baked Global Illumination 进行烘焙;

    禁用 Compress Lightmaps 来烘焙更高质量的 lightmaps

    Lightmap Size 设置为 256
    勾选 Ambient Occlusion
    设置 Max Distance 为 0.5 Indirect Contribution 为 0.1

    最终效果为:

    Screenshot 2019-07-20 at 6.20.40 PM.png

    相关文章

      网友评论

        本文标题:002-从零开始学习 Unity 之 Lighting a Si

        本文链接:https://www.haomeiwen.com/subject/akdulctx.html